[antlr-interest] Consumed input in V3

Mark Bednarczyk voytechs at yahoo.com
Fri Mar 2 09:19:56 PST 2007


I've been scratching my head on this little rule for a while since since I
discovered my fully qualified names are being rewritten incorrecly:
 
rule	:	i1=Identifier
        	('.' i2=Identifier)*
        	-> ^(ID $i1 ($i2)*)
	;

Output is from the CommonTree.toStringTree() call. 

input = "com.slytechs.def"
output = (ID com def)

Without the rewrite the same rule works as expected:

rule	:	i1=Identifier
        	('.'! i2=Identifier)*
	;

input = "com.slytechs.def"
output = com slytechs def

Obviously we loose the ID token as the root of this tree, but the output
contains a flat list of all the elements. Seems like the ($i2)* for
multivalue list is not working properly and dropping the front elements of
the list.

The rewrite rule seems to be dropping everything in the beginning of the
('.' i2=Identifier)* except the last token:

input = "com.org.slytechs.def"
output = (ID com def)

Any ideas to get all the elements of the rewrite added to the result tree?

Cheers,
mark...




More information about the antlr-interest mailing list