[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Cannot trace error location when %glr-parser and %pure-parser are us
From: |
Akim Demaille |
Subject: |
Re: Cannot trace error location when %glr-parser and %pure-parser are used together. |
Date: |
Sat, 15 Dec 2012 08:25:19 +0100 |
Hi Slava,
Le 14 déc. 2012 à 18:49, Slava Savitsky <address@hidden> a écrit :
> Here's a problem: for a grammar with both %glr-parser and %pure-parser
> declarations a location-aware error reporting function cannot be used.
>
> Usually to track the error position one defines "yyerror(msg)" to
> "print_error(message, &yylval, yychar)", right? In the pure parser
> "yylval" becomes "yystackp->yylval". The problem is, yyerror(YY_(msg))
> is called from the "reportAmbiguity" function which does not take the
> "yystackp" argument.
Do not use the #define yyerror hack, it is brittle. Just do not
#define it, and let Bison do its job. The test suite does check
glr + pure + location, so it is expected to work properly. See
your documentation (you did not specify the version of Bison)
about pure parsers.
>
> A possible fix would be:
>
> --- /usr/share/bison/glr.cssss 2012-12-14 20:07:40.516065313 +0400
> +++ /usr/share/bison/glr.csss 2012-12-14 19:49:35.600065872 +0400
> @@ -1788,8 +1788,7 @@
> s#endif
> s
> s/*ARGSUSED*/ static YYRESULTTAG
> -yyreportAmbiguity (yyGLRStack* yystackp,
> -ssssssssssssssssss yySemanticOption* yyx0,
> +yyreportAmbiguity (yySemanticOption* yyx0,
> ssss sss ss yySemanticOption* yyx1]b4_pure_formals[)
> s{
> ss YYUSE (yyx0);
> @@ -1900,7 +1899,7 @@
> ssss sss {
> ssss sss case 0:
> ssss sssss yyresolveLocations (yys, 1, yystackp]b4_user_args[);
> -sss sssss return yyreportAmbiguity (yystackp, yybest,
> yyp]b4_pure_args[);
> +sss sssss return yyreportAmbiguity (yybest, yyp]b4_pure_args[);
> ssss sssss break;
> ssss sss case 1:
> ssss sssss yymerge = yytrue;
>
> Slava Savitskiy.
FWIW, I don't know what happened here, but the patch was damaged.