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: Hans Aberg
Subject: Re: bison/flex: Best practice to report an libc error to caller of yyparse
Date: Sat, 13 Jun 2009 15:37:05 +0200

On 13 Jun 2009, at 13:40, Nicolai Stange wrote:

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.

For other errors, I had to write in .l:
  #define YYERRCODE     256
and then
  { std::cerr << "Error: ...\n"; return YYERRCODE; }

Unfortunately, this relies on Bison innards. It C++ .hh header contains
  yyerrcode_ = 256
so this header might be included and used instead.

It would be better if this header contained an official error token. (So I cc some developers.)

  Hans






reply via email to

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