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

Udo Weik WeikEngOff at aol.com
Thu Nov 17 11:30:37 PST 2011


I would be really happy to get an answer...


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
     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?
     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


More information about the stringtemplate-interest mailing list