开发者

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;}
  ;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜