[antlr-interest] Invalid rule text

Gerz, Michael Gerz at fgan.de
Mon Jun 23 05:25:15 PDT 2008


Hello again!

> In my tree grammar, there is a rule that looks like this:
> 
> 
> expressionList
>    @after { System.out.println($expressionList.text); }
>     :  
>         ( expression   { System.out.println($expression.text); }   )+
>    ;
>
>
> When this rule is entered, it outputs one or more <expression>'s. 
> However, at the end (i.e. in @after), it only outputs the first
element of 
> the expressionList.

I finally realized what the problem is:

expressionList does not have a root token but instead consists of a list
of tokens!

Is there any chance to warn the user if he wants to access the text of a
rule that apparently has no root token? I can imagine I am not the only
one stumbling over this problem...

Best regards,

Michael



More information about the antlr-interest mailing list