Greetings!

On Thu, 2011-07-14 at 16:11 -0700, Roy Metzger wrote:
> Hi all,
> 
> Let's say I have something like this:
> 
> rule: ( 'stuff' e1=expression)?
> statement
> ('stuff' e2=expression)? ;
> 
> Now, I would like to know is there a way to dynamically flip rules on/off. 
> For example, when
> e1 is present e2 is not, and when e2 exists, e1 does not. 
> 

I probably do not actually understand your question. But perhaps you do
not really need predicates...

rule :
    ( 'stuff' expression statement ) 
  | ( statement 'stuff' expression )
  ;

> 
> Based on my research I found that predicates may be of help to me(of course, 
> aside from refactoring), but 
> 
> I'm really not sure how to use them, as I'm still very new to antlr.
> 
> 
> Could something like this work:
> rule
> @init{boolean b=false;}: 
> 
> ( 'stuff' e1=expression{b=true;})?   {b}?=>expression
> statement
> ( 'stuff' e2=expression{b=false;})?   {!b}?=>expression
> 
> I would really appreciate if some of more experienced users would give me 
> hints on this one.
> 
> Thanks for any help
> 
> 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 il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to