[antlr-interest] Re: nested return statements

genericised trigonometric at softhome.net
Sun Aug 18 12:09:35 PDT 2002


--- In antlr-interest at y..., Ric Klaren <klaren at c...> wrote:
> On Thu, Aug 15, 2002 at 03:26:55PM -0000, genericised wrote:
> > Here is an attempt to clarify my last post:
> > 
> > How can I make a parser rule so that I can use nested return 
> > statements like this:
> > 
> > blah returns[String s]
> >   : String p = (blah2)+
> >   { s=p; }
> >   ;
> > 
> > blah2 returns[String s]
> >   : i:(INT)
> >   { s=i.getText(); }
> >   ;
> 
> declare variables that should live the whole rule in the init 
action. Then
> just append to it.
> 
> blah returns [String s = new String()] { String t; }
> :
> 	( t=blah2 { s += t; } )+
> ;	
> 
> blah2 returns [String s = new String()]
> :
> 	i:INT { s += i.getText(); }
> ;	
> 
> Advance apologies for any java mistakes it's not my native 
language ;)
> 
> We do have documentation and examples where this kindoff stuff is
> explained. And yes the documentation is fragmented/non-
ideal/scattered etc.
> 
> HTH
> 
> Ric
> -- 
> -----
+++++*****************************************************+++++++++---
----
>     ---- Ric Klaren ----- klaren at c... ----- +31 53 4893722  ----
> -----
+++++*****************************************************+++++++++---
----
>   Chaos always defeats order because it is better organized.
>   --- Terry Pratchet


 

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



More information about the antlr-interest mailing list