It looks like I missed a few posts on this topic from a few days ago
(Thanks, Jim!)

The suggestion appears to pass, for a tree grammar rule like:

expression    returns[ExpressionValue eval]
    :
        ^(PLUS left = expression right = expression)

to use $e.tree and then get the line and column info.

On the Java target, the following:

CommonTree tree = $left.tree;

generates:

CommonTree tree = (left!=null?((CommonTree)left.tree):null);

But there is no variable called tree (apparently). There is, however, a
"getTree()" function, but it doesn't look like ANTLR automatically
translates it into that form, so I assume that's not its intended use. If,
however, I hack the generated code and put in something similar to

(CommonTree)left.getTree()) the result appears to always be null.

Jim, does your solution have some preconditions I'm not seeing?

Andy

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

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

Reply via email to