[antlr-interest] Expr.text null?

Terence Parr parrt at cs.usfca.edu
Tue Aug 12 15:31:39 PDT 2008


should work.  java target right?  did you setTokenStream on the node  
stream?
Ter
On Aug 12, 2008, at 3:23 PM, Foust wrote:

> Does it make sense that a matched sub-rule returns null for its text  
> attribute?
>
> That is, the following rule matches the input AST just fine.
>
> tree grammar;
> expr : a? b;
>
> a : ^(SOME_TOKEN someargs)
> b: ^(etc…)
>
>
> But when the text of a is desired, it always returns null, whether  
> in the rule action, or in a sub-rule action, as below:
>
> expr : (a {System.out.println($a.text); } )?  b  ;
>
> prints “null”.
>
>



More information about the antlr-interest mailing list