Re: Parser error handling

"Piotr Wyderski" <>
30 Aug 2003 00:21:02 -0400

          From comp.compilers

Related articles
Parser error handling (Piotr Wyderski) (2003-08-20)
Re: Parser error handling (2003-08-23)
Re: Parser error handling (Piotr Wyderski) (2003-08-30)
Re: Parser error handling (2003-09-04)
| List of all articles for this month |

From: "Piotr Wyderski" <>
Newsgroups: comp.compilers
Date: 30 Aug 2003 00:21:02 -0400
Organization: tp.internet -
References: 03-08-059 03-08-074
Keywords: parse, errors
Posted-Date: 30 Aug 2003 00:21:02 EDT

Hans Aberg wrote:

> Depends on what you mean by "stop parsing correctly".

The parser should free all allocated blocks to prevent memory leaks
and then return an error value to the caller. Currently I'm experimanting
with ANTLR, because its error handling subsystem is much better
than that of Bison.

> You could for example let the lexer write out an error message, and
> then return a token to the parser which is not used anywhere, which
> will cause it to generate an error.

Yes, this is an idea...

> I assume you are using C as output language.

No, also C++.

> I use C++, where I write user classes which the C++ language can clean up.

But how? It's easy when the root class implements a kind of linked
list and tracks all the allocated fragments, but this increases memory

> For C, Akim Demaille has implemented a %destructor feature. See for
> example the thread "Destructor trouble" in May in the Help-Bison list.

Thanks, I'll check that.

        Best regards
        Piotr Wyderski

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.