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

View File

@@ -998,16 +998,9 @@ merge (YYSTYPE s1, YYSTYPE s2)
} }
]AT_YYERROR_DEFINE[ ]AT_YYERROR_DEFINE[
static int ]AT_YYLEX_DEFINE([{ PARENT_RHS_AFTER, 0 }],
yylex (void) [if (res == PARENT_RHS_AFTER)
{ parent_rhs_after_value = 1;])[
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++];
}
int int
main (void) main (void)
@@ -1117,17 +1110,8 @@ change_lookahead:
%% %%
]AT_YYERROR_DEFINE[ ]AT_YYERROR_DEFINE[
static int ]AT_YYLEX_DEFINE(["ab"],
yylex (void) [yylval.value = res + 'A' - 'a'])[
{
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++];
}
static void static void
print_lookahead (char const *reduction) print_lookahead (char const *reduction)
@@ -1507,16 +1491,9 @@ alt2: ;
%% %%
]AT_YYERROR_DEFINE[ ]AT_YYERROR_DEFINE[
static int ]AT_YYLEX_DEFINE(["ab"],
yylex (void) [if (res == 'b')
{ lookahead_value = 1])[
static char const input[] = "ab";
static size_t toknum;
assert (toknum < sizeof input);
if (input[toknum] == 'b')
lookahead_value = 1;
return input[toknum++];
}
int int
main (void) 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??!"; exp: "a" "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!";
%% %%
]AT_YYERROR_DEFINE[ ]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE([{ SPECIAL }])[
int
yylex (void)
{
static int called;
if (called++)
abort ();
return SPECIAL;
}
int int
main (void) main (void)
@@ -846,13 +838,11 @@ AT_CLEANUP
# so that possible bound checking compilers could check all the skeletons. # so that possible bound checking compilers could check all the skeletons.
m4_define([_AT_DATA_DANCER_Y], m4_define([_AT_DATA_DANCER_Y],
[AT_DATA_GRAMMAR([dancer.y], [AT_DATA_GRAMMAR([dancer.y],
[%{ [[%code provides
static int yylex (AT_LALR1_CC_IF([int *], [void])); {
AT_LALR1_CC_IF([], ]AT_YYERROR_DECLARE[
[#include <stdlib.h> ]AT_YYLEX_DECLARE[
#include <stdio.h> }
]AT_YYERROR_DECLARE[])
%}
$1 $1
%token ARROW INVALID NUMBER STRING DATA %token ARROW INVALID NUMBER STRING DATA
%defines %defines
@@ -897,7 +887,8 @@ member: STRING
| INVALID | INVALID
; ;
%% %%
AT_YYERROR_DEFINE[ ]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE([":"])[
]AT_LALR1_CC_IF( ]AT_LALR1_CC_IF(
[int [int
yyparse () yyparse ()
@@ -908,28 +899,14 @@ yyparse ()
#endif #endif
return parser.parse (); 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 int
main (void) main (void)
{ {
return yyparse (); return yyparse ();
} }
]) ]])
])# _AT_DATA_DANCER_Y ])# _AT_DATA_DANCER_Y
@@ -1071,13 +1048,8 @@ start:
%printer { fprintf (yyoutput, "PRINTER"); } 'a'; %printer { fprintf (yyoutput, "PRINTER"); } 'a';
%% %%
]AT_YYERROR_DEFINE[ ]AT_YYERROR_DEFINE[
static int ]AT_YYLEX_DEFINE(["a"])[
yylex (void)
{
return 'a';
}
int int
main (void) main (void)
@@ -1210,13 +1182,7 @@ sr_conflict:
%% %%
]AT_YYERROR_DEFINE[ ]AT_YYERROR_DEFINE[
int ]AT_YYLEX_DEFINE([{ 1, 2, 3, 0 }])[
yylex (void)
{
static int const input[] = { 1, 2, 3, 0 };
static int const *inputp = input;
return *inputp++;
}
int int
main (void) main (void)