This is the default logic Chevrotain uses to construct error messages. When constructing a custom error message provider it may be used as a reference or reused.
Convenience used to express an empty alternative in an OR (alternation). can be used to more clearly describe the intent in a case of empty alternation.
For example:
without using EMPTY_ALT:
this.OR([ {ALT: () => {
this.CONSUME1(OneTok)
return "1"
}}, {ALT: () => {
this.CONSUME1(TwoTok)
return "2"
}}, {ALT: () => { // implicitly empty because there are no invoked grammar rules (OR/MANY/CONSUME...) inside this alternative.
return "666"
}}, ])
using EMPTY_ALT:
this.OR([ {ALT: () => {
this.CONSUME1(OneTok)
return "1"
}}, {ALT: () => {
this.CONSUME1(TwoTok)
return "2"
}}, {ALT: EMPTY_ALT("666")}, // explicitly empty, clearer intent ])
Clears the chevrotain internal cache. This should not be used in regular work flows, This is intended for unique use cases for example: online playground where the a parser with the same name is initialized with different implementations multiple times.
The configuration for
Utility to create Chevrotain Token "instances" Note that Chevrotain tokens are not real instances, and thus the instanceOf cannot be used.
{{image: string, startOffset: number, endOffset: number, startLine: number, endLine: number, startColumn: number, endColumn: number, tokenType}}
The name of the new TokenClass
RegExp Pattern or Parent Token Constructor
The Token class to be extended
Given a Token instance, will return the Token Constructor. Note that this function is not just for convenience, Because a Token "instance' Does not use standard prototype inheritance and thus it's constructor cannot be accessed by traversing the prototype chain.
This can be used to improve the quality/readability of error messages or syntax diagrams.
A constructor for a Token subclass
A Utility method to check if a token is of the type of the argument Token class. Not that while this utility has similar semantics to ECMAScript "instanceOf" As Chevrotain tokens support inheritance.
It is not actually implemented using the "instanceOf" operator because Chevrotain Tokens have their own performance optimized inheritance mechanism.
Generated using TypeDoc
The type of custom pattern matcher functions. Matches should only be done on the start of the text. Note that this is similar to the signature of RegExp.prototype.exec
This should behave as if the regExp match is using a start of input anchor. So: for example if a custom matcher is implemented for Tokens matching: /\w+/ The implementation of the custom matcher must implement a custom matcher for /^\w+/.
The Optional tokens and groups arguments enable accessing information about previously identified tokens if necessary.
This can be used for example to lex python like indentation. see: https://github.com/SAP/chevrotain/blob/master/examples/lexer/python_indentation/python_indentation.js for a fuller example