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

Dave Carey dacarey at gmail.com
Sun Oct 21 06:31:06 PDT 2007


I think I answered my own question here and it seems it is a typo in the
book.
If the if clause you don't prefix el with a '$'   so it is

  if(el!=null)


On 21/10/2007, Dave Carey <dacarey at gmail.com> wrote:
>
> 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/fb7e2a05/attachment.html 


More information about the antlr-interest mailing list