[antlr-interest] Re: Semantic Predicates and SemanticExceptions

johnj1984 johnj1984 at yahoo.com
Mon Aug 2 12:27:01 PDT 2004


<<
ruleClassDeclaration
  : ((ruleProcedureDeclarationPart)=>ruleProcedureDeclarationPart) *
  ;
>>

   This works exactly like I need it to... Thanks Monty for all the 
support!

   -jj


--- In antlr-interest at yahoogroups.com, Monty Zukowski <monty at c...> 
wrote:
> By the way you need to keep your semantic predicates in place so 
the 
> exception is thrown that the syntactic predicate catches.
> 
> Monty
> 
> On Aug 2, 2004, at 10:04 AM, Monty Zukowski wrote:
> 
> > On Aug 2, 2004, at 9:38 AM, johnj1984 wrote:
> >
> >>    Essentially I need to tell the parser that when my semantic 
check
> >> fails, it should backtrack from the failed evaluation only,
> >> successfully exit the rules its matched so far, and reparse the
> >> failed text from somewhere higher in its rule hierarchy.
> >
> > To achieve backtracking you need to use syntactic predicates, up 
at the
> > point where you want to backtrack to.  Something like this:
> >
> >     ruleClassDeclaration
> >     	: ((ruleProcedureDeclarationPart)
=>ruleProcedureDeclarationPart) *
> >     	;
> >
> > Ignore the warning about a superfluous syntactic predicate, it's 
wrong.
> >
> > Monty
> >
> > ANTLR & Java Consultant -- http://www.codetransform.com
> > ANSI C/GCC transformation toolkit --
> > http://www.codetransform.com/gcc.html
> > Embrace the Decay -- 
http://www.codetransform.com/EmbraceDecay.html
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list