Your predicates are hoisted and so you do not have access to the local  
parameter. Search the list archives and  you will see how to use  
scopes for this. Just assign the value to a scope variable and use  
that in your predicate.

Jim

On Jul 12, 2009, at 7:55 AM, Carter Cheng <[email protected]>  
wrote:

>
> Actually this still isnt working. Is what I have legal ANTLR 3.1.3  
> code? I am getting the following error-
>
> lpcParser.c: In function ‘void synpred49_lpc_fragment(lpcParser_Ctx_ 
> struct*)’:
> lpcParser.c:13341: error: ‘e’ was not declared in this scope
>
>
> Generated by the following predicate block-
>
> // $ANTLR start synpred49_lpc
> static void synpred49_lpc_fragment(plpcParser ctx )
> {
>    exp::Exp* s;
>    #undef    RETURN_TYPE_s
>    #define    RETURN_TYPE_s exp::Exp*
>
>    s = NULL;
>
>    // /home/carter/sorrows-working5/sorrows/trunk/src/compiler/lpc.g: 
> 248:31: (s= selector[e] )
>    // /home/carter/sorrows-working5/sorrows/trunk/src/compiler/lpc.g: 
> 248:31: s= selector[e]
>    {
>        FOLLOWPUSH(FOLLOW_selector_in_synpred49_lpc1550);
>        s=selector(ctx, e);
>
>        FOLLOWPOP();
>        if  (HASEXCEPTION())
>        {
>            goto rulesynpred49_lpcEx;
>        }
>        if (HASFAILED())
>        {
>            return ;
>        }
>
>    }
>
> I am not sure how best to fix this. Any advice would be appreciated.  
> Thanks in advance,
>
> Carter.
>
>
> --- On Sat, 7/11/09, Carter Cheng <[email protected]> wrote:
>
>> From: Carter Cheng <[email protected]>
>> Subject: Re: [antlr-interest] Correct way to pass arguments with  
>> ANTLR
>> To: "Terence Parr" <[email protected]>
>> Cc: [email protected]
>> Date: Saturday, July 11, 2009, 11:44 AM
>>
>> Hi Terence,
>>
>> Thanks for the reply. I managed to work around the problem
>> by do this-
>>
>> unary returns [exp::Exp* e]
>>     : p=primary { $e = $p.e; }
>> (s=selector[e] { $e = $s.e;} )*
>>         ;
>>
>> I tried $p as well and it ANTLR doesnt seem to accept it.
>>
>> Carter.
>>
>> --- On Sat, 7/11/09, Terence Parr <[email protected]>
>> wrote:
>>
>>> From: Terence Parr <[email protected]>
>>> Subject: Re: [antlr-interest] Correct way to pass
>> arguments with ANTLR
>>> To: "Carter Cheng" <[email protected]>
>>> Cc: [email protected]
>>> Date: Saturday, July 11, 2009, 10:43 AM
>>> $p?
>>> Ter
>>> On Jul 11, 2009, at 9:36 AM, Carter Cheng wrote:
>>>
>>>>
>>>> I have been having some difficulties getting a
>> rule
>>> which looks somewhat as follows to work with ANTLR
>> 3.1.3 and
>>> the C runtime. I am not sure if I am passing the
>> parameter
>>> in question correctly. The rule is as follows-
>>>>
>>>> exp    : p=primary (selector[p])*
>>>>         ;
>>>>
>>>> The error I am getting is this:
>>>>
>>>> lpcParser.c: In function ‘void
>>> synpred23_lpc_fragment(lpcParser_Ctx_struct*)’:
>>>> lpcParser.c:10684: error: ‘p’ was not
>> declared in
>>> this scope
>>>>
>>>> Thanks in advance,
>>>>
>>>> Carter.
>>>>
>>>>
>>>>
>>>>
>>>> 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

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