[antlr-interest] Problem with Duplicating nodes/trees

Grzegorz Cieslewski cieslewski at hcs.ufl.edu
Fri Feb 8 06:00:27 PST 2008


Hello All,

I have encountered a problem with tree duplication during AST
construction.  I boiled my problem to following grammar.

grammar T2;
options {output=AST;}
tokens
{
	TEST;
}
a : c (',' c)* b -> ^(TEST c b)+
;
b 	:	INT;
c	: 	ID;

ID : 'a'..'z'+ ;
INT : '0'..'9'+;
WS : (' '|'\n') {$channel=HIDDEN;} ;

For input like "x, y, z 1", I was expecting to get a tree looking like
 ^(TEST x 1) ^(TEST y 1) ^(TEST z 1),
but the antlr seems not to duplicate the b rule and I get ^(TEST x 1)
^(TEST y) ^(TEST z).

Does any one know what am I doing wrong?  Is this a bug or a "feature".

Thanks,



-- 
=====================================================
Grzegorz Cieslewski
Research Assistant
High-performance Computing & Simulation (HCS) Research Laboratory
University of Florida, Dept. of Electrical and Computer Engineering
330 Benton Hall, Gainesville, FL, 32611-6200
Phone: (352) 392-9041
Email: cieslewski at hcs.ufl.edu
Web: www.hcs.ufl.edu
=====================================================


More information about the antlr-interest mailing list