0

Every solution I found on SO was "switch to ANTLR4" which isn't really an option because I am using antlr4ruby (which is ANTLR3, the 4 is meant as "for").

I want to build a rule for property access, it should match something like this:

variable
variable.property
variable.prop.prop
etc.

here's what I have:

variable: NAME -> ^(VARIABLE NAME) | variable DOT NAME -> ^(ACCESS variable NAME);

(VARIABLE and ACCESS are parser tokens for use later, NAME is a kind of string).

This is obviously left-recursive, but I have no idea how to fix this.

s-ol
  • 1,674
  • 17
  • 28
  • http://en.wikipedia.org/wiki/Left_recursion#Removing_left_recursion may help. – Mephy Apr 28 '15 at 00:20
  • that doesn't work because I need the inverted result; for `a.b.c` the AST should be `(A c (A b a))` not `(A a (A b c))`. – s-ol Apr 28 '15 at 00:33

0 Answers0