tests: fixes

* tests/c++.at: Use AT_YYLEX_PROTOTYPE etc.
Which requires that we use the same argument names (lvalp, etc.).
* tests/local.at (AT_NAME_PREFIX): Fix regex.
This commit is contained in:
Akim Demaille
2018-12-23 09:53:57 +01:00
parent 0978148763
commit 777b0163de
2 changed files with 15 additions and 19 deletions

View File

@@ -134,7 +134,7 @@ AT_DATA_GRAMMAR([list.y],
} <std::vector<int>> } <std::vector<int>>
%code requires { #include <vector> } %code requires { #include <vector> }
%code { int yylex (yy::parser::semantic_type* yylval); } %code { int yylex (yy::parser::semantic_type* lvalp); }
%% %%
exp: "int" { $$.push_back ($1); } exp: "int" { $$.push_back ($1); }
@@ -335,10 +335,8 @@ AT_DATA_GRAMMAR([list.y],
{ {
namespace yy namespace yy
{ {
static]AT_TOKEN_CTOR_IF([[ static
parser::symbol_type yylex ()]], [[ ]AT_YYLEX_PROTOTYPE[;
parser::token_type yylex (parser::semantic_type* yylval]AT_LOCATION_IF([,
parser::location_type* yylloc])[)]])[;
// Conversion to string. // Conversion to string.
template <typename T> template <typename T>
@@ -394,10 +392,8 @@ item:
#define STAGE_MAX 5 #define STAGE_MAX 5
namespace yy namespace yy
{ {
static]AT_TOKEN_CTOR_IF([[ static
parser::symbol_type yylex ()]], [[ ]AT_YYLEX_PROTOTYPE[
parser::token_type yylex (parser::semantic_type* yylval]AT_LOCATION_IF([,
parser::location_type* yylloc])[)]])[
{]AT_LOCATION_IF([ {]AT_LOCATION_IF([
typedef parser::location_type location;])[ typedef parser::location_type location;])[
// The 5 is a syntax error whose recovery requires that we discard // The 5 is a syntax error whose recovery requires that we discard
@@ -409,13 +405,13 @@ namespace yy
case 0:]AT_TOKEN_CTOR_IF([[ case 0:]AT_TOKEN_CTOR_IF([[
return parser::make_END_OF_FILE (]AT_LOCATION_IF([location ()])[);]], return parser::make_END_OF_FILE (]AT_LOCATION_IF([location ()])[);]],
[AT_LOCATION_IF([ [AT_LOCATION_IF([
*yylloc = location ();])[ *llocp = location ();])[
return parser::token::END_OF_FILE;]])[ return parser::token::END_OF_FILE;]])[
case ',':]AT_TOKEN_CTOR_IF([[ case ',':]AT_TOKEN_CTOR_IF([[
return parser::make_COMMA (]AT_LOCATION_IF([location ()])[);]], return parser::make_COMMA (]AT_LOCATION_IF([location ()])[);]],
[AT_LOCATION_IF([ [AT_LOCATION_IF([
*yylloc = location ();])[ *llocp = location ();])[
return parser::token::COMMA;]])[ return parser::token::COMMA;]])[
default: default:
@@ -423,15 +419,15 @@ namespace yy
if (stage % 2) if (stage % 2)
{]AT_TOKEN_CTOR_IF([[ {]AT_TOKEN_CTOR_IF([[
return parser::make_NUMBER (stage]AT_LOCATION_IF([, location ()])[);]], [[ return parser::make_NUMBER (stage]AT_LOCATION_IF([, location ()])[);]], [[
yylval->BUILD (int, stage);]AT_LOCATION_IF([ lvalp->BUILD (int, stage);]AT_LOCATION_IF([
*yylloc = location ();])[ *llocp = location ();])[
return parser::token::NUMBER;]])[ return parser::token::NUMBER;]])[
} }
else else
{]AT_TOKEN_CTOR_IF([[ {]AT_TOKEN_CTOR_IF([[
return parser::make_TEXT (to_string (stage)]AT_LOCATION_IF([, location ()])[);]], [[ return parser::make_TEXT (to_string (stage)]AT_LOCATION_IF([, location ()])[);]], [[
yylval->BUILD (string, to_string (stage));]AT_LOCATION_IF([ lvalp->BUILD (string, to_string (stage));]AT_LOCATION_IF([
*yylloc = location ();])[ *llocp = location ();])[
return parser::token::TEXT;]])[ return parser::token::TEXT;]])[
} }
} }
@@ -1305,7 +1301,7 @@ AT_DATA_GRAMMAR([input.yy], [
%code %code
{ {
int yylex (yy::parser::semantic_type *yylval); int yylex (yy::parser::semantic_type *lvalp);
} }
%% %%
@@ -1313,12 +1309,12 @@ exp: ZERO
%% %%
int yylex (yy::parser::semantic_type *yylval) int yylex (yy::parser::semantic_type *lvalp)
{ {
// Note: this argument is unused, but named on purpose. There used to be a // Note: this argument is unused, but named on purpose. There used to be a
// bug with a macro that erroneously expanded this identifier to // bug with a macro that erroneously expanded this identifier to
// yystackp->yyval. // yystackp->yyval.
YYUSE (yylval); YYUSE (lvalp);
return yy::parser::token::ZERO; return yy::parser::token::ZERO;
} }

View File

@@ -186,7 +186,7 @@ m4_pushdef([AT_PUSH_IF],
[m4_bmatch([$3], [%define api.push-pull \(both\|pull\)], [$1], [$2])]) [m4_bmatch([$3], [%define api.push-pull \(both\|pull\)], [$1], [$2])])
# AT_NAME_PREFIX. # AT_NAME_PREFIX.
m4_pushdef([AT_NAME_PREFIX], m4_pushdef([AT_NAME_PREFIX],
[m4_bmatch([$3], [\(%define api\.\|prefix\|%name-prefix\) .*], [m4_bmatch([$3], [\(%define api\.prefix\|%name-prefix\) .*],
[m4_bregexp([$3], [m4_bregexp([$3],
[\(%define api\.prefix\|%name-prefix\) [\{\"]\([^\"\}]*\)[\"\}]], [\(%define api\.prefix\|%name-prefix\) [\{\"]\([^\"\}]*\)[\"\}]],
[\2])], [\2])],