[antlr-interest] ANTLR v3.1.1 released

Sam Harwell sharwell at pixelminegames.com
Tue Jan 20 20:18:58 PST 2009


I've mentioned this behavior several times before. Currently, despite
the error, the Tool does behave in the way it states (it references the
enclosing rule). I assure you there is no syntactic or semantic
ambiguity in this use case under the documented rules of an ANTLR
grammar's rewrite syntax. With a $, it must refer to the enclosing rule.
Without a $, it can only refer to the result of a rule reference. I
finally just commented out the code in the tool that reports the error
so I could make use of this feature in my grammars. One place that
benefits from it is conversion of certain rules from recursive to
iterative in cases where stack depth is causing problems.

Honestly it shouldn't even be a warning, as it's like the following in
C# code.

class Foo
{
  int a;

  void B( int a )
  {
    // this use of a is *not* a warning, as it unambiguously refers to
the method's parameter:
    if ( a == 3 )
    {
    }
  }
}

Sam

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Terence Parr
Sent: Tuesday, January 20, 2009 7:14 PM
To: Randall R Schulz
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] ANTLR v3.1.1 released

interesting...so this should be a warning then?  I'm not sure which is  
correct.  It is most likely an error; I wouldn't rely on which it  
chooses.
Ter
On Oct 2, 2008, at 10:25 AM, Randall R Schulz wrote:

>
> It just got worse.
>
> I've got a rule that refers ambiguously to itself in a tree building
> construct:
>
> op790Formula
>    :   (op780Formula -> op780Formula)
>        (
>            Or rDisjunct = op790Formula
>        ->  ^(Or $op790Formula $rDisjunct)
>        ) ?
>    ;
>
> ANTLR tells me this:
>
> error(132): P9.g:581:11: reference $op790Formula is ambiguous;
> 	rule op790Formula is enclosing rule and referenced in the
production
> 	(assuming enclosing rule)
>
>
> Now it says it assumed the enclosing rule, which is what I want, so I
> figure the resulting code would be OK (and it does generate the usual
> complement of Java source files), but since this is labelled as an
> error, not a warning, my script thinks it cannot go on to run Ant to
> build the class files.
>
>
> Randall Schulz
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-addr
ess
>


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