[antlr-interest] C target: overriding parser and lexer error handlers

Jim Idle jimi at temporal-wave.com
Wed Jul 20 19:38:37 PDT 2011


Yes - they are documented in the C API documentation on the front page.
However, you should engineer your lexer so that it does not create errors,
which is usually possible with some work.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Vlad Roubtsov
> Sent: Wednesday, July 20, 2011 5:25 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] C target: overriding parser and lexer error
> handlers
>
> Greetings,
>
> I am new to ANTLR but have extensive experience with JavaCC. With some
> difficulty (section '@apifuncs' does not appear to be documented but
> was mentioned in this list) I can intercept parser errors with my own
> implementation of displayRecognitionError():
>
> @parser::apifuncs
> {
>     RECOGNIZER->displayRecognitionError = <my parser error function>; }
>
> However, lexer errors continued to cause messages to be printed to
> stderr.
> After some more poking around the source code the following seemed to
> work:
>
> @lexer::apifuncs
> {
>     LEXER->rec->displayRecognitionError = <my lexer error function>; }
>
> My question: are these @(lexer|parser)::apifuncs section declarations
> the supported way to do this? (@members does not work).
>
> Thank you,
> Vlad
>
> 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