[antlr-interest] Accessing a return value ...

Anthony Youngman Anthony.Youngman at ECA-International.com
Thu May 27 07:55:57 PDT 2004


Thanks. Sorry - I missed it - I didn't notice you'd rewritten my code
since it looked so similar to my code :-)

Cheers,
Wol 

-----Original Message-----
From: Ric Klaren [mailto:klaren at cs.utwente.nl] 
Sent: 27 May 2004 15:52
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] Accessing a return value ...

On Thu, May 27, 2004 at 03:43:24PM +0100, Anthony Youngman wrote:
> But how do I access that value in the programst rule ... that's where
I
> want to use it and I haven't got a clue how to get at it ...

programst { int val = 0; } :
  #(PROGRAM (IDENT)? statement_list END) 
| #(SUBROUTINE (IDENT)? (val=formalargs)? statement_list END) 
| #(FUNCTION (IDENT)? (val=formalargs)? statement_list END) 
{
	// do stuff with val...
}
;

Notice the 'val=formalargs' in the above... Just plain old assignment,
only
caveat is getting the order right if you also use a label then it
becomes:

  val=lbl:formal_args

Cheers,

Ric
--
-----+++++*****************************************************+++++++++
-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893755  ----
-----+++++*****************************************************+++++++++
-------
     Human beings, who are almost unique in having the ability to learn
   from the experience of others, are also remarkable for their apparent
         disinclination to do so. --- Douglas Adams, Last Chance to See


 
Yahoo! Groups Links



 





****************************************************************************

This transmission is intended for the named recipient only. It may contain private and confidential information. If this has come to you in error you must not act on anything disclosed in it, nor must you copy it, modify it, disseminate it in any way, or show it to anyone. Please e-mail the sender to inform us of the transmission error or telephone ECA International immediately and delete the e-mail from your information system.

Telephone numbers for ECA International offices are: Sydney +61 (0)2 8272 5300, Hong Kong + 852 2121 2388, London +44 (0)20 7351 5000 and New York +1 212 582 2333.

****************************************************************************



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list