[antlr-interest] Repeating output constructs with string templates
Terence Parr
parrt at cs.usfca.edu
Wed Aug 29 17:36:46 PDT 2007
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