Problem with parameter passing for stringtemplate
Given this rules :
开发者_如何学运维 defServ: 'service' path bodyServ? SEP ->Serv(....);
path: t+=ID ('/' t+=ID)* ->path(...);
I ask, as you can pass the token list "t" to the templete "Serv"?
The simplest solution would be to put the production of pathServ in defServ, that is :
defServ: 'service' t+=ID ('/' t+=ID)* bodyServ? SEP ->Serv(a={$t}, ...);
a better solution?
Thanks you
Tanuzzo88 wrote:
I ask, as you can pass the token list "t" to the templete "Serv"?
Sure, try this:
defServ
: 'service' path bodyServ? SEP -> Serv(a={$path.ids})
;
path returns [List ids]
: t+=ID ('/' t+=ID)* {$ids = $t;}
;
精彩评论