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.
utility to help the poor souls who are still stuck writing pure javascript 5.1 extend and create Token subclasses in a less verbose manner
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 SimpleLazyToken "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 instance of of the type of a specific Token class. Simply using instanceof is not enough because SimpleLazyToken Implementation does not use ECMAScript's built-in prototype inheritance.
Generated using TypeDoc
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 ])