Write a test the yycheck overrun reported by Andrew Suffield.

* tests/regression.at (_AT_DATA_DANCER_Y, AT_CHECK_DANCER): New.
Use them to exercise yycheck overrun.
Based on Andrew Suffield's grammar.
This commit is contained in:
Akim Demaille
2003-03-02 11:22:19 +00:00
parent 67a25fed4c
commit 22e304a6da
3 changed files with 143 additions and 1 deletions

View File

@@ -1,3 +1,11 @@
2003-03-02 Akim Demaille <akim@epita.fr>
Write a test the yycheck overrun reported by Andrew Suffield.
* tests/regression.at (_AT_DATA_DANCER_Y, AT_CHECK_DANCER): New.
Use them to exercise yycheck overrun.
Based on Andrew Suffield's grammar.
2003-03-02 Akim Demaille <akim@epita.fr>
Create tests/local.at for Bison generic testing macros.

1
THANKS
View File

@@ -6,6 +6,7 @@ Akim Demaille akim@freefriends.org
Albert Chin-A-Young china@thewrittenword.com
Alexander Belopolsky alexb@rentec.com
Andreas Schwab schwab@suse.de
Andrew Suffield asuffield@users.sourceforge.net
Arnold Robbins arnold@skeeve.com
Art Haas ahaas@neosoft.com
Benoit Perrot benoit.perrot@epita.fr

View File

@@ -1,5 +1,5 @@
# Bison Regressions. -*- Autotest -*-
# Copyright (C) 2001, 2002 Free Software Foundation, Inc.
# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -660,3 +660,136 @@ static const unsigned char yystos[] =
]])
AT_CLEANUP
## ------------------------- ##
## yycheck Bound Violation. ##
## ------------------------- ##
# _AT_DATA_DANCER_Y(BISON-OPTIONS)
# --------------------------------
# The following grammar, taken from Andrew Suffield's GPL'd implementation
# of DGMTP, the Dancer Generic Message Transport Protocol, used to violate
# yycheck's bounds where issuing a verbose error message. Keep this test
# so that possible bound checking compilers could check all the skeletons.
m4_define([_AT_DATA_DANCER_Y],
[AT_DATA_GRAMMAR([dancer.y],
[%{
AT_LALR1_CC_IF(
[static int yylex (int *lval);],
[#include <stdio.h>
static void yyerror (const char *s);
static int yylex ();])
%}
$1
%token ARROW INVALID NUMBER STRING DATA
%defines
%verbose
%error-verbose
/* Grammar follows */
%%
line: header body
;
header: '<' from ARROW to '>' type ':'
| '<' ARROW to '>' type ':'
| ARROW to type ':'
| type ':'
| '<' '>'
;
from: DATA
| STRING
| INVALID
;
to: DATA
| STRING
| INVALID
;
type: DATA
| STRING
| INVALID
;
body: /* empty */
| body member
;
member: STRING
| DATA
| '+' NUMBER
| '-' NUMBER
| NUMBER
| INVALID
;
%%
AT_LALR1_CC_IF(
[/* Currently, print_ is required in C++. */
void
yy::Parser::print_ ()
{
}
/* A C++ error reporting function. */
void
yy::Parser::error_ ()
{
std::cerr << message << std::endl;
}
int
yyparse (void)
{
yy::Parser parser (!!YYDEBUG);
return parser.parse ();
}
],
[static void
yyerror (const char *s)
{
fprintf (stderr, "%s\n", s);
}])
static int
yylex (AT_LALR1_CC_IF([int *lval]))
[{
static int toknum = 0;
int tokens[] =
{
':', -1
};
return tokens[toknum++];
}]
int
main (void)
{
return yyparse ();
}
])
])# _AT_DATA_DANCER_Y
# AT_CHECK_DANCER(BISON-OPTIONS)
# ------------------------------
# Generate the grammar, compile it, run it.
m4_define([AT_CHECK_DANCER],
[AT_SETUP([Dancer $1])
AT_BISON_OPTION_PUSHDEFS([$1])
_AT_DATA_DANCER_Y([$1])
AT_CHECK([bison -o dancer.c dancer.y])
AT_LALR1_CC_IF([AT_COMPILE_CXX([dancer])],
[AT_COMPILE([dancer])])
AT_PARSER_CHECK([./dancer], 1, [],
[syntax error, unexpected ':', expecting ARROW or INVALID or DATA or '<'
])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
])
AT_CHECK_DANCER()
AT_CHECK_DANCER([%glr-parser])
AT_CHECK_DANCER([%skeleton "lalr1.cc"])