[antlr-interest] Problem parsing left-recursive expressions (AntLR
2.7.5)
John B. Brodie
jbb at acm.org
Fri May 19 09:41:26 PDT 2006
on Fri, 19 May 2006 17:49:11 +0200, Kai Koehne asked:
>I have a rather nasty left-recursive structure to parse which I just
>cannot manage to handle correctly ...
>
> variable:
> NAME
> | variable LBRACK expression RBRACK
> | LBRACK variable FROM base (FOR count)? RBRACK
> ;
>...
how about (haven't actually tested it...):
variable :
( NAME | ( LBRACK variable FROM base (FOR count)? RBRACK ) )
( LBRACK expression RBRACK )*
;
Hope this helps...
-jbb
More information about the antlr-interest
mailing list