Thanks. Using gated semantic predicates nicely simplifies the logic in each 
rule (while doubling the number of rules). 

It doesn't stop the parse though -- just the evaluation. 

Is there a clean way to determine the condition's final result and return it 
without having to complete the parse of the entire expression? 

Jane


On May 28, 2010, at 10:22 AM, Farr, John wrote:

> The message I posted on April 8 with the subject "Processing/traversing a 
> rule -- dealing with conditionals" may help you.
> 
> --John
> 
> 
> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Jane Eisenstein
> Sent: Friday, May 28, 2010 7:47 AM
> To: [email protected]
> Subject: [antlr-interest] short circuiting further evaluation
> 
> I'm working with a simple expression grammar:
> 
> condition:    conditional_expression  EOF
>       ;
> 
> conditional_expression
>       :       conditional_term
>               (  OR conditional_expression  )?
>       ;
> 
> conditional_term
>       :       conditional_factor
>               ( AND conditional_term  )?
>       ;
> 
> conditional_factor
>       :       conditional_primary
>       |       NOT conditional_primary
>       ;
> 
> conditional_primary
>       : ID
>       | LEFT_PAREN conditional_expression RIGHT_PAREN
>       ;
> 
> At runtime, ID tokens evaluate to either true or false. Once it is clear the 
> condition as a whole will evaluate to either true or false, I'd like to stop 
> the evaluation and return the value of the condition. So far, all I've 
> managed to do is short-circuit further ID evaluations once an upper level 
> outcome is know.
> 
> Is there a way to short circuit the entire parse? I'm not sure how to even 
> tell it would be time to do so.
> 
> Jane
> 
> 
> 
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 
> 
> [CONFIDENTIALITY AND PRIVACY NOTICE]
> 
> Information transmitted by this email is proprietary to Medtronic and is 
> intended for use only by the individual or entity to which it is addressed, 
> and may contain information that is private, privileged, confidential or 
> exempt from disclosure under applicable law. If you are not the intended 
> recipient or it appears that this mail has been forwarded to you without 
> proper authority, you are notified that any use or dissemination of this 
> information in any manner is strictly prohibited. In such cases, please 
> delete this mail from your records.
> 
> To view this notice in other languages you can either select the following 
> link or manually copy and paste the link into the address bar of a web 
> browser: http://emaildisclaimer.medtronic.com
> 


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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to