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

Sam Harwell sharwell at pixelminegames.com
Wed Aug 13 12:03:31 PDT 2008


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

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080813/007c43ae/attachment.html 


More information about the antlr-interest mailing list