-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Virtlink
committed
Mar 16, 2016
1 parent
98cb8bb
commit c841a6c
Showing
5 changed files
with
244 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Lexing and Parsing | ||
IntelliJ relies on a lexer and parser. | ||
|
||
## Lexer | ||
The lexer shall extend the `com.intellij.lexer.Lexer` class (usually through | ||
the `com.intellij.lexer.LexerBase` class). IntelliJ will call its `start` | ||
method, providing it with a character buffer and range that need to be lexed, | ||
and the lexer state at the start of the region. Then the lexer will lex forward | ||
on each call to `advance`, providing information about the current token's type | ||
and offset, and the lexer state at that point. | ||
|
||
Note that the lexer may not know which file is being lexed, and it needs to be | ||
able to start at any arbitrary point in the input. Also, it needs to return | ||
_every_ token, including layout, even invalid ones. | ||
|
||
## Parser | ||
The parser is fed the lexer tokens, and turns them into AST nodes. A single AST | ||
node can consist of multiple tokens. Again, the parser must be able to parse | ||
from within a file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.