开发者

Problem with parameter passing for stringtemplate

开发者 https://www.devze.com 2023-03-08 15:05 出处:网络
Given this rules : 开发者_如何学运维 defServ: \'service\' path bodyServ? SEP ->Serv(....); path: t+=ID (\'/\' t+=ID)* ->path(...);

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

精彩评论

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