[antlr-interest] Issues with mutually left-recursive rules

Christian (VuuRWerK) Seifert vuurwerk.christian at googlemail.com
Thu Jul 1 15:02:47 PDT 2010


Hi list,

I've got some troubles with mutually left-recursive rules in my
grammar (which is just an easy conversion of an original EBNF
grammar).

First the error message:
========== >8 ==========
error(210):  The following sets of rules are mutually left-recursive
[pre_unary_expression, expression, array_declaration]
========== 8< ==========

The rules which cause the error:
========== >8 ==========
expression          : pre_unary_expression ( binary_operator expression )?;

pre_unary_expression: '++' primary_variable
                    | '--' primary_variable
                    | unary_expression
                    | expression KW_INSTANCEOF identifier
                    | array_declaration
                    ;

array_declaration   : KW_ARRAY '(' ( ( expression '=>' )? expression (
',' expression )* ( ',' )? )? ')'
                    | expression '..' expression
                    ;
========== 8< ==========

If I remove the pre_unary_expression from the expression rule the
error disappear, But for my intention the rule "expression" comprise a
pre_unary_expression.

I've already read
http://www.antlr.org/wiki/display/ANTLR3/Left-Recursion+Removal and
tried it as the author suggest it but I get no idea which rules I
should "inline". And ANTLRWorks means the selected rule has no
left-recursion ...
I've also read a lot of left-recursion and how to remove it but all
what I've tried so far doesn't work :(

I'm very sad about that I can't get it to work and it's my last idea
to try one's luck here at the list.
Hope someone can help me or just can give me a hint where I can find
more infos about to solve my problem.

Best regards
Christian


More information about the antlr-interest mailing list