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

Jim Idle jimi at temporal-wave.com
Wed Nov 9 13:55:35 PST 2011


These are all questions about stringtemplate, so you should post them
there.

Note that <\n?> forces a newline.
You created new templates, but did you create a new java class to process
it? Did you change the group names of the templates and so on?

Sorry, but to create a target, you basically just have to work it out as
you go along by trial and error, but you might find it easier to change
the embedded code than to remove blank lines. Also don't change more than
a single line of template at once.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Udo Weik
> Sent: Wednesday, November 09, 2011 1:40 PM
> To: Antlr-Interest Antlr.Org
> Subject: [antlr-interest] 2. Attempt: ANTLR code generation target:
> modifying the C-Runtime I
>
> I would be really happy to get an answer...
>
>
> Hello,
>
> yep, I startet to modify the C-Runtime and have a first bunch of
> questions. Be sure, more will follow - "Eeek, what a pain!"...
>
> 1. Header-file not created
>     I just added a new directory \Cmod to \org\antlr\codegen\templates
>     and copied the entire content of \C in that directory. Then I
>     renamed C.stg in Cmod.stg. The *Lexer.c/*Parser.c-files are
> created,
>     but no header (*.h)-files. Why?
>
> 2. <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?
>
> 3. 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?
>
> 4. I added a comment to section
>     ruleReturnValue() ::= <%
>     //! UW Test ruleReturnValue
>
>     <if(!ruleDescriptor.isSynPred)>
>     <if(ruleDescriptor.hasReturnValue)>
>     <if(ruleDescriptor.hasSingleReturnValue)>
>     <ruleDescriptor.singleValueReturnName>
>     <else>
>     retval
>     <endif>
>     <endif>
>     <endif>
>     %>
>
>     The result looks like
>     return //! UW Test ruleReturnValueretval;
>     1. The problem of the missing blank between "ruleReturnValue" and
> "retval"
>        can be solved by adding a blank after the comment "//! UW Test
> ruleReturnValue ".
>     2. But how can I add an additional line before the "retval"? I
> tried
>        <else>
>
>        retval
>        <endif>
>        without success.
>
>
> Many thanks and greetings
> Udo
>
> 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