help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bison/flex: Best practice to report an libc error to caller of yypar


From: Nicolai Stange
Subject: Re: bison/flex: Best practice to report an libc error to caller of yyparse
Date: Sat, 13 Jun 2009 17:55:50 +0200

Hi,
first of all: Thank you for your reply Hans.

> > i wonder how to report an libc error
> > (maybe ENOMEM, EIO) that has occured in either yylex or yyparse to the
> > caller of yyparse.
> 
> As for the first error, memory allocation error, your program is  
> likely unrecoverable, so just write an error message and exit.
There are three reasons why I don't want to do that.
1.) On EIO it could be possible for the program to continue, with some
other file for example.
2.) Sometimes later on the parser could be incorporated within a library
and to my knowledge a library should not print any text if it's not its
particular intention.
3.) I want to have some general error handling mechanism, independent of
the actual libc error code or what else has happened.

> For other errors, I had to write in .l:
>    #define YYERRCODE  256
What's the difference in using
%token YYERRCODE 
that doesn't rely on bison internals instead?

Thank you very much!

Nicolai






reply via email to

[Prev in Thread] Current Thread [Next in Thread]