[antlr-interest] Correct way to pass arguments with ANTLR

Carter Cheng carter_cheng at yahoo.com
Sat Jul 11 11:44:47 PDT 2009


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 <parrt at cs.usfca.edu> wrote:

> From: Terence Parr <parrt at cs.usfca.edu>
> Subject: Re: [antlr-interest] Correct way to pass arguments with ANTLR
> To: "Carter Cheng" <carter_cheng at yahoo.com>
> Cc: antlr-interest at antlr.org
> 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
> 
> 


      


More information about the antlr-interest mailing list