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 <[email protected]> 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 > List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
