[antlr-interest] Rewrite a list to a set of trees

Olaf Keijsers egrimm at dds.nl
Thu May 21 08:16:25 PDT 2009


Hello,

To make checking and generating easier, I would like to parse lines like the 
following:
node n1, n2, n3;

And turn them into trees like this:
(VAR 'node' 'n1')
(VAR 'node' 'n2')
(VAR 'node' 'n3')

At the moment I'm using the following rules to parse, but this obviously 
does not generate the result I would like to have:
var_declaration : var_type id_list -> ^(VAR var_type id_list) ;

id_list : IDENTIFIER (COMMA! id_list)? ;

Obviously, this generates trees like this:
(VAR 'node' 'n1' 'n2' 'n3')

Could anyone point me in a direction that allows me to end up with trees 
like I described above? If this is at all possible ;)

Thanks a lot!

Olaf Keijsers 



More information about the antlr-interest mailing list