This flag enables or disables error recovery (fault tolerance) of the parser. If this flag is disabled the parser will halt on the first error.
Convenience method equivalent to AT_LEAST_ONE1
convenience method, same as MANY but the repetition is of one or more. failing to match at least one repetition will result in a parsing error and cause the parser to attempt error recovery.
The lookahead function that 'decides' whether or not the AT_LEAST_ONE's action will be invoked or the action to optionally invoke
Convenience method equivalent to AT_LEAST_ONE_SEP1
convenience method, same as MANY_SEP but the repetition is of one or more. failing to match at least one repetition will result in a parsing error and cause the parser to attempt error recovery.
The lookahead function that 'decides' whether or not the AT_LEAST_ONE's action will be invoked or the action to optionally invoke
the rule to try and parse in backtracking mode
a predicate that given the result of the parse attempt will "decide" if the parse was successfully or not
a lookahead function that will try to parse the given grammarRule and will return true if succeed
Convenience method equivalent to CONSUME1
A Parsing DSL method use to consume a single terminal Token. a Token will be consumed, IFF the next token in the token vector is an instanceof tokClass. otherwise the parser will attempt to perform error recovery.
The index in the method name indicates the unique occurrence of a terminal consumption inside a the top level rule. What this means is that if a terminal appears more than once in a single rule, each appearance must have a difference index.
for example:
function parseQualifiedName() { this.CONSUME1(Identifier); this.MANY(()=> { this.CONSUME1(Dot); this.CONSUME2(Identifier); // <-- here we use CONSUME2 because the terminal }); // 'Identifier' has already appeared previously in the // the rule 'parseQualifiedName' }
A constructor function specifying the type of token to be consumed.
The consumed token.
Convenience method equivalent to MANY1
Parsing DSL method, that indicates a repetition of zero or more. This is equivalent to EBNF repetition {...}
note that the 'action' param is optional. so both of the following forms are valid:
short: this.MANY(()=>{ this.CONSUME(Comma}; this.CONSUME(Digit}); long: this.MANY(isComma, ()=>{ this.CONSUME(Comma}; this.CONSUME(Digit});
using the short form is recommended as it will compute the lookahead function automatically. however this currently has one limitation: It only works if the lookahead for the grammar is one.
As in CONSUME the index in the method name indicates the occurrence of the repetition production in it's top rule.
The lookahead function that 'decides' whether or not the MANY's action will be invoked or the action to optionally invoke
Convenience method equivalent to MANY_SEP1
Parsing DSL method, that indicates a repetition of zero or more with a separator Token between the repetitions.
note that the 'action' param is optional. so both of the following forms are valid:
short: this.MANY_SEP(Comma, ()=>{ this.CONSUME(Number}; ... );
long: this.MANY(Comma, isNumber, ()=>{ this.CONSUME(Number} ... );
using the short form is recommended as it will compute the lookahead function (for the first iteration) automatically. however this currently has one limitation: It only works if the lookahead for the grammar is one.
As in CONSUME the index in the method name indicates the occurrence of the repetition production in it's top rule.
The Token to use as a separator between repetitions.
The lookahead function that 'decides' whether or not the MANY_SEP's action will be invoked or the action to optionally invoke
Convenience method equivalent to OPTION1
Parsing DSL Method that Indicates an Optional production in EBNF notation: [...]
note that the 'action' param is optional. so both of the following forms are valid:
short: this.OPTION(()=>{ this.CONSUME(Digit}); long: this.OPTION(isDigit, ()=>{ this.CONSUME(Digit});
using the short form is recommended as it will compute the lookahead function automatically. however this currently has one limitation: It only works if the lookahead for the grammar is one.
As in CONSUME the index in the method name indicates the occurrence of the optional production in it's top rule.
The lookahead function that 'decides' whether or not the OPTION's action will be invoked or the action to optionally invoke
true iff the OPTION's action has been invoked
Convenience method equivalent to OR1
Parsing DSL method that indicates a choice between a set of alternatives must be made. This is equivalent to EBNF alternation (A | B | C | D ...)
There are two forms:
short: this.OR([ {ALT:()=>{this.CONSUME(One)}}, {ALT:()=>{this.CONSUME(Two)}}, {ALT:()=>{this.CONSUME(Three)}}, ], "a number")
long: this.OR([ {WHEN: isOne, THEN_DO:()=>{this.CONSUME(One)}}, {WHEN: isTwo, THEN_DO:()=>{this.CONSUME(Two)}}, {WHEN: isThree, THEN_DO:()=>{this.CONSUME(Three)}}, ], "a number")
using the short form is recommended as it will compute the lookahead function automatically. however this currently has one limitation: It only works if the lookahead for the grammar is one LL(1).
As in CONSUME the index in the method name indicates the occurrence of the alternation production in it's top rule.
The result of invoking the chosen alternative
The name of the rule.
The implementation of the rule.
The parsing rule which is the production implementation wrapped with the parsing logic that handles Parser state / error recovery&reporting/ ...
Convenience method equivalent to SUBRULE1
The Parsing DSL Method is used by one rule to call another.
This may seem redundant as it does not actually do much. However using it is mandatory for all sub rule invocations. calling another rule without wrapping in SUBRULE(...) will cause errors/mistakes in the Recognizer's self analysis which will lead to errors in error recovery/automatic lookahead calculation and any other functionality relying on the Recognizer's self analysis output.
As in CONSUME the index in the method name indicates the occurrence of the sub rule invocation in its rule.
the rule to invoke
the arguments to pass to the invoked subrule
the result of invoking ruleToCall
By default all tokens type may be inserted. This behavior may be overridden in inheriting Recognizers for example: One may decide that only punctuation tokens may be inserted automatically as they have no additional semantic value. (A mandatory semicolon has no additional semantic meaning, but an Integer may have additional meaning depending on its int value and context (Inserting an integer 0 in cardinality: "[1..]" will cause semantic issues as the max of the cardinality will be greater than the min value. (and this is a false error!)
The Type of Token we wish to consume (Reference to its constructor function)
occurrence index of consumed token in the invoking parser rule text for example: IDENT (DOT IDENT)* the first ident will have idx 1 and the second one idx 2
* note that for the second ident the idx is always 2 even if its invoked 30 times in the same rule
the idx is about the position in grammar (source code) and has nothing to do with a specific invocation
details
the consumed Token
The Class of the expected Token.
The actual unexpected (mismatched) Token instance encountered.
The error message saved as part of a MismatchedTokenException.
Returns an "imaginary" Token to insert when Single Token Insertion is done Override this if you require special behavior in your grammar for example if an IntegerToken is required provide one with the image '0' so it would be valid syntactically
Generated using TypeDoc
A Recognizer capable of self analysis to determine it's grammar structure This is used for more advanced features requiring such information. for example: Error Recovery, Automatic lookahead calculation