[antlr-interest] Accessing a return value ...
Ric Klaren
klaren at cs.utwente.nl
Thu May 27 07:38:16 PDT 2004
On Thu, May 27, 2004 at 03:33:50PM +0100, Anthony Youngman wrote:
> I've looked in the manual, and it tells me how to return a value, but
> not how to get at that value from the calling rule (at least as far as I
> can see ... :-)
>
programst { int val; } :
#(PROGRAM (IDENT)? statement_list END)
| #(SUBROUTINE (IDENT)? (val=formalargs)? statement_list END)
| #(FUNCTION (IDENT)? (val=formalargs)? statement_list END)
;
> deffunst
> : #(DEFFUN IDENT (formalargs)? (CALLING (IDENT |
> STRING_LITERAL))? )
> ;
>
> formalargs returns [int argcount]
> : #(FORMALARGS (IDENT {argcount++;})+ )
In C++ you can do:
formalargs returns [int argcount = 0]
: #(FORMALARGS (IDENT {argcount++;})+ )
;
Not 100% sure if java works like that too.
But this might work as well:
formalargs returns [int argcount] { argcount = 0; } :
#(FORMALARGS (IDENT {argcount++;})+ )
;
Cheers,
Ric
--
-----+++++*****************************************************+++++++++-------
---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893755 ----
-----+++++*****************************************************+++++++++-------
"I think we better split up."
"Good idea. We can do more damage that way."
--- Ghostbusters
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