bug-bison
[Top][All Lists]
Advanced

[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: Slava Savitsky
Subject: Re: Cannot trace error location when %glr-parser and %pure-parser are used together.
Date: Sat, 15 Dec 2012 13:35:26 +0400

   Hi Akim,

   A

   I'm using 2.4 but have checked this with 2.7. Can you be more specific
   on how to trace the location without using the yyerror define and the
   "yylval" field?

   Hm, don't know what happened to the patch, but it's simple - add a
   yystackp parameter to "reportAmbiguity" function and the coressponding
   argument to its call.

   Thanks.

   A

   15.12.2012, 11:25, "Akim Demaille" <address@hidden>:

     Hi Slava,
     Le 14 dA(c)c. 2012 A  18:49, Slava Savitsky <address@hidden>
     a A(c)crit :

     A A A Here's a problem: for a grammar with both %glr-parser and
     %pure-parser
     A A A declarations a location-aware error reporting function cannot
     be used.
     A A A Usually to track the error position one defines "yyerror(msg)"
     to
     A A A "print_error(message, &yylval, yychar)", right? In the pure
     parser
     A A A "yylval" becomes "yystackp->yylval". The problem is,
     yyerror(YY_(msg))
     A A A is called from the "reportAmbiguity" function which does not
     take the
     A A A "yystackp" argument.

     Do not use the #define yyerror hack, it is brittle. A Just do not
     #define it, and let Bison do its job. A The test suite does check
     glr + pure + location, so it is expected to work properly. A See
     your documentation (you did not specify the version of Bison)
     about pure parsers.

     A A A A possible fix would be:
     A A A --- /usr/share/bison/glr.cssss 2012-12-14 20:07:40.516065313
     +0400
     A A A +++ /usr/share/bison/glr.csss 2012-12-14 19:49:35.600065872
     +0400
     A A A @@ -1788,8 +1788,7 @@
     A A A s#endif
     A A A s
     A A A s/*ARGSUSED*/ static YYRESULTTAG
     A A A -yyreportAmbiguity (yyGLRStack* yystackp,
     A A A -ssssssssssssssssss yySemanticOption* yyx0,
     A A A +yyreportAmbiguity (yySemanticOption* yyx0,
     A A A ssss sss ss yySemanticOption* yyx1]b4_pure_formals[)
     A A A s{
     A A A ss YYUSE (yyx0);
     A A A @@ -1900,7 +1899,7 @@
     A A A ssss sss {
     A A A ssss sss case 0:
     A A A ssss sssss yyresolveLocations (yys, 1,
     yystackp]b4_user_args[);
     A A A -sss sssss return yyreportAmbiguity (yystackp, yybest,
     A A A yyp]b4_pure_args[);
     A A A +sss sssss return yyreportAmbiguity (yybest,
     yyp]b4_pure_args[);
     A A A ssss sssss break;
     A A A ssss sss case 1:
     A A A ssss sssss yymerge = yytrue;
     A A A Slava Savitskiy.

     FWIW, I don't know what happened here, but the patch was damaged.

References

   1. mailto:address@hidden


reply via email to

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