Thanks Jim! I found this:
http://www.mail-archive.com/[email protected]/msg03823.html

-/renji


On Wed, Sep 22, 2010 at 11:05 PM, Jim Idle <[email protected]> wrote:
> Please look for "hoisted predicates generating local references" (or
> similar) on antlr.markmail.org and see that you need to use a scope variable
> for this.
>
> Cheers,
>
> Jim
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Renji Panicker
> Sent: Wednesday, September 22, 2010 5:46 AM
> To: [email protected]
> Subject: [antlr-interest] Error compiling C code generated by antlr3c.
>
> Hi everyone,
>
> I'm trying to compile the following grammar into C code:
>  //------------------------------------------------------
> grammar SimpleG;
>
> options
> {
>   language=C;
>   backtrack=true;
> }
>
> @header{
> #include <QtCore/QStringList>
> #undef emit
> }
>
>  external_function_call_expression
> �...@declarations{
>    QStringList tlist;
>    QStringList vlist;
>  }:
>  (
>        id0=ID
>  |       qualified_type[tlist]
>  |       qualified_id[vlist]
>  )
> ;
>
>  qualified_id[QStringList& list]
> �...@init {
>  }:
>     id0=ID
>     (
>         DOT
>         id1=ID
>     )*
>     ;
>
>  qualified_type [QStringList& list]:
>    id0=ID
>     (
>        SCOPE
>        id1=ID
>    )*
>    ;
>
> DOT : '.';
> SCOPE : '::';
> ID :   ('A'..'Z')+ ;
>  //------------------------------------------------------
>
>
> Its a bit contrived, because the external_function_call_expression rule
> could be left factored, but I am using it to demonstrate the bug.
> When this grammar is run through antlr3.2, the resultant SimpleGParser.c
> file  has the following function at line 781:
>
>  //------------------------------------------------------
> static void synpred2_SimpleG_fragment(pSimpleGParser ctx ) {
>   // SimpleG.g:22:10: ( qualified_type[tlist] )
>   // SimpleG.g:22:10: qualified_type[tlist]
>   {
>       FOLLOWPUSH(FOLLOW_qualified_type_in_synpred2_SimpleG70);
>       qualified_type(ctx, tlist);
>
>       FOLLOWPOP();
>       if  (HASEXCEPTION())
>       {
>           goto rulesynpred2_SimpleGEx;
>       }
>       if (HASFAILED())
>       {
>           return ;
>       }
>
>   }
>
> // This is where rules clean up and exit // goto rulesynpred2_SimpleGEx; /*
> Prevent compiler warnings */
> rulesynpred2_SimpleGEx: ;
>
> }
>  //------------------------------------------------------
>
> This does not compile because it refers to 'tlist', which is nowhere in the
> current scope. I hope I haven't missed out something obvious.
>
> Regards,
> -/renji
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to