Posted By:
emilianoarg
Posted On:
Sunday, June 17, 2012 04:40 AM
I've discover that the following grammar seems to work fine but its not casting properly to our Node class.
declareStatement: n+=type+ VARIABLE (COMMA VARIABLE)* SEMICOLON -> ^(VARIABLE type+<type>)+;
Remember that the code to be parsed was int VALOR, VALORD;
I have a NodeFactory and Nodes of type Variable, IntegerTypeLiteral, etc.
For any strange reason It creates the tree but presents the following description when I debug it:
1) Variable VALOR and a child IntegerTypeLiteral
2) Variable VALORD and a child CommonTree
I've captured the properties in runtime.
1) children=null, startIndex=0, stopIndex=0, token=CommonToken, type=null.
2) children=null, startIndex=-1, stopIndex=-1, token=CommonToken.
The two 'int' exist, but the second 'int' that corresponds to VALORD is not capable to cast to IntegerTypeLiteral. The first int has a property type that is not present in the second int.
I think this type is the key of the problem.
I would appreciate your help.
Thanks,
Emiliano.
I'm interested to participate in ANTLR forum. If you know another forum to participate in please send me information about this.
Thanks!