Class Lexer
java.lang.Object
org.clafer.frontend.Lexer
Splits the explicit form of a Clafer model, as
AstPrinter
prints it, into tokens.
Whitespace and line breaks only separate tokens: nesting is in braces, and
indentation carries no meaning. Comments (// ... to the end of the
line and /* ... */) are set aside with their spans, for
tools that show or keep them.
Lines and columns start at 1. A column counts UTF-16 code units, as the Language Server Protocol does by default, so a tab is one column. A span ends after its last character.
The lexer does not stop at an error: an unexpected character or an
unterminated string becomes an TokenKind.ERROR token with a
diagnostic, and lexing goes on after it.
-
Nested Class Summary
Nested Classes -
Method Summary
-
Method Details
-
lex
Splits a source text into tokens.- Parameters:
source- the source text- Returns:
- the tokens, the comments and the errors
-
unescape
Decodes a string token: drops the quotes and replaces the escapes.- Parameters:
token- the text of aTokenKind.STRINGtoken- Returns:
- the string it denotes
-