Readonly
dedentThe token type to be used for dedentation tokens
Protected
diagnosticsThe list of diagnostics stored during the lexing process of a single text.
Protected
indentationThe stack stores all the previously matched indentation levels to understand how deeply the next tokens are nested. The stack is valid for lexing
Readonly
indentThe token type to be used for indentation tokens
Readonly
optionsProtected
whitespaceA regular expression to match a series of tabs and/or spaces. Override this to customize what the indentation is allowed to consist of.
Protected
buildProtected
buildProtected
buildOptional
options: TokenBuilderOptionsProtected
buildProtected
buildOptional
options: TokenBuilderOptionsProtected
createHelper function to create an instance of an indentation token.
Indent or dedent token type
Full input string, used to calculate the line number
The original image of the token (tabs or spaces)
Current position in the input string
The indentation token instance
Protected
dedentA custom pattern for matching dedents
The full input string.
The offset at which to attempt a match
Previously scanned tokens
Token Groups
Protected
findProduces a lexing report for the given text that was just tokenized using the tokens provided by this builder.
The text that was tokenized.
Protected
getProtected
indentA custom pattern for matching indents
The full input string.
The offset at which to attempt a match
Previously scanned tokens
Token Groups
Protected
isProtected
matchA helper function used in matching both indents and dedents.
The full input string.
The current position at which to attempt a match
Previously scanned tokens
Token Groups
The current and previous indentation levels and the matched whitespace
Protected
popProtected
regexProtected
requires
A token builder that is sensitive to indentation in the input text. It will generate tokens for indentation and dedentation based on the indentation level.
The first generic parameter corresponds to the names of terminal tokens, while the second one corresponds to the names of keyword tokens. Both parameters are optional and can be imported from
./generated/ast.js
.Inspired by https://github.com/chevrotain/chevrotain/blob/master/examples/lexer/python_indentation/python_indentation.js