[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: calc.at workaround for current test failures
From: |
Paul Eggert |
Subject: |
Re: calc.at workaround for current test failures |
Date: |
20 Jun 2003 15:53:39 -0700 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
> From: Frank Heckenbach <address@hidden>
> Date: Fri, 20 Jun 2003 00:20:35 +0200
> In my copy it says (line 708):
>
> YYLLOC_DEFAULT (*yylocp, yyvsp - yyrhslen, yyrhslen);
>
> It should be:
>
> YYLLOC_DEFAULT ((*yylocp), (yyvsp - yyrhslen), yyrhslen);
>
> I suppose you mean the macro definition. Yes, generally, parentheses
> are put in macro definitions. But since in this case the macro call
> is generated by bison and the macro is (often) provided by the user,
> it might be useful to add the parentheses in the call.
I'd rather follow the usual convention, which is that it's the C
macro definition's responsibility for proper parenthesization. So I
installed this patch:
2003-06-20 Paul Eggert <address@hidden>
* data/glr.c (YYLLOC_DEFAULT): Parenthesize arguments as needed,
and return properly parenthesized result.
* data/lalar1.cc (YYLLOC_DEFAULT): Likewise.
* data/yacc.c (YYLLOC_DEFAULT): Likewise.
Remove unnecessary parentheses from uses.
* doc/bison.texinfo (Location Default Action): Describe the
conventions for parentheses.
Index: data/glr.c
===================================================================
RCS file: /cvsroot/bison/bison/data/glr.c,v
retrieving revision 1.59
diff -p -u -r1.59 glr.c
--- data/glr.c 19 Jun 2003 08:45:16 -0000 1.59
+++ data/glr.c 20 Jun 2003 22:49:46 -0000
@@ -414,14 +414,14 @@ static const ]b4_int_type_for([b4_stos])
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(yyCurrent, yyRhs, YYN) \
- (yyCurrent).first_line = YYRHSLOC(yyRhs,1).first_line; \
- (yyCurrent).first_column = YYRHSLOC(yyRhs,1).first_column; \
- (yyCurrent).last_line = YYRHSLOC(yyRhs,YYN).last_line; \
- (yyCurrent).last_column = YYRHSLOC(yyRhs,YYN).last_column;
+ ((yyCurrent).first_line = YYRHSLOC(yyRhs, 1).first_line, \
+ (yyCurrent).first_column = YYRHSLOC(yyRhs, 1).first_column, \
+ (yyCurrent).last_line = YYRHSLOC(yyRhs, YYN).last_line, \
+ (yyCurrent).last_column = YYRHSLOC(yyRhs, YYN).last_column)
#endif
]],[
#ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(yyCurrent, yyRhs, YYN)
+# define YYLLOC_DEFAULT(yyCurrent, yyRhs, YYN) ((void) 0)
#endif
])[
Index: data/lalr1.cc
===================================================================
RCS file: /cvsroot/bison/bison/data/lalr1.cc,v
retrieving revision 1.34
diff -p -u -r1.34 lalr1.cc
--- data/lalr1.cc 4 Jun 2003 05:53:10 -0000 1.34
+++ data/lalr1.cc 20 Jun 2003 22:49:47 -0000
@@ -170,7 +170,7 @@ b4_syncline(address@hidden@], address@hidden@])],
b4_syncline(address@hidden@], address@hidden@])[
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
- Current.end = Rhs[N].end;
+ ((Current).end = Rhs[N].end)
#endif
namespace yy
Index: data/yacc.c
===================================================================
RCS file: /cvsroot/bison/bison/data/yacc.c,v
retrieving revision 1.58
diff -p -u -r1.58 yacc.c
--- data/yacc.c 2 Jun 2003 03:57:39 -0000 1.58
+++ data/yacc.c 20 Jun 2003 22:49:48 -0000
@@ -501,11 +501,11 @@ while (0)
are run). */
#ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(Current, Rhs, N) \
- Current.first_line = Rhs[1].first_line; \
- Current.first_column = Rhs[1].first_column; \
- Current.last_line = Rhs[N].last_line; \
- Current.last_column = Rhs[N].last_column;
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ ((Current).first_line = (Rhs)[1].first_line, \
+ (Current).first_column = (Rhs)[1].first_column, \
+ (Current).last_line = (Rhs)[N].last_line, \
+ (Current).last_column = (Rhs)[N].last_column)
#endif
/* YYLEX -- calling `yylex' with the right arguments. */
@@ -983,7 +983,7 @@ yyreduce:
]b4_location_if(
[ /* Default location. */
- YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);])[
+ YYLLOC_DEFAULT (yyloc, yylsp - yylen, yylen);])[
YY_REDUCE_PRINT (yyn);
switch (yyn)
]{
@@ -1180,7 +1180,7 @@ yyerrlab1:
YYDPRINTF ((stderr, "Shifting error token, "));
*++yyvsp = yylval;
-]b4_location_if([ YYLLOC_DEFAULT (yyloc, yylsp, (yylerrsp - yylsp));
+]b4_location_if([ YYLLOC_DEFAULT (yyloc, yylsp, yylerrsp - yylsp);
*++yylsp = yyloc;])[
yystate = yyn;
Index: doc/bison.texinfo
===================================================================
RCS file: /cvsroot/bison/bison/doc/bison.texinfo,v
retrieving revision 1.109
diff -p -u -r1.109 bison.texinfo
--- doc/bison.texinfo 17 Jun 2003 05:15:49 -0000 1.109
+++ doc/bison.texinfo 20 Jun 2003 22:49:56 -0000
@@ -3210,11 +3210,11 @@ By default, @code{YYLLOC_DEFAULT} is def
@example
@group
-#define YYLLOC_DEFAULT(Current, Rhs, N) \
- Current.first_line = Rhs[1].first_line; \
- Current.first_column = Rhs[1].first_column; \
- Current.last_line = Rhs[N].last_line; \
- Current.last_column = Rhs[N].last_column;
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ ((Current).first_line = (Rhs)[1].first_line, \
+ (Current).first_column = (Rhs)[1].first_column, \
+ (Current).last_line = (Rhs)[N].last_line, \
+ (Current).last_column = (Rhs)[N].last_column)
@end group
@end example
@@ -3223,11 +3223,11 @@ and like this for @acronym{GLR} parsers:
@example
@group
-#define YYLLOC_DEFAULT(Current, Rhs, N) \
- Current.first_line = YYRHSLOC(Rhs,1).first_line; \
- Current.first_column = YYRHSLOC(Rhs,1).first_column; \
- Current.last_line = YYRHSLOC(Rhs,N).last_line; \
- Current.last_column = YYRHSLOC(Rhs,N).last_column;
+# define YYLLOC_DEFAULT(yyCurrent, yyRhs, YYN) \
+ ((yyCurrent).first_line = YYRHSLOC(yyRhs, 1).first_line, \
+ (yyCurrent).first_column = YYRHSLOC(yyRhs, 1).first_column, \
+ (yyCurrent).last_line = YYRHSLOC(yyRhs, YYN).last_line, \
+ (yyCurrent).last_column = YYRHSLOC(yyRhs, YYN).last_column)
@end group
@end example
@@ -3241,6 +3241,12 @@ result) should be modified by @code{YYLL
@item
For consistency with semantic actions, valid indexes for the location
array range from 1 to @var{n}.
+
address@hidden
+Your macro should parenthesize its arguments, if need be, since the
+actual arguments may not be surrounded by parentheses. Also, your
+macro should expand to something that can be used as a single
+statement when it is followed by a semicolon.
@end itemize
@node Declarations