[antlr-interest] short circuiting further evaluation
Jane Eisenstein
janee at softweave.com
Fri May 28 05:50:00 PDT 2010
I also don't know how to short circuit further parsing of sub trees when appropriate. I suspect these problems are related. :-)
Jane
On May 28, 2010, at 8:47 AM, Jane Eisenstein wrote:
> 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
More information about the antlr-interest
mailing list