Package org.antlr.v4.analysis
Class LeftRecursiveRuleTransformer
java.lang.Object
org.antlr.v4.analysis.LeftRecursiveRuleTransformer
Remove left-recursive rule refs, add precedence args to recursive rule refs.
Rewrite rule so we can create ATN.
MODIFIES grammar AST in place.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLeftRecursiveRuleTransformer
(GrammarRootAST ast, Collection<Rule> rules, Grammar g) -
Method Summary
Modifier and TypeMethodDescriptionparseArtificialRule
(Grammar g, String ruleText) void
(RULE e int _p (returns int v) (BLOCK (ALT (BLOCK (ALT INT {$v = $INT.int;}) (ALT '(' (= x e) ')' {$v = $x.v;}) (ALT ID)) (* (BLOCK (OPTIONS ...) (ALT {7 >= $_p}? '*' (= b e) {$v = $a.v * $b.v;}) (ALT {6 >= $_p}? '+' (= b e) {$v = $a.v + $b.v;}) (ALT {3 >= $_p}? '++') (ALT {2 >= $_p}? '--'))))))boolean
translateLeftRecursiveRule
(GrammarRootAST ast, LeftRecursiveRule r, String language) Return true if successfulvoid
-
Field Details
-
PRECEDENCE_OPTION_NAME
- See Also:
-
TOKENINDEX_OPTION_NAME
- See Also:
-
ast
-
rules
-
g
-
tool
-
-
Constructor Details
-
LeftRecursiveRuleTransformer
-
-
Method Details
-
translateLeftRecursiveRules
public void translateLeftRecursiveRules() -
translateLeftRecursiveRule
Return true if successful -
parseArtificialRule
-
setAltASTPointers
(RULE e int _p (returns int v) (BLOCK (ALT (BLOCK (ALT INT {$v = $INT.int;}) (ALT '(' (= x e) ')' {$v = $x.v;}) (ALT ID)) (* (BLOCK (OPTIONS ...) (ALT {7 >= $_p}? '*' (= b e) {$v = $a.v * $b.v;}) (ALT {6 >= $_p}? '+' (= b e) {$v = $a.v + $b.v;}) (ALT {3 >= $_p}? '++') (ALT {2 >= $_p}? '--'))))))
-