[stringtemplate-interest] ANTLR code generation target/Stringtemplate: modifying the C-Runtime I

Terence Parr parrt at cs.usfca.edu
Thu Nov 10 16:34:46 PST 2011


On Nov 10, 2011, at 12:47 AM, Udo Weik wrote:

> Hello,
> 
> I asked my questions in antlr-interest and Jim wrote that
> these are more Stringtemplate-related. So here again.
> 
> I startet to modify the C-Runtime and have a first bunch of
> questions. Be sure, more will follow - "Eeek, what a pain!"...
> 
> 1. <token> in <action>
>    I need the token of an rule in the <action>-section
>    /** How to execute an action (when not backtracking) */
>    execAction(action) ::= <<
>    <if(backtracking)>
>    <if(actions.(actionScope).synpredgate)>
>    if ( <actions.(actionScope).synpredgate> )
>    ...
>    <ruleDescriptor.name> and <ruleName> are replaced (what is the

Hi.  I don't see    <ruleDescriptor.name> and <ruleName>

>    difference?) but <token> not. Why?
> 
> 2. Blank lines
>    The C-Parser-file of my grammar consits of ~150.000 lines, ~20.000
>    lines are blank. As mentioned in another email from me, I can't debug
>    more than 65535 lines. The only solution is to reorder the (parser) rules.
>    But apart from that severe problem, I looked for a solution to get
>    a much more compact code. Some examples, section...
>    1. // Forward declare the locally static matching functions we have generated.
>       //
>       static
>         XYZParser_RULE_return
>           RULE (pXYZParser ctx);
> 
>       3 lines - the result of
>       <rules:{r | static <headerReturnType(ruleDescriptor=r.ruleDescriptor)>  <r.ruleDescriptor.name>    (p<name> ctx<if(r.ruleDescriptor.parameterScope)>, <endif>
>       <r.ruleDescriptor.parameterScope:parameterScope()>);}; separator="\n">
>       How can I avoid 2 lines?

 the easiest thing to do is to build an StringTemplateOutputWriter that strips blank lines :)
Ter
>    2. /* ==============================================
>        * Parsing rules
>        */
>       ...
>       static XYZParser_RULE_return
>       port_RULE(pXYZParser ctx)
> 
>       2 lines - the result of
>       <rules; separator="\n\n">
>       How can I avoid 1 line?
> 
> 
> Many thanks and greetings
> Udo
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest



More information about the stringtemplate-interest mailing list