mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 17:53:02 +00:00
tests: factor.
* tests/glr-regression.at, tests/output.at, tests/push.at, * tests/regression.at, tests/torture.at, tests/actions.at: Use AT_YYLEX_* and AT_YYERROR_*.
This commit is contained in:
@@ -150,14 +150,8 @@ two: { $$.val = 2; } ;
|
|||||||
sum: { printf ("%d\n", $0.val + $-1.val + $-2.val); } ;
|
sum: { printf ("%d\n", $0.val + $-1.val + $-2.val); } ;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
]AT_YYERROR_DEFINE[
|
]AT_YYERROR_DEFINE[
|
||||||
|
]AT_YYLEX_DEFINE()[
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ AT_DATA_GRAMMAR([glr-regr1.y],
|
|||||||
|
|
||||||
#define YYSTYPE int
|
#define YYSTYPE int
|
||||||
static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1);
|
static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1);
|
||||||
]AT_YYLEX_DECLARE[
|
|
||||||
]AT_YYERROR_DECLARE[
|
]AT_YYERROR_DECLARE[
|
||||||
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
@@ -128,8 +128,8 @@ AT_DATA_GRAMMAR([glr-regr2a.y],
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
]AT_YYLEX_DECLARE[
|
|
||||||
]AT_YYERROR_DECLARE[
|
]AT_YYERROR_DECLARE[
|
||||||
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%glr-parser
|
%glr-parser
|
||||||
@@ -519,18 +519,8 @@ AT_DATA_GRAMMAR([glr-regr6.y],
|
|||||||
start: 'a' | 'a' ;
|
start: 'a' | 'a' ;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static char const input[] = "a";
|
|
||||||
static size_t toknum;
|
|
||||||
if (! (toknum < sizeof input))
|
|
||||||
abort ();
|
|
||||||
return input[toknum++];
|
|
||||||
}
|
|
||||||
|
|
||||||
]AT_YYERROR_DEFINE[
|
]AT_YYERROR_DEFINE[
|
||||||
|
]AT_YYLEX_DEFINE(a)[
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -657,7 +647,6 @@ AT_DATA_GRAMMAR([glr-regr8.y],
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
]AT_YYERROR_DECLARE[
|
]AT_YYERROR_DECLARE[
|
||||||
]AT_YYLEX_DECLARE[
|
]AT_YYLEX_DECLARE[
|
||||||
]AT_YYERROR_DECLARE[
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%token T_CONSTANT
|
%token T_CONSTANT
|
||||||
@@ -845,16 +834,8 @@ start:
|
|||||||
;
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
]AT_YYERROR_DEFINE[
|
]AT_YYERROR_DEFINE[
|
||||||
static int
|
]AT_YYLEX_DEFINE()[
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static int called;
|
|
||||||
if (called++)
|
|
||||||
abort ();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -1468,16 +1449,8 @@ ambiguity1: ;
|
|||||||
ambiguity2: ;
|
ambiguity2: ;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
]AT_YYERROR_DEFINE[
|
]AT_YYERROR_DEFINE[
|
||||||
static int
|
]AT_YYLEX_DEFINE()[
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static int called;
|
|
||||||
if (called++)
|
|
||||||
abort ();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -1675,7 +1648,7 @@ AT_DATA_GRAMMAR([glr-regr18.y],
|
|||||||
%{
|
%{
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
]AT_YYERROR_DECLARE[
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex ();
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%union {
|
%union {
|
||||||
@@ -1695,7 +1668,6 @@ sym3: %merge<merge> { $$ = 0; } ;
|
|||||||
%type <type3> sym3;
|
%type <type3> sym3;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
]AT_YYERROR_DEFINE[
|
]AT_YYERROR_DEFINE[
|
||||||
]AT_YYLEX_DEFINE()[
|
]AT_YYLEX_DEFINE()[
|
||||||
int
|
int
|
||||||
|
|||||||
@@ -176,10 +176,11 @@ AT_CHECK_CONFLICTING_OUTPUT([foo.y], [], [-o foo.y],
|
|||||||
|
|
||||||
|
|
||||||
# AT_CHECK_OUTPUT_FILE_NAME(FILE-NAME-PREFIX, [ADDITIONAL-TESTS])
|
# AT_CHECK_OUTPUT_FILE_NAME(FILE-NAME-PREFIX, [ADDITIONAL-TESTS])
|
||||||
# -----------------------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
m4_define([AT_CHECK_OUTPUT_FILE_NAME],
|
m4_define([AT_CHECK_OUTPUT_FILE_NAME],
|
||||||
[AT_SETUP([Output file name: $1])
|
[AT_SETUP([Output file name: $1])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
# Skip if platform doesn't support file name. For example, Cygwin
|
# Skip if platform doesn't support file name. For example, Cygwin
|
||||||
# doesn't support file names containing ":" or "\".
|
# doesn't support file names containing ":" or "\".
|
||||||
AT_CHECK([[touch "]AS_ESCAPE([$1[.tmp]])[" || exit 77]])
|
AT_CHECK([[touch "]AS_ESCAPE([$1[.tmp]])[" || exit 77]])
|
||||||
@@ -187,8 +188,8 @@ AT_CHECK([[touch "]AS_ESCAPE([$1[.tmp]])[" || exit 77]])
|
|||||||
AT_DATA_GRAMMAR([glr.y],
|
AT_DATA_GRAMMAR([glr.y],
|
||||||
[[%glr-parser
|
[[%glr-parser
|
||||||
%code {
|
%code {
|
||||||
int yylex (void);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
void yyerror (const char *);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
}
|
}
|
||||||
%%
|
%%
|
||||||
start: {};
|
start: {};
|
||||||
@@ -209,6 +210,7 @@ AT_CHECK([ls "AS_ESCAPE([$1.c])" "AS_ESCAPE([$1.h])"], [], [ignore])
|
|||||||
AT_COMPILE_CXX([cxx.o], [-c "AS_ESCAPE([$1.c])"])
|
AT_COMPILE_CXX([cxx.o], [-c "AS_ESCAPE([$1.c])"])
|
||||||
$2
|
$2
|
||||||
|
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|||||||
@@ -24,17 +24,18 @@ AT_BANNER([[Push Parsing Tests]])
|
|||||||
AT_SETUP([[Memory Leak for Early Deletion]])
|
AT_SETUP([[Memory Leak for Early Deletion]])
|
||||||
|
|
||||||
# Requires Valgrind.
|
# Requires Valgrind.
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([[input.y]],
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define YYINITDEPTH 1
|
#define YYINITDEPTH 1
|
||||||
void yyerror (char const *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%define api.pure %define api.push-pull push
|
%define api.pure
|
||||||
|
%define api.push-pull push
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
@@ -42,11 +43,7 @@ start: 'a' 'b' 'c' ;
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -71,6 +68,7 @@ main (void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o input.c input.y]])
|
AT_BISON_CHECK([[-o input.c input.y]])
|
||||||
AT_COMPILE([[input]])
|
AT_COMPILE([[input]])
|
||||||
@@ -85,13 +83,14 @@ AT_CLEANUP
|
|||||||
AT_SETUP([[Multiple impure instances]])
|
AT_SETUP([[Multiple impure instances]])
|
||||||
|
|
||||||
m4_pushdef([AT_MULTIPLE_IMPURE_INSTANCES_CHECK], [
|
m4_pushdef([AT_MULTIPLE_IMPURE_INSTANCES_CHECK], [
|
||||||
|
AT_BISON_OPTION_PUSHDEFS([%define api.push-pull $1])
|
||||||
AT_DATA_GRAMMAR([[input.y]],
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (char const *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]m4_if([$1], [[both]], [AT_YYLEX_DECLARE([])])[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%define api.push-pull ]$1[
|
%define api.push-pull ]$1[
|
||||||
@@ -101,28 +100,16 @@ AT_DATA_GRAMMAR([[input.y]],
|
|||||||
start: ;
|
start: ;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
void
|
]m4_if([$1], [[both]], [AT_YYLEX_DEFINE([])])[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
yypstate *ps;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 2; ++i)
|
for (i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
ps = yypstate_new ();
|
yypstate *ps = yypstate_new ();
|
||||||
assert (ps);
|
assert (ps);
|
||||||
assert (yypstate_new () == YY_NULL);
|
assert (yypstate_new () == YY_NULL);
|
||||||
]m4_if([$1], [[both]], [[assert (yyparse () == 2)]])[;
|
]m4_if([$1], [[both]], [[assert (yyparse () == 2)]])[;
|
||||||
@@ -140,6 +127,7 @@ main (void)
|
|||||||
AT_BISON_CHECK([[-o input.c input.y]])
|
AT_BISON_CHECK([[-o input.c input.y]])
|
||||||
AT_COMPILE([[input]])
|
AT_COMPILE([[input]])
|
||||||
AT_PARSER_CHECK([[./input]])
|
AT_PARSER_CHECK([[./input]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
])
|
])
|
||||||
|
|
||||||
AT_MULTIPLE_IMPURE_INSTANCES_CHECK([[both]])
|
AT_MULTIPLE_IMPURE_INSTANCES_CHECK([[both]])
|
||||||
@@ -155,12 +143,14 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([[Unsupported Skeletons]])
|
AT_SETUP([[Unsupported Skeletons]])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA([[input.y]],
|
AT_DATA([[input.y]],
|
||||||
[[%glr-parser
|
[[%glr-parser
|
||||||
%define api.push-pull push
|
%define api.push-pull push
|
||||||
%%
|
%%
|
||||||
start: ;
|
start: ;
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[input.y]], [[1]], [],
|
AT_BISON_CHECK([[input.y]], [[1]], [],
|
||||||
[[input.y:2.9-21: %define variable 'api.push-pull' is not used
|
[[input.y:2.9-21: %define variable 'api.push-pull' is not used
|
||||||
|
|||||||
@@ -462,11 +462,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??!";
|
||||||
%%
|
%%
|
||||||
void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *s)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", s);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
@@ -901,15 +897,9 @@ member: STRING
|
|||||||
| INVALID
|
| INVALID
|
||||||
;
|
;
|
||||||
%%
|
%%
|
||||||
AT_LALR1_CC_IF(
|
AT_YYERROR_DEFINE[
|
||||||
[/* A C++ error reporting function. */
|
]AT_LALR1_CC_IF(
|
||||||
void
|
[int
|
||||||
yy::parser::error (const location&, const std::string& m)
|
|
||||||
{
|
|
||||||
std::cerr << m << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
yyparse ()
|
yyparse ()
|
||||||
{
|
{
|
||||||
yy::parser parser;
|
yy::parser parser;
|
||||||
@@ -918,12 +908,7 @@ yyparse ()
|
|||||||
#endif
|
#endif
|
||||||
return parser.parse ();
|
return parser.parse ();
|
||||||
}
|
}
|
||||||
],
|
])
|
||||||
[static void
|
|
||||||
yyerror (const char *s)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", s);
|
|
||||||
}])
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
yylex (AT_LALR1_CC_IF([int *lval], [void]))
|
yylex (AT_LALR1_CC_IF([int *lval], [void]))
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ print <<EOF;
|
|||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#define MAX $max
|
||||||
]AT_YYLEX_DECLARE[
|
]AT_YYLEX_DECLARE[
|
||||||
]AT_YYERROR_DECLARE[
|
]AT_YYERROR_DECLARE[
|
||||||
%}
|
%}
|
||||||
@@ -96,14 +96,15 @@ for my $size (1 .. $max)
|
|||||||
};
|
};
|
||||||
print ";\n";
|
print ";\n";
|
||||||
|
|
||||||
print <<EOF;
|
print <<\EOF;
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
static int inner = 1;
|
static int inner = 1;
|
||||||
static int outer = 0;
|
static int outer = 0;
|
||||||
if (outer > $max)
|
if (outer > MAX)
|
||||||
return 0;
|
return 0;
|
||||||
else if (inner > outer)
|
else if (inner > outer)
|
||||||
{
|
{
|
||||||
@@ -113,13 +114,6 @@ yylex (void)
|
|||||||
}
|
}
|
||||||
return inner++;
|
return inner++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -173,7 +167,7 @@ print <<EOF;
|
|||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#define MAX $max
|
||||||
]AT_YYLEX_DECLARE[
|
]AT_YYLEX_DECLARE[
|
||||||
]AT_YYERROR_DECLARE[
|
]AT_YYERROR_DECLARE[
|
||||||
%}
|
%}
|
||||||
@@ -196,25 +190,20 @@ print
|
|||||||
(map { "\"$_\"" } (1 .. $max)), ";"),
|
(map { "\"$_\"" } (1 .. $max)), ";"),
|
||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
print <<EOF;
|
print <<\EOF;
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
static int counter = 1;
|
static int counter = 1;
|
||||||
if (counter <= $max)
|
if (counter <= MAX)
|
||||||
return counter++;
|
return counter++;
|
||||||
if (counter++ != $max + 1)
|
if (counter++ != MAX + 1)
|
||||||
abort ();
|
abort ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -282,7 +271,7 @@ print <<EOF;
|
|||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# include <assert.h>
|
# include <assert.h>
|
||||||
|
# define MAX $max
|
||||||
]AT_YYLEX_DECLARE[
|
]AT_YYLEX_DECLARE[
|
||||||
]AT_YYERROR_DECLARE[
|
]AT_YYERROR_DECLARE[
|
||||||
%}
|
%}
|
||||||
@@ -329,16 +318,17 @@ for my $count (1 .. $max)
|
|||||||
print "n$count: token { \$\$ = $count; };\n";
|
print "n$count: token { \$\$ = $count; };\n";
|
||||||
};
|
};
|
||||||
|
|
||||||
print <<EOF;
|
print <<\EOF;
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
static int return_token = 1;
|
static int return_token = 1;
|
||||||
static int counter = 1;
|
static int counter = 1;
|
||||||
if (counter > $max)
|
if (counter > MAX)
|
||||||
{
|
{
|
||||||
if (counter++ != $max + 1)
|
if (counter++ != MAX + 1)
|
||||||
abort ();
|
abort ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -351,12 +341,6 @@ yylex (void)
|
|||||||
return counter++;
|
return counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user