help-bison
[Top][All Lists]
Advanced

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

Re: pure bison yyerror()


From: Akim Demaille
Subject: Re: pure bison yyerror()
Date: 14 Dec 2000 15:12:05 +0100
User-agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands)

>>>>> "mike" == mike burrell <address@hidden> writes:

mike> excuse me if this is the wrong address to send to.  i'd like to
mike> have Bison's error reporting mechanics (i.e. yyerror()) be more
mike> re-entrant friendly and thus pass a re-entrant argument to it
mike> (as is already done with yyparse() via YYPARSE_PARAM and yylex()
mike> via YYLEX_PARAM).  i went through the source code and found that
mike> there are only a half-dozen places that changes would have to be
mike> made (in bison.s1, basically adding some #ifdefs).  i figure
mike> that all i'd have to do now is update the documentation some.

mike> so i'm wondering whether this (YYERROR_PARAM) would be of
mike> interest.  i.e. if i finish the changes and update the
mike> documentation, etc. and send someone a patch, will this get
mike> folded in to the next release?

Actually it just occurred to me that all you need is a #define
yyerror.  I use this in my parser, with success.

/* Have descent parse error reports. */
#define YYDEBUG 1
#define YYERROR_VERBOSE 1
#define YYPRINT(file, type, value)   yyprint (yylloc, type, value)
#define yyerror(Msg)   parse_error (yylloc, Msg)
static void parse_error (const Location &loc, const char *msg);

and

static void
parse_error (const Location &loc, const char *msg)
{
  //<<
  cerr << loc << ": " << msg <<endl;
  errors++;
  //>>
}


IMHO, just documenting the redefinition of yyerror is all we need.
I'm not ready to introduce a new macro.  This macro should be named
YYERROR, as in the relationship between yyprint and YYPRINT, but
YYERROR is already used.  Any other name seems kludgy.  So `yyerror'
is just fine.

Given that yyerror is called from yyparse only, even with pure parsers
you can access all the variables you need.



reply via email to

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