[antlr-interest] Repeating output constructs with stringtemplates

Hardy, Stephen Stephen.Hardy at digi.com
Thu Aug 30 14:00:46 PDT 2007


Yup, works like a charm!  Thanks!  (Still haven't quite got my head
around ST stuff, as you can see).

Regards,
SJH

> -----Original Message-----
> 
> Try somethign like
> 
> decl(type, names) ::= "<names:{ n | <type> <n>;}>"
> 
> sweeet, eh? :)
> 
> Ter
> On Aug 29, 2007, at 5:27 PM, Hardy, Stephen wrote:
> 
> > In C one can create declarations like
> >
> >   int a, b, c;
> >
> > which, in a C parser, may result in an AST something like
> >
> >   ^(DECL type declarator+)
> >
> > It is easy to get string templates to output the original 
> code, but I
> > would like to transform the original code to something like
> >
> >   int a;
> >   int b;
> >   int c;
> >
> > that is, repeating the type for each declarator.
> >
> > Is this possible using ST, or do I need to manipulate the AST first?
> >
> > Regards,
> > SJH
> 
> 


More information about the antlr-interest mailing list