help-bison
[Top][All Lists]
Advanced

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

Re: yyerror() with %pure_parser


From: akim
Subject: Re: yyerror() with %pure_parser
Date: Fri, 9 Nov 2001 23:21:11 +0100
User-agent: Mutt/1.3.23i

On Fri, Nov 09, 2001 at 01:46:31PM -0500, Matt Carter wrote:
> Hi,
> 
> I'm using %pure_parser to generate a thread-safe parser.
> This lets me pass an extra parameter to yyparse() to maintain state (rather
> than using global variables).
> The problem is that yyerror() does not have access to this state parameter
> as all the actions do.  yyerror() only gets passed a char * as with a normal
> non-reentrant parser.  I need the state information to generate a useful
> error message in yyerror().
> Does anyone disagree that this is a shortcoming in bison?  Can anyone
> suggest a work-around?

I'm not sure Bison should adjust, but at least the documentation should
suggest the following, agreed.

Personnally, I have a pure parser, and it's based on:

#define YYERROR_VERBOSE 1
#define YYPRINT(file, type, value)   yyprint (yylloc, type, value)
#define yyerror(Msg)   parse_error (yylloc, Msg)
void parse_error (const Location &loc, const char *msg);

You can add additional vars to yyerror via a cpp definition.



reply via email to

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