[antlr-interest] List-Labels Problem

Daniel Kasmeroglu Daniel.Kasmeroglu at Kasisoft.net
Tue Jul 1 03:21:10 PDT 2008


Maybe I'm a fool but I'm struggling with a grammar that looks like the following

one:



declaration_header :    '[' e+=id (',' e+=id)* ']' -> header(elements={e}) ;



id                 :     'id' i=ID -> element(el={i});



For an input like this: "[ id bla, id blub, id frog, id hello ]" I expected to 
handle a list of 4 items using the StringTemplate header (see rule 
declaration_header). But there's only the last label processed. Checking out the 
parser I've noticed that the label itself will be passed as an argument instead 
of the list-variable. Is that correct behaviour (according to Chapter 4 of the 
ANTLR Reference I believe not) ? And if it is correct where is this documented ?

Can anyone explain to me why and how such a list label can be handled ?



Thanks in advance.



Ciao

Kasimir


More information about the antlr-interest mailing list