[antlr-interest] short circuiting further evaluation

Farr, John john.farr at medtronic.com
Fri May 28 07:22:24 PDT 2010


The message I posted on April 8 with the subject "Processing/traversing a rule -- dealing with conditionals" may help you.

--John


-----Original Message-----
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Jane Eisenstein
Sent: Friday, May 28, 2010 7:47 AM
To: antlr-interest at antlr.org
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



More information about the antlr-interest mailing list