mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 01:33:03 +00:00
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:
@@ -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>
|
2003-03-02 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
Create tests/local.at for Bison generic testing macros.
|
Create tests/local.at for Bison generic testing macros.
|
||||||
|
|||||||
1
THANKS
1
THANKS
@@ -6,6 +6,7 @@ Akim Demaille akim@freefriends.org
|
|||||||
Albert Chin-A-Young china@thewrittenword.com
|
Albert Chin-A-Young china@thewrittenword.com
|
||||||
Alexander Belopolsky alexb@rentec.com
|
Alexander Belopolsky alexb@rentec.com
|
||||||
Andreas Schwab schwab@suse.de
|
Andreas Schwab schwab@suse.de
|
||||||
|
Andrew Suffield asuffield@users.sourceforge.net
|
||||||
Arnold Robbins arnold@skeeve.com
|
Arnold Robbins arnold@skeeve.com
|
||||||
Art Haas ahaas@neosoft.com
|
Art Haas ahaas@neosoft.com
|
||||||
Benoit Perrot benoit.perrot@epita.fr
|
Benoit Perrot benoit.perrot@epita.fr
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Bison Regressions. -*- Autotest -*-
|
# 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
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -660,3 +660,136 @@ static const unsigned char yystos[] =
|
|||||||
]])
|
]])
|
||||||
|
|
||||||
AT_CLEANUP
|
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"])
|
||||||
|
|||||||
Reference in New Issue
Block a user