[antlr-interest] List-Labels Problem

André van der Merwe AndrevdM at pyrogenesis.co.za
Tue Jul 1 03:23:51 PDT 2008


Hi,

Have you tried using $e?

e.g.
   -> header(elements={$e}) ;

Andre


-----Original Message-----
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