mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-15 15:23:02 +00:00
tests: calc: simplify location management.
* tests/local.at (AT_LOC_PUSHDEF, AT_LOC_POPDEF): New. (_AT_BISON_OPTION_PUSHDEFS, AT_BISON_OPTION_POPDEFS): Use them to define the appropriate AT_LOC accessors. * tests/calc.at: Use AT_LOC accessors.
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
2010-04-13 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
|
tests: calc: simplify location management.
|
||||||
|
* tests/local.at (AT_LOC_PUSHDEF, AT_LOC_POPDEF): New.
|
||||||
|
(_AT_BISON_OPTION_PUSHDEFS, AT_BISON_OPTION_POPDEFS): Use them to
|
||||||
|
define the appropriate AT_LOC accessors.
|
||||||
|
* tests/calc.at: Use AT_LOC accessors.
|
||||||
|
|
||||||
2010-04-13 Akim Demaille <demaille@gostai.com>
|
2010-04-13 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
test location_type.
|
test location_type.
|
||||||
|
|||||||
@@ -55,11 +55,11 @@ get_char (]AT_LEX_FORMALS[)
|
|||||||
last_yylloc = AT_LOC;
|
last_yylloc = AT_LOC;
|
||||||
if (res == '\n')
|
if (res == '\n')
|
||||||
{
|
{
|
||||||
AT_LOC.last_line++;
|
AT_LOC_LAST_LINE++;
|
||||||
AT_LOC.last_column = 1;
|
AT_LOC_LAST_COLUMN = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
AT_LOC.last_column++;
|
AT_LOC_LAST_COLUMN++;
|
||||||
])[
|
])[
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -117,22 +117,22 @@ int
|
|||||||
{
|
{
|
||||||
init = 0;
|
init = 0;
|
||||||
]AT_LOCATION_IF([
|
]AT_LOCATION_IF([
|
||||||
AT_LOC.last_column = 1;
|
AT_LOC_LAST_COLUMN = 1;
|
||||||
AT_LOC.last_line = 1;
|
AT_LOC_LAST_LINE = 1;
|
||||||
])[
|
])[
|
||||||
}
|
}
|
||||||
|
|
||||||
]AT_LOCATION_IF([
|
]AT_LOCATION_IF([
|
||||||
AT_LOC.first_column = AT_LOC.last_column;
|
AT_LOC_FIRST_COLUMN = AT_LOC_LAST_COLUMN;
|
||||||
AT_LOC.first_line = AT_LOC.last_line;
|
AT_LOC_FIRST_LINE = AT_LOC_LAST_LINE;
|
||||||
])[
|
])[
|
||||||
|
|
||||||
/* Skip white space. */
|
/* Skip white space. */
|
||||||
while ((c = get_char (]AT_LEX_ARGS[)) == ' ' || c == '\t')
|
while ((c = get_char (]AT_LEX_ARGS[)) == ' ' || c == '\t')
|
||||||
{
|
{
|
||||||
]AT_LOCATION_IF(
|
]AT_LOCATION_IF(
|
||||||
[ AT_LOC.first_column = AT_LOC.last_column;
|
[ AT_LOC_FIRST_COLUMN = AT_LOC_LAST_COLUMN;
|
||||||
AT_LOC.first_line = AT_LOC.last_line;
|
AT_LOC_FIRST_LINE = AT_LOC_LAST_LINE;
|
||||||
])[
|
])[
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,17 +192,7 @@ extern FILE *input;]AT_SKEL_CC_IF([[
|
|||||||
#ifndef YYLTYPE
|
#ifndef YYLTYPE
|
||||||
# define YYLTYPE ]AT_NAME_PREFIX[::parser::location_type
|
# define YYLTYPE ]AT_NAME_PREFIX[::parser::location_type
|
||||||
#endif
|
#endif
|
||||||
]AT_LOCATION_TYPE_IF([[
|
]])[
|
||||||
#define first_line begin.l
|
|
||||||
#define first_column begin.c
|
|
||||||
#define last_line end.l
|
|
||||||
#define last_column end.c
|
|
||||||
]], [[
|
|
||||||
#define first_line begin.line
|
|
||||||
#define first_column begin.column
|
|
||||||
#define last_line end.line
|
|
||||||
#define last_column end.column
|
|
||||||
]])])[
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%code
|
%code
|
||||||
@@ -328,13 +318,13 @@ yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ])
|
|||||||
AT_PARAM_IF([(void) result; (void) count;])
|
AT_PARAM_IF([(void) result; (void) count;])
|
||||||
AT_YYERROR_SEES_LOC_IF([
|
AT_YYERROR_SEES_LOC_IF([
|
||||||
fprintf (stderr, "%d.%d",
|
fprintf (stderr, "%d.%d",
|
||||||
AT_LOC.first_line, AT_LOC.first_column);
|
AT_LOC_FIRST_LINE, AT_LOC_FIRST_COLUMN);
|
||||||
if (AT_LOC.first_line != AT_LOC.last_line)
|
if (AT_LOC_FIRST_LINE != AT_LOC_LAST_LINE)
|
||||||
fprintf (stderr, "-%d.%d",
|
fprintf (stderr, "-%d.%d",
|
||||||
AT_LOC.last_line, AT_LOC.last_column - 1);
|
AT_LOC_LAST_LINE, AT_LOC_LAST_COLUMN - 1);
|
||||||
else if (AT_LOC.first_column != AT_LOC.last_column - 1)
|
else if (AT_LOC_FIRST_COLUMN != AT_LOC_LAST_COLUMN - 1)
|
||||||
fprintf (stderr, "-%d",
|
fprintf (stderr, "-%d",
|
||||||
AT_LOC.last_column - 1);
|
AT_LOC_LAST_COLUMN - 1);
|
||||||
fprintf (stderr, ": ");])
|
fprintf (stderr, ": ");])
|
||||||
fprintf (stderr, "%s\n", s);
|
fprintf (stderr, "%s\n", s);
|
||||||
}])[
|
}])[
|
||||||
|
|||||||
@@ -40,6 +40,25 @@ printf "$count\n";' $1], [0], [$3
|
|||||||
## Macros decoding Bison options. ##
|
## Macros decoding Bison options. ##
|
||||||
## ------------------------------- ##
|
## ------------------------------- ##
|
||||||
|
|
||||||
|
# AT_LOC_PUSHDEF(FIRST-LINE, FIRST-COLUMN, LAST-LINE, LAST-COLUMN)
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# Pushdef AT_LOC_(FIRST|LAST)_(LINE|COLUMN).
|
||||||
|
m4_define([AT_LOC_PUSHDEF],
|
||||||
|
[m4_pushdef([AT_LOC_FIRST_LINE], [AT_LOC.$1])
|
||||||
|
m4_pushdef([AT_LOC_FIRST_COLUMN], [AT_LOC.$2])
|
||||||
|
m4_pushdef([AT_LOC_LAST_LINE], [AT_LOC.$3])
|
||||||
|
m4_pushdef([AT_LOC_LAST_COLUMN], [AT_LOC.$4])])
|
||||||
|
|
||||||
|
# AT_LOC_POPDEF
|
||||||
|
# -------------
|
||||||
|
# Popdef AT_LOC_(FIRST|LAST)_(LINE|COL).
|
||||||
|
m4_define([AT_LOC_POPDEF],
|
||||||
|
[m4_popdef([AT_LOC_FIRST_LINE])
|
||||||
|
m4_popdef([AT_LOC_FIRST_COLUMN])
|
||||||
|
m4_popdef([AT_LOC_LAST_LINE])
|
||||||
|
m4_popdef([AT_LOC_LAST_COLUMN])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# AT_BISON_OPTION_PUSHDEFS([BISON-OPTIONS])
|
# AT_BISON_OPTION_PUSHDEFS([BISON-OPTIONS])
|
||||||
# -----------------------------------------
|
# -----------------------------------------
|
||||||
@@ -131,6 +150,16 @@ AT_PURE_LEX_IF(
|
|||||||
m4_pushdef([AT_LEX_PRE_FORMALS], [])
|
m4_pushdef([AT_LEX_PRE_FORMALS], [])
|
||||||
m4_pushdef([AT_LEX_PRE_ARGS], [])
|
m4_pushdef([AT_LEX_PRE_ARGS], [])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# Handle the different types of location components.
|
||||||
|
|
||||||
|
AT_SKEL_CC_IF(
|
||||||
|
[AT_LOCATION_TYPE_IF(
|
||||||
|
[AT_LOC_PUSHDEF([begin.l], [begin.c], [end.l], [end.c])],
|
||||||
|
[AT_LOC_PUSHDEF([begin.line], [begin.column], [end.line], [end.column])])],
|
||||||
|
[AT_LOC_PUSHDEF([first_line], [first_column], [last_line], [last_column])])
|
||||||
|
|
||||||
|
|
||||||
AT_GLR_IF([AT_KEYWORDS([glr])])
|
AT_GLR_IF([AT_KEYWORDS([glr])])
|
||||||
])# _AT_BISON_OPTION_PUSHDEFS
|
])# _AT_BISON_OPTION_PUSHDEFS
|
||||||
|
|
||||||
@@ -161,6 +190,7 @@ m4_popdef([AT_SKEL_CC_IF])
|
|||||||
m4_popdef([AT_GLR_CC_IF])
|
m4_popdef([AT_GLR_CC_IF])
|
||||||
m4_popdef([AT_LALR1_CC_IF])
|
m4_popdef([AT_LALR1_CC_IF])
|
||||||
m4_popdef([AT_DEFINES_IF])
|
m4_popdef([AT_DEFINES_IF])
|
||||||
|
AT_LOC_POPDEF
|
||||||
])# AT_BISON_OPTION_POPDEFS
|
])# AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user