kafka
kafka

Reputation: 949

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

Upvotes: 0

Views: 212

Answers (1)

Bart Kiers
Bart Kiers

Reputation: 170308

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

Upvotes: 1

Related Questions