On Mon, Dec 04, 2006 at 06:15:46PM -0500, Joel E. Denny wrote:
> Well, I found a little time much earlier than I thought....
> 
> 1. How was the name yypvars chosen?  What does ctx stand for?  Context?  
> It seems we have about three terms for the same thing: parser state, vars, 
> and context.  This will make the documentation a little confusing I fear.  
> I think we should pick one term and stick with it.  I prefer parser state, 
> which implies renaming yypvars to something like yypstate.

Hi Joel,

Here's a patch that renames all uses of pv to pstate. It changes all
uses of pvars to pstate. It also adds the prototypes for yypstateinit
and yypushparse to the bison generated header file.

I'm not really sure how to write a ChangeLog entry whening doing mass
renames, so hopefully this is OK.

Thanks,
Bob Rossi

2006-12-08  Bob Rossi  <[EMAIL PROTECTED]>

        * data/push.c (yypvarsinit, yypvars, struct yypvars): Renamed from
        yypvars to yypstate.
        (pv): Renamed all occurences of pv to pstate.
        (yypstateinit, yypushparse): Declare in bison generated header file.
        * tests/calc.at (_AT_DATA_CALC_Y): Use newly named functions.


Index: data/push.c
===================================================================
RCS file: /sources/bison/bison/data/push.c,v
retrieving revision 1.10
diff -u -r1.10 push.c
--- data/push.c 8 Dec 2006 01:04:39 -0000       1.10
+++ data/push.c 8 Dec 2006 15:34:16 -0000
@@ -153,8 +153,8 @@
 [/* Substitute the variable and function names.  */
 #define yyparse b4_prefix[]parse
 ]b4_push_if([#define yypushparse b4_prefix[]pushparse
-#define yypvarsinit b4_prefix[]pvarsinit
-#define yypvars b4_prefix[]pvars])[
+#define yypstateinit b4_prefix[]pstateinit
+#define yypstate b4_prefix[]pstate])[
 #define yylex   b4_prefix[]lex
 #define yyerror b4_prefix[]error
 #define yylval  b4_prefix[]lval
@@ -968,11 +968,11 @@
 #endif /* ! YYPARSE_PARAM */
 
 ]b4_push_if([
-struct yypvars;
+struct yypstate;
 enum { YYPUSH_MORE = 4 };
-]b4_c_function_decl([yypvarsinit], [struct yypvars *], [[void], []])[
+]b4_c_function_decl([yypstateinit], [struct yypstate *], [[void], []])[
 ]b4_c_function_decl([yypushparse], [int],
-   [[struct yypvars *yypvars], [yypvars]],
+   [[struct yypstate *yypstate], [yypstate]],
    [[int yynchar], [yynchar]],
    [[YYSTYPE *yynlval], [yynlval]]
    b4_locations_if([,[[YYLTYPE *yynlloc], [yynlloc]]]))[
@@ -997,14 +997,14 @@
 YYLTYPE yylloc;])
 ])
 
-m4_define([b4_yyssa],b4_push_if([pv->yyssa],[yyssa]))
-m4_define([b4_yyerror_range],b4_push_if([pv->yyerror_range],[yyerror_range]))
+m4_define([b4_yyssa],b4_push_if([pstate->yyssa],[yyssa]))
+m4_define([b4_yyerror_range],b4_push_if([pstate->yyerror_range],[yyerror_range]))
 
 # b4_declare_yyparse_variables
 # ----------------------------
 # Declare all the variables that are needed local to YYPARSE
 m4_define([b4_declare_yyparse_variables],
-[[struct yypvars
+[[struct yypstate
   {
     int yystate;
     int yyn;
@@ -1047,30 +1047,30 @@
   };
 
 /* Initialize the parser data structure.  */
-struct yypvars*
-yypvarsinit (void)
+struct yypstate*
+yypstateinit (void)
 {
-  struct yypvars *pv = (struct yypvars *) malloc (sizeof *pv);
-  pv->yystate = 0;
-  pv->yyresult = -1;
-  pv->yyerrstatus = 0;
-  pv->yytoken = 0;
+  struct yypstate *pstate = (struct yypstate *) malloc (sizeof *pstate);
+  pstate->yystate = 0;
+  pstate->yyresult = -1;
+  pstate->yyerrstatus = 0;
+  pstate->yytoken = 0;
 
-  pv->yyss = pv->yyssa;
-  pv->yyvs = pv->yyvsa;
+  pstate->yyss = pstate->yyssa;
+  pstate->yyvs = pstate->yyvsa;
 
   ]b4_locations_if([
-    pv->yyls = pv->yylsa;])[
-  pv->yystacksize = YYINITDEPTH;
+    pstate->yyls = pstate->yylsa;])[
+  pstate->yystacksize = YYINITDEPTH;
 
-  pv->yyssp = pv->yyss;
-  pv->yyvsp = pv->yyvs;
+  pstate->yyssp = pstate->yyss;
+  pstate->yyvsp = pstate->yyvs;
 
-  pv->yynew = 1;
+  pstate->yynew = 1;
 
-]b4_locations_if([  pv->yylsp = pv->yyls;])[
+]b4_locations_if([  pstate->yylsp = pstate->yyls;])[
 
-  return pv;
+  return pstate;
 }])
 m4_divert_pop([KILL])dnl# ====================== End of M4 code.
 
@@ -1084,7 +1084,7 @@
 `-------------------------*/
 
 b4_push_if([
-b4_c_function_def([yypushparse], [int], [[struct yypvars *yypvars], 
[yypvars]], 
+b4_c_function_def([yypushparse], [int], [[struct yypstate *yypstate], 
[yypstate]], 
                   [[int yynchar], [yynchar]], [[YYSTYPE *yynlval], [yynlval]]
                  b4_locations_if([,[[YYLTYPE *yynlloc], [yynlloc]]]))],[
 #ifdef YYPARSE_PARAM
@@ -1095,7 +1095,7 @@
 {[
   ]b4_pure_if([b4_declare_parser_variables])[
   ]b4_push_if([b4_declare_parser_variables])[
-  ]b4_push_if([struct yypvars *pv;])[
+  ]b4_push_if([struct yypstate *pstate;])[
   int yystate;
   int yyn;
   int yyresult;
@@ -1155,7 +1155,7 @@
   yystate = 0;
   yyerrstatus = 0;
 ]b4_push_if([  yychar = yynchar;
-  pv = yypvars;
+  pstate = yypstate;
   if (yynlval)
     yylval = *yynlval;
 ]b4_locations_if([  if (yynlloc)
@@ -1190,30 +1190,30 @@
 ]])dnl
 [  ]b4_push_if([
        /* Initialize the locals to the current context. */
-       yystate = pv->yystate;
-       yyn = pv->yyn;
-       yyresult = pv->yyresult;
-       yyerrstatus = pv->yyerrstatus;
-       yytoken = pv->yytoken;
+       yystate = pstate->yystate;
+       yyn = pstate->yyn;
+       yyresult = pstate->yyresult;
+       yyerrstatus = pstate->yyerrstatus;
+       yytoken = pstate->yytoken;
 
-       yyss = pv->yyss;
-       yyssp = pv->yyssp;
+       yyss = pstate->yyss;
+       yyssp = pstate->yyssp;
 
-       yyvs = pv->yyvs;
-       yyvsp = pv->yyvsp;
+       yyvs = pstate->yyvs;
+       yyvsp = pstate->yyvsp;
 
        ]b4_locations_if([[  /* The location stack.  */
-       yyls = pv->yyls;
-       yylsp = pv->yylsp;]])[
+       yyls = pstate->yyls;
+       yylsp = pstate->yylsp;]])[
 
-       yystacksize = pv->yystacksize;
-       yyval = pv->yyval;
-       ]b4_locations_if([yyloc = pv->yyloc;])[
-      if (pv->yynew == 0)
+       yystacksize = pstate->yystacksize;
+       yyval = pstate->yyval;
+       ]b4_locations_if([yyloc = pstate->yyloc;])[
+      if (pstate->yynew == 0)
       {
        goto gottoken;
       }
-      pv->yynew= 0;])[
+      pstate->yynew= 0;])[
   goto yysetstate;
 
 /*------------------------------------------------------------.
@@ -1321,24 +1321,24 @@
        YYDPRINTF ((stderr, "Return for a new token:\n"));
        yyresult = YYPUSH_MORE;
        /* Initialize the locals to the current context. */
-       pv->yystate = yystate;
-       pv->yyn = yyn;
-       pv->yyerrstatus = yyerrstatus;
-       pv->yytoken = yytoken;
+       pstate->yystate = yystate;
+       pstate->yyn = yyn;
+       pstate->yyerrstatus = yyerrstatus;
+       pstate->yytoken = yytoken;
 
-       pv->yyss = yyss;
-       pv->yyssp = yyssp;
+       pstate->yyss = yyss;
+       pstate->yyssp = yyssp;
 
-       pv->yyvs = yyvs;
-       pv->yyvsp = yyvsp;
+       pstate->yyvs = yyvs;
+       pstate->yyvsp = yyvsp;
 
        ]b4_locations_if([[  /* The location stack.  */
-       pv->yyls = yyls;
-       pv->yylsp = yylsp;]])[
+       pstate->yyls = yyls;
+       pstate->yylsp = yylsp;]])[
 
-       pv->yystacksize = yystacksize;
-       pv->yyval = yyval;
-       ]b4_locations_if([pv->yyloc = yyloc;])[
+       pstate->yystacksize = yystacksize;
+       pstate->yyval = yyval;
+       ]b4_locations_if([pstate->yyloc = yyloc;])[
        goto yypushreturn;
 gottoken:])[
       YYDPRINTF ((stderr, "Reading a token: "));
@@ -1633,7 +1633,7 @@
   if (yymsg != yymsgbuf)
     YYSTACK_FREE (yymsg);
 #endif
-  ]b4_push_if([pv->yyresult = YYID (yyresult);])[
+  ]b4_push_if([pstate->yyresult = YYID (yyresult);])[
   /* Make sure YYID is used.  */
   return YYID (yyresult);
 ]}
@@ -1680,7 +1680,13 @@
 # define YYLTYPE_IS_TRIVIAL 1
 #endif
 
-]b4_push_if([struct ]b4_prefix[pvars;
+]b4_push_if([struct ]b4_prefix[pstate;
+]b4_c_function_decl([]b4_prefix[pstateinit], [struct ]b4_prefix[pstate *], 
[[void], []])[
+]b4_c_function_decl([]b4_prefix[pushparse], [int],
+   [[struct ]b4_prefix[pstate *]b4_prefix[pstate], []b4_prefix[pstate]],
+   [[int yynchar], [yynchar]],
+   [[YYSTYPE *yynlval], [yynlval]]
+   b4_locations_if([,[[YYLTYPE *yynlloc], [yynlloc]]]))[
 enum { YYPUSH_MORE = 4 };])[
 ]b4_pure_if([],
           [extern YYLTYPE b4_prefix[]lloc;])
Index: tests/calc.at
===================================================================
RCS file: /sources/bison/bison/tests/calc.at,v
retrieving revision 1.95
diff -u -r1.95 calc.at
--- tests/calc.at       7 Dec 2006 02:21:13 -0000       1.95
+++ tests/calc.at       8 Dec 2006 15:34:16 -0000
@@ -338,13 +338,13 @@
 [  yydebug = 1;])])[
 ]AT_PUSH_IF([
   {
-    struct yypvars *ctx = yypvarsinit ();
+    struct yypstate *pstate = yypstateinit ();
     YYSTYPE my_lval;
     ]AT_LOCATION_IF([YYLTYPE my_lloc;])[
     do {
-      status = yypushparse (ctx, yylex (&my_lval]AT_LOCATION_IF([[, 
&my_lloc]])[), &my_lval]AT_LOCATION_IF([[, &my_lloc]])[);
+      status = yypushparse (pstate, yylex (&my_lval]AT_LOCATION_IF([[, 
&my_lloc]])[), &my_lval]AT_LOCATION_IF([[, &my_lloc]])[);
     } while (status == YYPUSH_MORE);
-    free (ctx);
+    free (pstate);
   }],[
   status = yyparse (]AT_PARAM_IF([[&result, &count]])[);])[
   fclose (input);

Reply via email to