Your message dated Sun, 6 Jun 2010 04:00:52 -0400
with message-id <[email protected]>
has caused the   report #584738,
regarding byacc: Fix compatibility with bison's pure-parser option
to be marked as having been forwarded to the upstream software
author(s) [email protected]

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
584738: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=584738
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Hello,

I thought it might be good to send you patches that I submitted to the Debian 
bug tracking system as well. In this way, these changes I'm proposing will 
benefit everyone using byacc, and also help with having a similar 
implementation of byacc accross different platforms/distros.

The first patch fixes the output order of the generated parse code file. This 
will allow for the use of YYPARSE_PARAM, by having the output that checks for 
YYPARSE_PARAM to be defined come after the C code block in the definitions 
section of a yacc file.

The second patch implements support for YYLEX_PARAM, similar to bison. This is 
useful for support for building reentrant lexers with flex.

The third patch fixes a compatibility issue with bison's pure-parser option. 
Bison defines yylex as sending at least one paramater, &yylval, as the first 
parameter and doesn't seem to have an easy way to remove that parameter. This 
on the other hand is rather convenient to support saving to yylval from flex 
when building reentrant lexers and parsers.

If you wish to reply, please also preserve the addresses in the CC field when 
replying so that any response from you is also saved in the relevant bug 
reports in the Debian bug tracking system.

-- 
Regards,
Andres Mejia
Fixes output order so that YYPARSE_PARAM can be overridden.

--- byacc-20100216.orig/output.c
+++ byacc-20100216/output.c
@@ -1223,8 +1223,8 @@ output(void)
     free_shifts();
     free_reductions();
     output_prefix(output_file);
-    write_section(xdecls);
     output_stored_text();
+    write_section(xdecls);
     output_defines();
     output_rule_data();
     output_yydefred();
Be able to set options via YYLEX_PARAM, useful when using reentrant flex.

--- byacc-20100216.orig/skeleton.c
+++ byacc-20100216/skeleton.c
@@ -55,6 +55,17 @@ const char *xdecls[] =
     "",
     "extern int YYPARSE_DECL();",
     "",
+    "/* compatibility with flex */",
+    "#ifdef YYLEX_PARAM",
+    "#define YYLEX_DECL() yylex(void *YYLEX_PARAM)",
+    "#define YYLEX yylex(YYLEX_PARAM)",
+    "#else",
+    "#define YYLEX_DECL() yylex(void)",
+    "#define YYLEX yylex()",
+    "#endif",
+    "",
+    "extern int YYLEX_DECL();",
+    "",
     0
 };
 
@@ -232,7 +243,7 @@ const char *body_2[] =
     "    if ((yyn = yydefred[yystate]) != 0) goto yyreduce;",
     "    if (yychar < 0)",
     "    {",
-    "        if ((yychar = yylex()) < 0) yychar = 0;",
+    "        if ((yychar = YYLEX) < 0) yychar = 0;",
     "#if YYDEBUG",
     "        if (yydebug)",
     "        {",
@@ -368,7 +379,7 @@ const char *trailer[] =
     "        *++yystack.l_mark = yyval;",
     "        if (yychar < 0)",
     "        {",
-    "            if ((yychar = yylex()) < 0) yychar = 0;",
+    "            if ((yychar = YYLEX) < 0) yychar = 0;",
     "#if YYDEBUG",
     "            if (yydebug)",
     "            {",
Patch for better support for bison compatibility for pure-parser option.

--- byacc-20100216.orig/skeleton.c
+++ byacc-20100216/skeleton.c
@@ -55,10 +55,18 @@ const char *xdecls[] =
     "",
     "extern int YYPARSE_DECL();",
     "",
-    "/* compatibility with flex */",
-    "#ifdef YYLEX_PARAM",
+    "/* compatibility with bison pure-parser and flex reentrant options */",
+    "#if defined YYPURE && defined YYLEX_PARAM",
+    "#define YYLEX_DECL() yylex(YYSTYPE *yylval, void *YYLEX_PARAM)",
+    "#define YYLEX yylex(&yylval, YYLEX_PARAM)",
+    "/* compatibility with flex reentrant option */",
+    "#elif defined YYLEX_PARAM",
     "#define YYLEX_DECL() yylex(void *YYLEX_PARAM)",
     "#define YYLEX yylex(YYLEX_PARAM)",
+    "/* compatilibity with bison pure-parser option */",
+    "#elif defined YYPURE",
+    "#define YYLEX_DECL() yylex(YYSTYPE *yylval)",
+    "#define YYLEX yylex(&yylval)",
     "#else",
     "#define YYLEX_DECL() yylex(void)",
     "#define YYLEX yylex()",
--- byacc-20100216.orig/output.c
+++ byacc-20100216/output.c
@@ -1223,6 +1223,7 @@ output(void)
     free_shifts();
     free_reductions();
     output_prefix(output_file);
+    output_pure_parser();
     output_stored_text();
     write_section(xdecls);
     output_defines();
@@ -1239,7 +1240,6 @@ output(void)
 	write_section(tables);
     }
     write_section(hdr_defs);
-    output_pure_parser();
     if (!pure_parser)
     {
 	write_section(hdr_vars);

--- End Message ---

Reply via email to