[antlr-interest] String Template question

Terence Parr parrt at cs.usfca.edu
Wed Jul 8 13:34:10 PDT 2009


Hi. try either <struct(typename="yourStructObject"> or  
<yourStructObject:struct()>
Ter
On Jul 8, 2009, at 1:16 PM, Behdad Forghani wrote:

> Hi,
>
> I have a  question regarding templates. I have spent a lot of time  
> to get the syntax right with no success. I cannot get the syntax of  
> calling a template within a template to work.
> I expected the syntax to be:
> <template(<arg>)>
> I.e.,
> if the first template is:
> template1(arg1) ::= "... <arg1> ..."
>
> Then for the second template to call the first template, the syntax  
> would be:
> template2(arg) :: <<
> ...
> <template1(<arg>)>
> ...
>>>
>
> This does not seem to work.
>
>
> I want to declare a C structure. The typename may not be present.  
> I.e.,
> sometimes it is struct {} x; and sometimes it is struct y {} x;. So,  
> in
> the string template I have:
>
> struct(typename) ::="struct <typename>"
>
> Now I want to define a template to call struct.  I expected the
> following to work, but it doesn't:
>
> headerFileStruct(typename, fieldname) ::= <<
>  <struct(<typename>)> {
>   int length;
> } fieldname;
>>>
>
> I have tried <struct(typename)>, <struct<$typename$>> and any  
> possiblity
> that I could think of with now luck.
>
> Another question, jsut to doublecheck, is there a way to trace and  
> debug
> stringtemplates? Not that this would have helped with not knowing the
> syntax.
>
> Thanks for your help and providing Antlr.
>
>
> Behdad
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list