* data/bison.simple (yyparse): Do not implement @$ = @1.

(YYLLOC_DEFAULT): Adjust to do it.
* doc/bison.texinfo (Location Default Action): Fix.
This commit is contained in:
Akim Demaille
2002-05-02 16:40:54 +00:00
parent 3a8b410924
commit b2d52318fa
4 changed files with 25 additions and 23 deletions

View File

@@ -1,3 +1,9 @@
2002-05-02 Akim Demaille <akim@epita.fr>
* data/bison.simple (yyparse): Do not implement @$ = @1.
(YYLLOC_DEFAULT): Adjust to do it.
* doc/bison.texinfo (Location Default Action): Fix.
2002-05-02 Akim Demaille <akim@epita.fr> 2002-05-02 Akim Demaille <akim@epita.fr>
* src/reader.c (parse_braces): Merge into... * src/reader.c (parse_braces): Merge into...

8
NEWS
View File

@@ -43,9 +43,11 @@ Changes in version 1.49b:
* Revert the C++ namespace changes introduced in 1.31, as they caused too * Revert the C++ namespace changes introduced in 1.31, as they caused too
many portability hassles. many portability hassles.
* Items overflow * Default locations
Bison no longer dumps core when there are too many items, it just By an accident of design, the default computation of @$ was
dies. performed after another default computation was performed: @$ = @1.
The latter is now removed: YYLLOC_DEFAULT is fully responsible of
the computation of @$.
* Token end-of-file * Token end-of-file
The token end of file may be specified by the user, in which case, The token end of file may be specified by the user, in which case,

View File

@@ -465,16 +465,14 @@ while (0)
#define YYERRCODE 256 #define YYERRCODE 256
/* YYLLOC_DEFAULT -- Compute the default location (before the actions /* YYLLOC_DEFAULT -- Compute the default location (before the actions
are run). are run). */
When YYLLOC_DEFAULT is run, CURRENT is set the location of the
first token. By default, to implement support for ranges, extend
its range to the last symbol. */
#ifndef YYLLOC_DEFAULT #ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \ # define YYLLOC_DEFAULT(Current, Rhs, N) \
Current.last_line = Rhs[[N]].last_line; \ Current.first_line = Rhs[[1]].first_line; \
Current.last_column = Rhs[[N]].last_column; Current.first_column = Rhs[[1]].first_column; \
Current.last_line = Rhs[[N]].last_line; \
Current.last_column = Rhs[[N]].last_column;
#endif #endif
/* YYLEX -- calling `yylex' with the right arguments. */ /* YYLEX -- calling `yylex' with the right arguments. */
@@ -956,9 +954,7 @@ yyreduce:
yyval = yyvsp[1-yylen]; yyval = yyvsp[1-yylen];
#if YYLSP_NEEDED #if YYLSP_NEEDED
/* Similarly for the default location. Let the user run additional /* Default location. */
commands if for instance locations are ranges. */
yyloc = yylsp[1-yylen];
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
#endif #endif

View File

@@ -2886,9 +2886,11 @@ By default, it is defined this way:
@example @example
@group @group
#define YYLLOC_DEFAULT(Current, Rhs, N) \ #define YYLLOC_DEFAULT(Current, Rhs, N) \
Current.last_line = Rhs[N].last_line; \ Current.first_line = Rhs[1].first_line; \
Current.last_column = Rhs[N].last_column; Current.first_column = Rhs[1].first_column; \
Current.last_line = Rhs[N].last_line; \
Current.last_column = Rhs[N].last_column;
@end group @end group
@end example @end example
@@ -2900,12 +2902,8 @@ All arguments are free of side-effects. However, only the first one (the
result) should be modified by @code{YYLLOC_DEFAULT}. result) should be modified by @code{YYLLOC_DEFAULT}.
@item @item
Before @code{YYLLOC_DEFAULT} is executed, the output parser sets @code{@@$} For consistency with semantic actions, valid indexes for the location
to @code{@@1}. array range from 1 to @var{n}.
@item
For consistency with semantic actions, valid indexes for the location array
range from 1 to @var{n}.
@end itemize @end itemize
@node Declarations @node Declarations