[antlr-interest] How to resolve the left-recursion problem?
YiQing Yang
yiqing at objectivity.com
Mon Jun 4 18:20:58 PDT 2007
Hi,
I need to write a parser rule for an extended class attribute namme
expression. It could be simply a single attribute name with the class scope
as option (persion::name) or a series of attribute names chained by "." (ie,
"employer.ceo.name": "ceo" is an attribute of "employer" corresponded class.
"name" is an attribute of "ceo" corresponded class).
I wrote the parser rules as following which contains left-recursion. I do
not know how to resolve this problem without changing the semantic. I would
appreciate if anyone could help.
-----------------------------------------------------
attribute_expression
: attribute_name
| dot_operator_exp
;
dot_operator_exp
: attribute_expression DOT attribute_name
;
attribute_name
: n1:NAME (SCOPE n2:NAME)?
;
------------------------------------------------------
Yiqing Yang
More information about the antlr-interest
mailing list