On Tue, Oct 10, 2006 at 03:19:51PM -0700, Paul Eggert wrote:
> Bob Rossi <[EMAIL PROTECTED]> writes:
>
> > --- yacc.c 2006-10-10 14:06:22.000000000 -0400
> > +++ push.c 2006-10-10 10:49:23.000000000 -0400
> > @@ -152,6 +152,9 @@
> > m4_if(b4_prefix, [yy], [],
> > [/* Substitute the variable and function names. */
> > #define yyparse b4_prefix[]parse
> > +#define yypushparse b4_prefix[]pushparse
> > +#define yypvarsinit b4_prefix[]pvarsinit
> > +#define yypvars b4_prefix[]pvars
> > #define yylex b4_prefix[]lex
> > #define yyerror b4_prefix[]error
> > #define yylval b4_prefix[]lval
> >
> > These are 3 new symbols that get defined depending on the prefix.
>
> Are these symbols needed if it's not a push parser? If not, perhaps
> they should be protected with b4_push_if. Similarly for any other
> changes needed only for the push parser.
OK fixed in this patch.
> > @@ -1023,6 +1136,7 @@
> >
> > /* The state stack. */
> > yytype_int16 yyssa[YYINITDEPTH];
> > + yytype_int16 *yyssa_ptr = yyssa;
> > yytype_int16 *yyss = yyssa;
> > yytype_int16 *yyssp;
> >
> > Same idea as above here.
> >
> > @@ -1037,7 +1151,9 @@
> > YYLTYPE *yyls = yylsa;
> > YYLTYPE *yylsp;
> > /* The locations where the error started and ended. */
> > - YYLTYPE yyerror_range[2];]])[
> > + YYLTYPE yyerror_range[2];
> > + YYLTYPE *yyerror_range_ptr = yyerror_range;
> > + ]])[
> >
> > Again, same idea.
>
> I guess this is different from yymsgbuf_ptr, since this storage does
> need to survive from one call to the next. But I don't see why the
> pointers are needed here, either. If it's always the case that
> yyssa_ptr == pv->yyssa then you can simply use pv->yyssa rather than
> maintaining a separate pointer. Likewise for yyerror_range_ptr.
OK, fixed in this patch also.
I hope doing this in small patches is easier, that's why I'm sending
them in this way. Did you have any other complaints regarding the
differences between the push and yacc parser?
Thanks,
Bob Rossi
2006-10-11 Bob Rossi <[EMAIL PROTECTED]>
* data/push.c (yypushparse, yypvarsinit, yypvars): Wrap in
b4_push_if.
(b4_yyssa, b4_yyerror_range): New macros.
(struct yypvars): Remove yyssa_ptr and yyerror_range_ptr fields.
(yypvarsinit): Remove init of removed fields.
(yypushparse): Remove use of removed fields, use new macros
instead.
Index: data/push.c
===================================================================
RCS file: /sources/bison/bison/data/push.c,v
retrieving revision 1.5
diff -u -r1.5 push.c
--- data/push.c 11 Oct 2006 19:13:48 -0000 1.5
+++ data/push.c 11 Oct 2006 20:40:55 -0000
@@ -152,9 +152,9 @@
m4_if(b4_prefix, [yy], [],
[/* Substitute the variable and function names. */
#define yyparse b4_prefix[]parse
-#define yypushparse b4_prefix[]pushparse
+]b4_push_if([#define yypushparse b4_prefix[]pushparse
#define yypvarsinit b4_prefix[]pvarsinit
-#define yypvars b4_prefix[]pvars
+#define yypvars b4_prefix[]pvars])[
#define yylex b4_prefix[]lex
#define yyerror b4_prefix[]error
#define yylval b4_prefix[]lval
@@ -1002,6 +1002,9 @@
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]))
+
# b4_declare_yyparse_variables
# ----------------------------
# Declare all the variables that are needed local to YYPARSE
@@ -1027,7 +1030,6 @@
/* The state stack. */
yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyssa_ptr;
yytype_int16 *yyss;
yytype_int16 *yyssp;
@@ -1040,8 +1042,7 @@
YYLTYPE *yyls;
YYLTYPE *yylsp;
/* The locations where the error started and ended. */
- YYLTYPE yyerror_range[2];
- YYLTYPE *yyerror_range_ptr;]]])[
+ YYLTYPE yyerror_range[2];]]])[
YYSIZE_T yystacksize;
int yylen;
/* The variables used to return semantic value and location from the
@@ -1062,7 +1063,6 @@
pv->yyerrstatus = 0;
pv->yytoken = 0;
- pv->yyssa_ptr = pv->yyssa;
pv->yyss = pv->yyssa;
pv->yyvs = pv->yyvsa;
@@ -1153,7 +1153,6 @@
/* The state stack. */
yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyssa_ptr = yyssa;
yytype_int16 *yyss = yyssa;
yytype_int16 *yyssp;
@@ -1169,7 +1168,6 @@
YYLTYPE *yylsp;
/* The locations where the error started and ended. */
YYLTYPE yyerror_range[2];
- YYLTYPE *yyerror_range_ptr = yyerror_range;
]])[
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_locations_if([, yylsp
-= (N)])[)
@@ -1234,7 +1232,6 @@
yyerrstatus = pv->yyerrstatus;
yytoken = pv->yytoken;
- yyssa_ptr = pv->yyssa_ptr;
yyss = pv->yyss;
yyssp = pv->yyssp;
@@ -1243,9 +1240,7 @@
]b4_locations_if([[ /* The location stack. */
yyls = pv->yyls;
- yylsp = pv->yylsp;
-
- yyerror_range_ptr = pv->yyerror_range_ptr;]])[
+ yylsp = pv->yylsp;]])[
yystacksize = pv->yystacksize;
yylen = pv->yylen;
@@ -1317,7 +1312,7 @@
YYSTACK_RELOCATE (yyvs);
]b4_locations_if([ YYSTACK_RELOCATE (yyls);])[
# undef YYSTACK_RELOCATE
- if (yyss1 != yyssa_ptr)
+ if (yyss1 != ]b4_yyssa[)
YYSTACK_FREE (yyss1);
}
# endif
@@ -1374,7 +1369,6 @@
pv->yyerrstatus = yyerrstatus;
pv->yytoken = yytoken;
- pv->yyssa_ptr = yyssa_ptr;
pv->yyss = yyss;
pv->yyssp = yyssp;
@@ -1383,8 +1377,7 @@
]b4_locations_if([[ /* The location stack. */
pv->yyls = yyls;
- pv->yylsp = yylsp;
- pv->yyerror_range_ptr = yyerror_range_ptr;]])[
+ pv->yylsp = yylsp;]])[
pv->yystacksize = yystacksize;
pv->yylen = yylen;
@@ -1543,7 +1536,7 @@
#endif
}
-]b4_locations_if([[ yyerror_range[0] = yylloc;]])[
+]b4_locations_if([[ ]b4_yyerror_range[[0] = yylloc;]])[
if (yyerrstatus == 3)
{
@@ -1580,7 +1573,7 @@
if (/*CONSTCOND*/ 0)
goto yyerrorlab;
-]b4_locations_if([[ yyerror_range[0] = yylsp[1-yylen];
+]b4_locations_if([[ ]b4_yyerror_range[[0] = yylsp[1-yylen];
]])[ /* Do not reclaim the symbols of the rule which action triggered
this YYERROR. */
YYPOPSTACK (yylen);
@@ -1614,7 +1607,7 @@
if (yyssp == yyss)
YYABORT;
-]b4_locations_if([[ yyerror_range[0] = *yylsp;]])[
+]b4_locations_if([[ ]b4_yyerror_range[[0] = *yylsp;]])[
yydestruct ("Error: popping",
yystos[yystate], yyvsp]b4_locations_if([,
yylsp])[]b4_user_args[);
YYPOPSTACK (1);
@@ -1624,10 +1617,10 @@
*++yyvsp = yylval;
]b4_locations_if([[
- yyerror_range[1] = yylloc;
+ ]b4_yyerror_range[[1] = yylloc;
/* Using YYLLOC is tempting, but would change the location of
the lookahead. YYLOC is available though. */
- YYLLOC_DEFAULT (yyloc, (yyerror_range- 1), 2);
+ YYLLOC_DEFAULT (yyloc, (]b4_yyerror_range[- 1), 2);
*++yylsp = yyloc;]])[
/* Shift the error token. */
@@ -1676,7 +1669,7 @@
YYPOPSTACK (1);
}
#ifndef yyoverflow
- if (yyss != yyssa_ptr)
+ if (yyss != ]b4_yyssa[)
YYSTACK_FREE (yyss);
#endif
]b4_push_if([yypushreturn:])[