tests: use the generalized default yylex.

* tests/actions.at, tests/glr-regression.at, tests/regression.at: here.
This commit is contained in:
Akim Demaille
2012-06-28 14:54:45 +02:00
parent 95361618de
commit 087dcd7868
3 changed files with 22 additions and 87 deletions

View File

@@ -1417,7 +1417,7 @@ AT_DATA_GRAMMAR([input.y],
# include <assert.h>
]AT_YYERROR_DECLARE[
static int yylex (YYSTYPE *yylval);
]AT_YYLEX_DECLARE[
}
%%
input:
@@ -1432,15 +1432,7 @@ exp:
%%
]AT_YYERROR_DEFINE[
static int
yylex (YYSTYPE *yylval)
{
static char const input[] = "bcd";
static size_t toknum;
assert (toknum < sizeof input);
*yylval = (toknum + 1) * 10;
return input[toknum++];
}
]AT_YYLEX_DEFINE(["bcd"], [*lvalp = (toknum + 1) * 10])[
int
main (void)

View File

@@ -998,16 +998,9 @@ merge (YYSTYPE s1, YYSTYPE s2)
}
]AT_YYERROR_DEFINE[
static int
yylex (void)
{
static int const input[] = { PARENT_RHS_AFTER, 0 };
static size_t toknum;
assert (toknum < sizeof input / sizeof *input);
if (input[toknum] == PARENT_RHS_AFTER)
parent_rhs_after_value = 1;
return input[toknum++];
}
]AT_YYLEX_DEFINE([{ PARENT_RHS_AFTER, 0 }],
[if (res == PARENT_RHS_AFTER)
parent_rhs_after_value = 1;])[
int
main (void)
@@ -1117,17 +1110,8 @@ change_lookahead:
%%
]AT_YYERROR_DEFINE[
static int
yylex (void)
{
static char const input[] = "ab";
static size_t toknum;
assert (toknum < sizeof input);
yylloc.first_line = yylloc.last_line = 1;
yylloc.first_column = yylloc.last_column = toknum + 1;
yylval.value = input[toknum] + 'A' - 'a';
return input[toknum++];
}
]AT_YYLEX_DEFINE(["ab"],
[yylval.value = res + 'A' - 'a'])[
static void
print_lookahead (char const *reduction)
@@ -1507,16 +1491,9 @@ alt2: ;
%%
]AT_YYERROR_DEFINE[
static int
yylex (void)
{
static char const input[] = "ab";
static size_t toknum;
assert (toknum < sizeof input);
if (input[toknum] == 'b')
lookahead_value = 1;
return input[toknum++];
}
]AT_YYLEX_DEFINE(["ab"],
[if (res == 'b')
lookahead_value = 1])[
int
main (void)

View File

@@ -463,15 +463,7 @@ AT_DATA_GRAMMAR([input.y],
exp: "a" "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!";
%%
]AT_YYERROR_DEFINE[
int
yylex (void)
{
static int called;
if (called++)
abort ();
return SPECIAL;
}
]AT_YYLEX_DEFINE([{ SPECIAL }])[
int
main (void)
@@ -846,13 +838,11 @@ AT_CLEANUP
# so that possible bound checking compilers could check all the skeletons.
m4_define([_AT_DATA_DANCER_Y],
[AT_DATA_GRAMMAR([dancer.y],
[%{
static int yylex (AT_LALR1_CC_IF([int *], [void]));
AT_LALR1_CC_IF([],
[#include <stdlib.h>
#include <stdio.h>
]AT_YYERROR_DECLARE[])
%}
[[%code provides
{
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
}
$1
%token ARROW INVALID NUMBER STRING DATA
%defines
@@ -897,7 +887,8 @@ member: STRING
| INVALID
;
%%
AT_YYERROR_DEFINE[
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE([":"])[
]AT_LALR1_CC_IF(
[int
yyparse ()
@@ -908,28 +899,14 @@ yyparse ()
#endif
return parser.parse ();
}
])
#include <assert.h>
static int
yylex (AT_LALR1_CC_IF([int *lval], [void]))
[{
static int const tokens[] =
{
':', -1
};
static size_t toknum;
]AT_LALR1_CC_IF([*lval = 0; /* Pacify GCC. */])[
assert (toknum < sizeof tokens / sizeof *tokens);
return tokens[toknum++];
}]
])[
int
main (void)
{
return yyparse ();
}
])
]])
])# _AT_DATA_DANCER_Y
@@ -1071,13 +1048,8 @@ start:
%printer { fprintf (yyoutput, "PRINTER"); } 'a';
%%
]AT_YYERROR_DEFINE[
static int
yylex (void)
{
return 'a';
}
]AT_YYLEX_DEFINE(["a"])[
int
main (void)
@@ -1210,13 +1182,7 @@ sr_conflict:
%%
]AT_YYERROR_DEFINE[
int
yylex (void)
{
static int const input[] = { 1, 2, 3, 0 };
static int const *inputp = input;
return *inputp++;
}
]AT_YYLEX_DEFINE([{ 1, 2, 3, 0 }])[
int
main (void)