dcsimg
ANTLR, StringTemplate and list labels
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Daniel_Kasmeroglu
Posted On:   Sunday, June 29, 2008 06:04 AM

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 template 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, can anyone explain to me why    More>>

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 template 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, can anyone explain to me why and how such a list label can be handled ?

Thanks in advance.

Ciao
Kasimir    <<Less
About | Sitemap | Contact