[antlr-interest] FailedPredicateException leads to infinite loop - bug in the Lexer?

Scott Stanchfield scott at javadude.com
Wed Mar 31 11:32:19 PDT 2010


When I wrote ANTXR (my XML parser derivative of ANTLR 2.x) I had it
use SAX or XMLPull as the scanner rather than using an ANTLR scanner.
Much simpler for dealing with things like CDATA...
-- Scott

----------------------------------------
Scott Stanchfield
http://javadude.com



On Wed, Mar 31, 2010 at 2:27 PM, Ron Burk <ronburk at gmail.com> wrote:
>> My question is then what is
>> the appropriate way to construct the lexer such that it will recover
>> gracefully from that invalid input and NOT go into the infinite loop state
>> caused by the thrown exception?
>
> Personally, I try to keep "modes" in the lexer and
> out of the parser. I probably would have had the
> lexer looking past any initial '<' to distinguish the
> various types of things it presages (especially
> since the XML spec seems to make that relatively
> easy). So, for example, this:
>
>> <Program><</Program>
>
> would have returned a token stream like:
>
> TK_START_TAG
> TK_IDENT
> TK_GT
> TK_ILLEGAL
> TK_END_TAG
> TK_IDENT
> TK_GT
>
> I would keep modes like CDATA in the lexer.
> YMMV, many ways to skin a cat, etc.
>
> 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