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
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 ])