Jan F wrote:
> Hello fellow ANTLRs, I have a problem with obtaining text and positions for
> one of my rules ion a tree walker, and since I ran out of ideas on what
> might be wrong I am here to ask :-)
> 
> My rule looks like this:
> 
> memberExpression returns [ Expression expression = null ]
> @after { post ($expression, $memberExpression.start,
> $memberExpression.text); }
>     : ^( BYINDEX parenLeftHandSideExpression expressionSt ) {
>        $expression = new NIndexRefExpression (0, 0,
> $parenLeftHandSideExpression.expression, $expressionSt.statement);
>   }
>     | ^( BYFIELD parenLeftHandSideExpression Identifier ) {
>        $expression = new NFieldRefExpression (0, 0,
> $parenLeftHandSideExpression.expression, $Identifier.text);
>      }
>     ;
> 
> and the problem is that $memberExpression.text returns empty string, caused
> by the fact that $memberExpression.start has the start/stop indexes as -1.
By my understanding the .text attribute on a tree-walker rule will only
return you the text from the top node of the tree. Is your parser
constructing the BYINDEX / BYFIELD tokens with any useful text in them? By
default, imaginary nodes get constructed with empty text.

Richard
-- 
\o/

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to