[antlr-interest] New user

mzukowski at yci.com mzukowski at yci.com
Thu Aug 29 11:06:46 PDT 2002


Also note that semantic precidates come in two flavors: disambiguating and
validating.  A disambiguating semantic predicate is one that is used to
choose between alternatives, if it fails then the next alternative is tried.
Antlr assumes that if the sem pred is within an alternative block that it is
disambiguating.  A validating sem pred is not part of an alternative block,
so if it fails an exception is thrown.

Monty

> -----Original Message-----
> From: Greg Lindholm [mailto:glindholm at yahoo.com]
> Sent: Thursday, August 29, 2002 9:57 AM
> To: antlr-interest at yahoogroups.com
> Subject: RE: [antlr-interest] New user
> 
> 
> A couple other important points about predicates:
> 
> - Semantic predicates are written in the host language (Java, C++,
> etc.) and provide a break-out hook at that point in the parsing.
> You have full access to the internals of the parser plus access
> to symbol tables and any external resources you've setup.
> 
> - Syntactic predicates are written in and use the "syntax" grammer 
> of the parser to provide unlimited look ahead.
> 
> - Syntactic predicates are used to select between one of several 
> alternatives (usually with a common prefix)
> 
> - Syntactic predicates are "ordered" they are checked in the order 
> that they are written in.  I believe this is the only way to do
> an ordered series of tests.
> 
> --- mzukowski at yci.com wrote:
> > 
> > 5. When do I use syntatic predicate and semantic predicate? Why does
> > this
> > semantic make sense: ( set_clause ) => set_clause ??!! 
> > 
> > It doesn't make sense like that because you're not using it in
> > context.
> > What it is saying is choose this alternative if the syntactic
> > predicate
> > matches.  Sometimes you have things that need "infinite
> > lookahead"--you
> > can't always decide in "k" tokens what is happening.  When you have
> > that
> > situation you use a syntactic predicate.  Semantic 
> predicates are for
> > things
> > like checking symbol tables--the actual semantics of the program.
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Finance - Get real-time stock quotes
> http://finance.yahoo.com
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
http://docs.yahoo.com/info/terms/ 


 

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



More information about the antlr-interest mailing list