Evaluating *disambiguating* syntactic predicates at the *end* of a parser rule.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ansgar_Konermann
Posted On:   Tuesday, May 27, 2003 08:27 AM

How can I make ANTLR to support the evaluation of real "disambiguating" predicates at the *end* of a parser rule? Usually, there are two variants of semantic predicates: disambiguating and validating. Disambiguating predicates are evaluated before the parser rule is entered. If you need to access information from subrules (say: AST parts) to determine whether a rule matches or not, you have to delay evaluation of disambiguating rules until the end of the parser rule (after all subrules successfully matched). ANTLR supports only *validating* semantic predicates at the end of a parser rule, throwing a SemanticException if the predicate fails. What I want to do    More>>

How can I make ANTLR to support the evaluation of real "disambiguating"
predicates at the *end* of a parser rule?


Usually, there are two variants of semantic predicates: disambiguating and
validating. Disambiguating predicates are evaluated before the parser rule
is entered. If you need to access information from subrules (say: AST parts) to
determine whether a rule matches or not, you have to delay evaluation of
disambiguating rules until the end of the parser rule (after all subrules successfully
matched).


ANTLR supports only *validating* semantic predicates at the end of a parser rule,
throwing a SemanticException if the predicate fails. What I want to do is: if the
predicate fails, just continue with backtracking (select next viable alternative)
within the enclosing rule.


How can I make ANTLR support this behaviour? Are there any hooks? Would
it be possible with custom exception handling? Any help greatly appreciated.

   <<Less
About | Sitemap | Contact