mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 04:43:03 +00:00
* src/bison.s1 (YYLLOC_DEFAULT): New macro.
Provide a default definition. Use it when executing the default @ action. * src/reader.c (reader_output_yylsp): No longer include `timestamp' and `text' in the default YYLTYPE.
This commit is contained in:
36
src/bison.s1
36
src/bison.s1
@@ -117,7 +117,21 @@ while (0)
|
||||
#define YYERRCODE 256
|
||||
|
||||
|
||||
/* YYLEX -- calling `yylex' with the right arguments. */
|
||||
/* YYLLOC_DEFAULT -- Compute the default location (before the actions
|
||||
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
|
||||
# define YYLLOC_DEFAULT(Current, Last) \
|
||||
Current.last_line = Last.last_line; \
|
||||
Current.last_column = Last.last_column;
|
||||
#endif
|
||||
|
||||
|
||||
/* YYLEX -- calling `yylex' with the right arguments. */
|
||||
|
||||
#if YYPURE
|
||||
# if YYLSP_NEEDED
|
||||
@@ -579,22 +593,12 @@ yyreduce:
|
||||
unconditionally makes the parser a bit smaller, and it avoids a
|
||||
GCC warning that YYVAL may be used uninitialized. */
|
||||
yyval = yyvsp[1-yylen];
|
||||
|
||||
#if YYLSP_NEEDED
|
||||
/* Implement default location. If the rhs is empty, extend YYLOC to
|
||||
YYLLOC, which corresponds to the current token, otherwise
|
||||
implement `@{dollar} = Starts at @1, ends at @YYLEN'. */
|
||||
if (yylen > 0)
|
||||
{
|
||||
yyloc = yylsp[1-yylen];
|
||||
yyloc.last_line = yylsp[0].last_line;
|
||||
yyloc.last_column = yylsp[0].last_column;
|
||||
}
|
||||
else
|
||||
{
|
||||
yyloc.last_line = yylsp[0].last_line;
|
||||
yyloc.last_column = yylsp[0].last_column;
|
||||
yyloc.text = 0;
|
||||
}
|
||||
/* Similarly for the default location. Let the user run additional
|
||||
commands if for instance locations are ranges. */
|
||||
yyloc = yylsp[1-yylen];
|
||||
YYLLOC_DEFAULT (yyloc, yylsp[0]);
|
||||
#endif
|
||||
|
||||
#if YYDEBUG
|
||||
|
||||
@@ -117,7 +117,21 @@ while (0)
|
||||
#define YYERRCODE 256
|
||||
|
||||
|
||||
/* YYLEX -- calling `yylex' with the right arguments. */
|
||||
/* YYLLOC_DEFAULT -- Compute the default location (before the actions
|
||||
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
|
||||
# define YYLLOC_DEFAULT(Current, Last) \
|
||||
Current.last_line = Last.last_line; \
|
||||
Current.last_column = Last.last_column;
|
||||
#endif
|
||||
|
||||
|
||||
/* YYLEX -- calling `yylex' with the right arguments. */
|
||||
|
||||
#if YYPURE
|
||||
# if YYLSP_NEEDED
|
||||
@@ -579,22 +593,12 @@ yyreduce:
|
||||
unconditionally makes the parser a bit smaller, and it avoids a
|
||||
GCC warning that YYVAL may be used uninitialized. */
|
||||
yyval = yyvsp[1-yylen];
|
||||
|
||||
#if YYLSP_NEEDED
|
||||
/* Implement default location. If the rhs is empty, extend YYLOC to
|
||||
YYLLOC, which corresponds to the current token, otherwise
|
||||
implement `@{dollar} = Starts at @1, ends at @YYLEN'. */
|
||||
if (yylen > 0)
|
||||
{
|
||||
yyloc = yylsp[1-yylen];
|
||||
yyloc.last_line = yylsp[0].last_line;
|
||||
yyloc.last_column = yylsp[0].last_column;
|
||||
}
|
||||
else
|
||||
{
|
||||
yyloc.last_line = yylsp[0].last_line;
|
||||
yyloc.last_column = yylsp[0].last_column;
|
||||
yyloc.text = 0;
|
||||
}
|
||||
/* Similarly for the default location. Let the user run additional
|
||||
commands if for instance locations are ranges. */
|
||||
yyloc = yylsp[1-yylen];
|
||||
YYLLOC_DEFAULT (yyloc, yylsp[0]);
|
||||
#endif
|
||||
|
||||
#if YYDEBUG
|
||||
|
||||
@@ -1992,6 +1992,11 @@ reader (void)
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------.
|
||||
| Define YYLTYPE. Cannot be in the skeleton since we might have to |
|
||||
| output it in the headers if --defines is used. |
|
||||
`------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
reader_output_yylsp (struct obstack *oout)
|
||||
{
|
||||
@@ -2001,13 +2006,11 @@ reader_output_yylsp (struct obstack *oout)
|
||||
#ifndef YYLTYPE\n\
|
||||
typedef struct yyltype\n\
|
||||
{\n\
|
||||
int timestamp;\n\
|
||||
int first_line;\n\
|
||||
int first_column;\
|
||||
int first_column;\n\
|
||||
\n\
|
||||
int last_line;\n\
|
||||
int last_column;\n\
|
||||
char *text;\n\
|
||||
} yyltype;\n\
|
||||
\n\
|
||||
# define YYLTYPE yyltype\n\
|
||||
|
||||
Reference in New Issue
Block a user