[antlr-interest] Trying to resolve mutual left-recursion

向秦贤 fyaoxy at gmail.com
Wed Sep 26 23:36:55 PDT 2007


I try it:)
At first let me rewrite by math-like style
query=join | noj    1)
noj = nojterm | query others 2)
let we replace noj of 1) by use 2), so get
query = join | (nojterm | query others)    3)
so (soooorry for my english), get
query = join | nojterm | query others 4)
query = join | nojterm | (join | nojterm | query others) others 4)
and so concludise join and nojterm times, maybe like
query = (join | nojterm)+ others
:)
Could you give some grammar target details?

2007/9/27, Jeremy Sheldon <Jeremy.Sheldon at 90degreesoftware.com>:
>
>
>
>
> Hi everyone,
>
>
>
> I'm new to Antlr and have come up against mutual left-recursion for the
> first time.  Despite doing some googling, I'm still struggling to try and
> remove it.  Would anyone be kind enough to give me some pointers?
>
>
>
> Here are the culprits:
>
>
>
> query_expression
>
>                 : joined_table
>
>                 |  non_join_query_expression;
>
>
>
> non_join_query_expression
>
>                 :  non_join_query_term
>
>                 |  query_expression (UNION ALL | EXCEPT ALL)?
> corresponding_spec? query_term;
>
>
>
> Thanks in advance for your help,
>
> Jeremy


-- 
致敬
向秦贤


More information about the antlr-interest mailing list