[antlr-interest] validating semantic predicates
Harald Mueller
harald_m_mueller at gmx.de
Fri Nov 30 08:47:42 PST 2007
Hi -
You are already in a tree-parser, aren't you?
So some syntax parser has produced your trees (I don't assume you create the trees manually in some other way).
That syntax parser can then - in its tree-building rules (-> ...) - create trees which actually DO have terminating tokens - there is some documentation on such artificial tokens in the Wiki and also - I think - in the ANTLR book.
Hope this helps ...
Regards
Harald
-------- Original-Nachricht --------
> Datum: Fri, 30 Nov 2007 09:37:19 -0600
> Von: "Mark Volkmann" <r.mark.volkmann at gmail.com>
> An: antlr-interest at antlr.org
> Betreff: [antlr-interest] validating semantic predicates
> I'm trying to determine how to use validating semantic predicates in a
> rule that has no terminating token. Here's an example of the approach
> I've tried.
>
> statement
> : simpleStatement
> | ^('if' c=condition { $c.result }? simpleStatement)
> ;
> catch[FailedPredicateException fpe] {
> consumeUntil(input, STMT_TERMINATOR);
> input.consume();
> }
>
> The problem is that simpleStatements have no terminating token. They
> are a keyword optionally foIlowed by a number. I know whether to
> expect the number based on the keyword. There's no such thing as
> STMT_TERMINATOR in my grammar.
>
> I think in order to continue parsing when the condition evaluates to
> false, I have to consume all the tokens that make up the
> simpleStatement being skipped. How can I consume those tokens?
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
More information about the antlr-interest
mailing list