[antlr-interest] missing attribute access on rule scope when testing token in action section

Dave Carey dacarey at gmail.com
Sun Oct 21 05:30:55 PDT 2007


I have a question regarding "action section" and testing for the presence of
optional tokens inside them
According to the v3 Definitive Antlr Guide ( section 6.3) you can do
something like this:-

stat: 'if' expr 'then' stat(el='else' stat)?
{
   if($el!=null)
       System.out.println("found an else");}
|...
;

In fact when I try this same example ( Anrlr 3.0.1)   I always get

error(117): Test.g3:116:4: missing attribute access on rule scope: el

You can workaround by access the token contents supplying an attribute e.g.
$el.text:  but this doesn't feel right and the guide suggests that it should
work as prescribed.

Can anybody clarify?

Cheers
Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20071021/6699ec86/attachment.html 


More information about the antlr-interest mailing list