[antlr-interest] Keyword for referencing the enclosing rule in rewrite scope?

Terence Parr parrt at cs.usfca.edu
Wed Aug 13 13:10:15 PDT 2008


The ambig is a warning I think in antlr.  Just add a label to  
disambig...no need for a keyword.
Ter
On Aug 13, 2008, at 12:03 PM, Sam Harwell wrote:

> As I mentioned before, this construct as it exists in v3.1 will give  
> a compile error even when a label reference is unambiguous according  
> to the language rules. The error’s purpose is solely to alert the  
> user to the possibility they meant something other than what they  
> wrote (could be a warning?). To prevent the problem, I propose  
> adding a special keyword to consistently designate the enclosing  
> rule’s label in the rewrite scope.
>
> Right now, I write the following, and have a local change to  
> suppress the compile error.
>
> rule
> :               (              ID
>                                 -> ^(ID)
>                 )
>                 (              NUMBER rule
>                                 ->            ^(NUMBER $rule rule)
>                                 )?
>                 ;
>
> I propose writing the following instead.
>
> rule
> :               (              ID
>                                 -> ^(ID)
>                 )
>                 (              NUMBER rule
>                                 ->            ^(NUMBER $this rule)
>                                 )?
>                 ;
>
> Sam
>



More information about the antlr-interest mailing list