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

Mikesell, Darin B. Darin.Mikesell at gd-ais.com
Thu Jul 1 15:52:35 PDT 2010


So in your grammar it's possible to have an expression of the form:

++primary_variable KW_INSTANCEOF identifier KW_INSTANCEOF identifier KW_INTANCEOF identifier KW_INSTANCEOF identifier and on and on?


- Darin

-----Original Message-----
From: Mikesell, Darin B. 
Sent: Thursday, July 01, 2010 3:51 PM
To: 'vuurwerk.christian at gmail.com'
Subject: RE: [antlr-interest] Issues with mutually left-recursive rules

So in your grammar it's possible to have an expression of the form:

++primary_variable KW_INSTANCEOF identifier KW_INSTANCEOF identifier KW_INTANCEOF identifier KW_INSTANCEOF identifier and on and on?


- Darin


-----Original Message-----
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Christian (VuuRWerK) Seifert
Sent: Thursday, July 01, 2010 3:03 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] Issues with mutually left-recursive rules

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

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address


More information about the antlr-interest mailing list