bison-patches
[Top][All Lists]
Advanced

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

Re: push parser


From: Joel E. Denny
Subject: Re: push parser
Date: Tue, 19 Dec 2006 20:12:37 -0500 (EST)

On Tue, 19 Dec 2006, Paul Eggert wrote:

> "Joel E. Denny" <address@hidden> writes:
> 
> > Actually that's my plan.  Somehow the above ugliness just made this diff a 
> > little easier to read.  If I promise that a future patch will clean this 
> > up, is it ok to commit this one?
> 
> Sure!  Thanks.

Thanks, I committed it.  I'll take care of that initialization cleanup 
next.

In the meantime, here's another uncommitted patch that's fairly small.  
Paul, could you look over the M4?  Specifically, I'm adding redundant 
quoting that doesn't seem to be the norm in Bison's uses of 
b4_c_function_def and b4_c_function_decl.  However, that norm seems 
inconsistent with what I was taught by the folks at Autoconf.  Especially 
in the header where the M4 gets hairy because b4_prefix is needed, I keep 
stumbling over this inconsistency.  In summary, even though it's 
redundant, the consistency of this extra quoting is easier on my head.  
Is it ok with you?

Index: ChangeLog
===================================================================
RCS file: /sources/bison/bison/ChangeLog,v
retrieving revision 1.1632
diff -p -u -r1.1632 ChangeLog
--- ChangeLog   20 Dec 2006 00:59:18 -0000      1.1632
+++ ChangeLog   20 Dec 2006 01:03:24 -0000
@@ -1,5 +1,14 @@
 2006-12-19  Joel E. Denny  <address@hidden>
 
+       * data/push.c: Add CPP guards around push parser declarations in both
+       the header and the code file.
+       In the code file, move the push parser declarations to the same place
+       they appear in the header file.
+       Clean up the M4 some, especially the inconsistent underquoting in
+       some b4_c_function_def and b4_c_function_decl uses.
+
+2006-12-19  Joel E. Denny  <address@hidden>
+
        Encapsulate the push parser state variables into an M4 macro so the
        push skeleton doesn't have to list them again for pull mode's yyparse.
        For push mode, remove yypush_parse's local equivalents of these
Index: data/push.c
===================================================================
RCS file: /sources/bison/bison/data/push.c,v
retrieving revision 1.19
diff -p -u -r1.19 push.c
--- data/push.c 20 Dec 2006 00:59:18 -0000      1.19
+++ data/push.c 20 Dec 2006 01:03:24 -0000
@@ -217,6 +217,22 @@ typedef struct YYLTYPE
 # define YYLTYPE_IS_TRIVIAL 1
 #endif])
 
+b4_push_if([[#ifndef YYPUSH_DECLS
+#  define YYPUSH_DECLS
+struct yypstate;
+typedef struct yypstate yypstate;
+enum { YYPUSH_MORE = 4 };
+]b4_c_function_decl([[yypstate_new]], [[yypstate *]], [[[void]], []])
+b4_c_function_decl([[yypstate_delete]], [[void]],
+                   [[[yypstate *yyps]], [[yyps]]])
+b4_c_function_decl([[yypush_parse]], [[int]],
+  [[[yypstate *yyps]], [[yyps]]],
+  [[[int yynchar]], [[yynchar]]],
+  [[[YYSTYPE const *yynlval]], [[yynlval]]]b4_locations_if([,
+  [[[YYLTYPE const *yynlloc]], [[yynlloc]]]])m4_ifset([b4_parse_param], [,
+  b4_parse_param]))[
+#endif
+]])
 m4_ifdef([b4_provides],
 [[/* Copy the %provides blocks.  */
 ]b4_user_provides])[]dnl
@@ -957,36 +973,23 @@ yysyntax_error (char *yyresult, int yyst
 
 
 ]b4_yydestruct_generate([b4_c_function_def])[
-
-
-/* Prevent warnings from -Wmissing-prototypes.  */
 
-]b4_push_if([
-struct yypstate;
-typedef struct yypstate yypstate;
-enum { YYPUSH_MORE = 4 };
-]b4_c_function_decl([yypstate_new], [yypstate *], [[void], []])[
-]b4_c_function_decl([yypstate_delete], [void], [[yypstate *yyps], [yyps]])[
-]b4_c_function_decl([yypush_parse], [int],
-   [[yypstate *yyps], [yyps]],
-   [[int yynchar], [yynchar]],
-   [[YYSTYPE const *yynlval], [yynlval]]
-   b4_locations_if([,[[YYLTYPE const *yynlloc], [yynlloc]]])
-   m4_ifset([b4_parse_param], [, b4_parse_param]))[
-],[#ifdef YYPARSE_PARAM
+]b4_push_if([],
+[[/* Prevent warnings from -Wmissing-prototypes.  */
+#ifdef YYPARSE_PARAM
 ]b4_c_function_decl([yyparse], [int],
    [[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[
 #else /* ! YYPARSE_PARAM */
 ]b4_c_function_decl([yyparse], [int], b4_parse_param)[
-#endif /* ! YYPARSE_PARAM */])[
+#endif /* ! YYPARSE_PARAM */]])
 
-]m4_divert_push([KILL])# ======================== M4 code.
+m4_divert_push([KILL])# ======================== M4 code.
 # b4_declare_scanner_communication_variables
 # ------------------------------------------
 # Declare the variables that are global, or local to YYPARSE if
 # pure-parser.
 m4_define([b4_declare_scanner_communication_variables],
-[/* The lookahead symbol.  */
+[[/* The lookahead symbol.  */
 int yychar;
 
 /* The semantic value of the lookahead symbol.  */
@@ -994,9 +997,9 @@ YYSTYPE yylval;
 
 /* Number of syntax errors so far.  */
 ]b4_push_if([],[
-int yynerrs;])[b4_locations_if([
+int yynerrs;])b4_locations_if([[
 /* Location data for the lookahead symbol.  */
-YYLTYPE yylloc;])
+YYLTYPE yylloc;]])
 ])
 
 m4_define([b4_yyssa],b4_push_if([yyps->yyssa],[yyssa]))
@@ -1060,7 +1063,7 @@ b4_push_if(
   };
 
 /* Initialize the parser data structure.  */
-]b4_c_function_def([yypstate_new], [yypstate *])[
+]b4_c_function_def([[yypstate_new]], [[yypstate *]])[
 {
   yypstate *yyps = (yypstate *) malloc (sizeof *yyps);
   yyps->yystate = 0;
@@ -1085,8 +1088,8 @@ b4_push_if(
   return yyps;
 }
 
-]b4_c_function_def([yypstate_delete], [void],
-                   [[yypstate *yyps], [yyps]])[
+]b4_c_function_def([[yypstate_delete]], [[void]],
+                   [[[yypstate *yyps]], [[yyps]]])[
 {
   free (yyps);
 }
@@ -1112,11 +1115,11 @@ b4_push_if(
 `-------------------------*/
 
 ]b4_push_if([
-b4_c_function_def([yypush_parse], [int], [[yypstate *yyps], [yyps]], 
-                  [[int yynchar], [yynchar]],
-                  [[YYSTYPE const *yynlval], [yynlval]]
-                 b4_locations_if([,[[YYLTYPE const *yynlloc], [yynlloc]]])
-                  m4_ifset([b4_parse_param], [, b4_parse_param]))],[
+b4_c_function_def([[yypush_parse]], [[int]], [[[yypstate *yyps]], [[yyps]]], 
+  [[[int yynchar]], [[yynchar]]],
+  [[[YYSTYPE const *yynlval]], [[yynlval]]]b4_locations_if([,
+  [[[YYLTYPE const *yynlloc]], [[yynlloc]]]])m4_ifset([b4_parse_param], [,
+  b4_parse_param]))], [
 #ifdef YYPARSE_PARAM
 b4_c_function_def([yyparse], [int], [[void *YYPARSE_PARAM], [YYPARSE_PARAM]])
 #else /* ! YYPARSE_PARAM */
@@ -1156,7 +1159,6 @@ b4_c_function_def([yyparse], [int], b4_p
      Waste one element of value and location stack
      so that they stay on the same level as the state stack.
      The wasted elements are never initialized.  */
-
   yyssp = yyss;
   yyvsp = yyvs;
 ]b4_locations_if([[  yylsp = yyls;
@@ -1634,20 +1636,23 @@ typedef struct YYLTYPE
           [extern YYLTYPE b4_prefix[]lloc;])
 )dnl b4_locations_if
 
-]b4_push_if([struct ]b4_prefix[pstate;
+b4_push_if([[#ifndef YYPUSH_DECLS
+#  define YYPUSH_DECLS
+struct ]b4_prefix[pstate;
 typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
-]b4_c_function_decl([]b4_prefix[pstate_new], []b4_prefix[pstate *],
-                    [[void], []])[
-]b4_c_function_decl([]b4_prefix[pstate_delete], [void],
-                    [[]b4_prefix[pstate *yyps],[yyps]])[
-]b4_c_function_decl([]b4_prefix[push_parse], [int],
-   [[]b4_prefix[pstate *]b4_prefix[pstate], []b4_prefix[pstate]],
-   [[int yynchar], [yynchar]],
-   [[YYSTYPE const *yynlval], [yynlval]]
-   b4_locations_if([,[[YYLTYPE const *yynlloc], [yynlloc]]])
-   m4_ifset([b4_parse_param], [, b4_parse_param]))[
-enum { YYPUSH_MORE = 4 };])[
-
+enum { YYPUSH_MORE = 4 };
+]b4_c_function_decl([b4_prefix[pstate_new]], [b4_prefix[pstate *]],
+                    [[[void]], []])
+b4_c_function_decl([b4_prefix[pstate_delete]], [[void]],
+                   [[b4_prefix[pstate *yyps]], [[yyps]]])
+b4_c_function_decl([b4_prefix[push_parse]], [[int]],
+  [[b4_prefix[pstate *yyps]], [[yyps]]],
+  [[[int yynchar]], [[yynchar]]],
+  [[[YYSTYPE const *yynlval]], [[yynlval]]]b4_locations_if([,
+  [[[YYLTYPE const *yynlloc]], [[yynlloc]]]])m4_ifset([b4_parse_param], [,
+  b4_parse_param]))[
+#endif
+]])
 m4_ifdef([b4_provides],
 [[/* Copy the %provides blocks.  */
 ]b4_user_provides])[]




reply via email to

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