com.intellij.lang
Interface ParserDefinition


public interface ParserDefinition

Defines the implementation of a parser for a custom language.

See Also:
Language.getParserDefinition()

Method Summary
 PsiElement createElement(ASTNode node)
          Creates a PSI element for the specified AST node.
 PsiFile createFile(Project project, java.lang.String name, java.lang.CharSequence text)
          Creates a PSI element for the file with the specified name and contents.
 PsiFile createFile(Project project, VirtualFile file)
          Creates a PSI element for the specified virtual file.
 Lexer createLexer(Project project)
          Returns the lexer for lexing files in the specified project.
 PsiParser createParser(Project project)
          Returns the parser for parsing files in the specified project.
 TokenSet getCommentTokens()
          Returns the set of token types which are treated as comments by the PSI builder.
 IFileElementType getFileNodeType()
          Returns the element type of the node describing a file in the specified language.
 TokenSet getWhitespaceTokens()
          Returns the set of token types which are treated as whitespace by the PSI builder.
 

Method Detail

createLexer

@NotNull
Lexer createLexer(Project project)
Returns the lexer for lexing files in the specified project. This lexer does not need to support incremental relexing - it is always called for the entire file.

Parameters:
project - the project to which the lexer is connected.
Returns:
the lexer instance.

createParser

@NotNull
PsiParser createParser(Project project)
Returns the parser for parsing files in the specified project.

Parameters:
project - the project to which the parser is connected.
Returns:
the parser instance.

getFileNodeType

IFileElementType getFileNodeType()
Returns the element type of the node describing a file in the specified language.

Returns:
the file node element type.

getWhitespaceTokens

@NotNull
TokenSet getWhitespaceTokens()
Returns the set of token types which are treated as whitespace by the PSI builder. Tokens of those types are automatically skipped by PsiBuilder. Whitespace elements on the bounds of nodes built by PsiBuilder are automatically excluded from the text range of the nodes.

Returns:
the set of whitespace token types.

getCommentTokens

@NotNull
TokenSet getCommentTokens()
Returns the set of token types which are treated as comments by the PSI builder. Tokens of those types are automatically skipped by PsiBuilder. Also, To Do patterns are searched in the text of tokens of those types.

Returns:
the set of comment token types.

createElement

@NotNull
PsiElement createElement(ASTNode node)
Creates a PSI element for the specified AST node. The AST tree is a simple, semantic-free tree of AST nodes which is built during the PsiBuilder parsing pass. The PSI tree is built over the AST tree and includes elements of different types for different language constructs.

Parameters:
node - the node for which the PSI element should be returned.
Returns:
the PSI element matching the element type of the AST node.

createFile

PsiFile createFile(Project project,
                   VirtualFile file)
Creates a PSI element for the specified virtual file.

Parameters:
project - the project to which the file belongs.
file - the file for which the PSI element is created.
Returns:
the PSI file element.

createFile

PsiFile createFile(Project project,
                   java.lang.String name,
                   java.lang.CharSequence text)
Creates a PSI element for the file with the specified name and contents.

Parameters:
project - the project to which the file belongs.
name - The name of the file.
text - The contents of the file.
Returns:
the PSI file element.