Class LeftRecursiveRuleTransformer


  • public class LeftRecursiveRuleTransformer
    extends Object
    Remove left-recursive rule refs, add precedence args to recursive rule refs. Rewrite rule so we can create ATN. MODIFIES grammar AST in place.
    • Method Detail

      • translateLeftRecursiveRules

        public void translateLeftRecursiveRules()
      • setAltASTPointers

        public void setAltASTPointers​(LeftRecursiveRule r,
                                      RuleAST t)
         (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}? '--'))))))