bug-bison
[Top][All Lists]
Advanced

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

yyerror()


From: Miko Nahum
Subject: yyerror()
Date: Sun, 24 Mar 2002 14:30:30 +0200

Hi,

Handling syntax error by bison requires adding of rules
that uses the 'error' keyword. For all other cases not covered
by error rules, bison calls the function yyerror(), right ?!

yyoerror() proto is: "int yyerror(char*);"

So the problem is that yyerror() do not have a context parameter
as the yyparse() does. To remind you that last one declared this way:

int yyparse(YYPARSE_PARAM_ARG)
     YYPARSE_PARAM_DECL
{...}

This is usefull when implementing a pure classed based parser (C++),
i.e., when cannot use global variables to share the context.

Generally, I think yyerror() proto should have BOTH the "char *message" 
and YYPARSE_PARAM_ARG. E.g.: 

void yyerror(char *message, YYPARSE_PARAM_ARG)

(of course this not 100% safe as the comma should be avoided if the
YYPARSE_PARAM_ARG is empty, etc.)

I am writing my own pure parser and face this problem. Is this going to be
the same with the new future C++ bison ?


Regards,
Miko

--
address@hidden




reply via email to

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