[antlr-interest] Tree grammar bizarre behaviour?

Iwud H8u iwudh8u at hotmail.com
Sun Feb 7 16:34:52 PST 2010


Hi,

I am hoping someone can enlighten me on how ANTLR generates the TreeParser
java code from tree grammar. I have a tree grammar file with exactly the
same code for two different tokens, both of which must return the same
object type. The generated Java code for one returns the object type
expected, whereas the other does not! My tree grammar looks like : 

token1 returns [ObjectA a]
    :  ^(C_ID (conId=classId {$a=evaluateAndReturnAsObjectA($conId.text); })
);

token2 returns [ObjectA m]
    :  ^(C_ID (id=classId {$m=evaluateAndReturnAsObjectA($id.text); }) );

The tokens token1, token2 and classId are part of my parser vocabulary.

Oddly, the Java methods generated for the methods have the following return
types :
 --- MyTree.token1_return token1() { ... }
 --- ObjectA token2() { .. }

I'm slightly at my wits end, understanding whats going on. What am I missing
here?

Many thanks in advance...
J
-- 
View this message in context: http://n2.nabble.com/Tree-grammar-bizarre-behaviour-tp4531741p4531741.html
Sent from the ANTLR mailing list archive at Nabble.com.


More information about the antlr-interest mailing list