[antlr-interest] Consumed input in V3

David Holroyd dave at badgers-in-foil.co.uk
Fri Mar 2 16:10:24 PST 2007


In addition to Jim's suggestion...

On Fri, Mar 02, 2007 at 12:19:56PM -0500, Mark Bednarczyk wrote:
> rule	:	i1=Identifier
>         	('.' i2=Identifier)*
>         	-> ^(ID $i1 ($i2)*)
> 	;
> 
> Output is from the CommonTree.toStringTree() call. 
> 
> input = "com.slytechs.def"
> output = (ID com def)

Each time around the (..)* overwrites 'i2', so you only see the last
subtree matched.

ANTLR will automatically collect lists of subtrees for the distinct
names on the l.h.s. of the rewrite; to use them, drop the labels and use
the names directly on the r.h.s.,

  rule 	:	Identifier
		('.' Identifier)*
		-> ^(ID Identifier+)
	;

ta,
dave

-- 
http://david.holroyd.me.uk/


More information about the antlr-interest mailing list