# Bison Regressions. -*- Autotest -*-
-# Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+
+# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 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
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
AT_BANNER([[Regression tests.]])
AT_CLEANUP
+AT_SETUP([Invalid inputs with {}])
+
+AT_DATA([input.y],
+[[
+%destructor
+%initial-action
+%lex-param
+%parse-param
+%printer
+%union
+]])
+
+AT_CHECK([bison input.y], [1], [],
+[[input.y:3.1: missing `{' in "%destructor {...}"
+input.y:4.1: missing `{' in "%initial-action {...}"
+input.y:4.1: syntax error, unexpected %initial-action {...}, expecting string or identifier
+]])
+
+AT_CLEANUP
+
+
## ------------------- ##
## Token definitions. ##
# Bison managed, when fed with `%token 'f' "f"' to #define 'f'!
AT_DATA_GRAMMAR([input.y],
[%{
+#include <stdio.h>
void yyerror (const char *s);
int yylex (void);
%}
-[%token MYEOF 0 "end of file"
+[%error-verbose
+%token MYEOF 0 "end of file"
%token 'a' "a"
-%token b "b"
-%token c 'c'
-%token 'd' d
+%token B_TOKEN "b"
+%token C_TOKEN 'c'
+%token 'd' D_TOKEN
+%token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
%%
-exp: "a";
+exp: "a" "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!";
+%%
+void
+yyerror (char const *s)
+{
+ fprintf (stderr, "%s\n", s);
+}
+
+int
+yylex (void)
+{
+ return SPECIAL;
+}
+
+int
+main (void)
+{
+ return yyparse ();
+}
]])
AT_CHECK([bison -o input.c input.y])
-AT_COMPILE([input.o], [-c input.c])
+AT_COMPILE([input])
+AT_DATA([experr],
+[[syntax error, unexpected "\\'?\"\a\b\f\n\r\t\v\001\201\001\201?\?!", expecting a
+]])
+AT_PARSER_CHECK([./input], 1, [], [experr])
AT_CLEANUP
#
# It used to be wrong on yydefact only:
#
-# static const short int yydefact[] =
+# static const yytype_uint8 yydefact[] =
# {
# - 2, 0, 1, 0, 0, 2, 3, 2, 5, 4,
# + 2, 0, 1, 0, 0, 0, 3, 2, 5, 4,
[sed -n 's/ *$//;/^static const.*\[\] =/,/^}/p' input.c >tables.c]
AT_CHECK([[cat tables.c]], 0,
-[[static const unsigned char yytranslate[] =
+[[static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6
};
-static const unsigned char yyprhs[] =
+static const yytype_uint8 yyprhs[] =
{
0, 0, 3, 5, 6, 9, 14
};
-static const yysigned_char yyrhs[] =
+static const yytype_int8 yyrhs[] =
{
8, 0, -1, 9, -1, -1, 10, 11, -1, 3,
4, 5, 8, -1, 6, 8, -1
};
-static const unsigned char yyrline[] =
+static const yytype_uint8 yyrline[] =
{
0, 2, 2, 3, 3, 4, 5
};
"$end", "error", "$undefined", "\"if\"", "\"const\"", "\"then\"",
"\"else\"", "$accept", "statement", "struct_stat", "if", "else", 0
};
-static const unsigned short int yytoknum[] =
+static const yytype_uint16 yytoknum[] =
{
0, 256, 257, 258, 259, 260, 261
};
-static const unsigned char yyr1[] =
+static const yytype_uint8 yyr1[] =
{
0, 7, 8, 9, 9, 10, 11
};
-static const unsigned char yyr2[] =
+static const yytype_uint8 yyr2[] =
{
0, 2, 1, 0, 2, 4, 2
};
-static const unsigned char yydefact[] =
+static const yytype_uint8 yydefact[] =
{
3, 0, 0, 2, 0, 0, 1, 3, 4, 3,
6, 5
};
-static const yysigned_char yydefgoto[] =
+static const yytype_int8 yydefgoto[] =
{
-1, 2, 3, 4, 8
};
-static const yysigned_char yypact[] =
+static const yytype_int8 yypact[] =
{
-2, -1, 4, -8, 0, 2, -8, -2, -8, -2,
-8, -8
};
-static const yysigned_char yypgoto[] =
+static const yytype_int8 yypgoto[] =
{
-8, -7, -8, -8, -8
};
-static const unsigned char yytable[] =
+static const yytype_uint8 yytable[] =
{
10, 1, 11, 5, 6, 0, 7, 9
};
-static const yysigned_char yycheck[] =
+static const yytype_int8 yycheck[] =
{
7, 3, 9, 4, 0, -1, 6, 5
};
-static const unsigned char yystos[] =
+static const yytype_uint8 yystos[] =
{
0, 3, 8, 9, 10, 4, 0, 6, 11, 5,
8, 8
AT_LALR1_CC_IF(
[/* A C++ error reporting function. */
void
-yy::Parser::error (const Location&, const std::string& m)
+yy::parser::error (const location&, const std::string& m)
{
std::cerr << m << std::endl;
}
int
-yyparse (void)
+yyparse ()
{
- yy::Parser parser;
+ yy::parser parser;
parser.set_debug_level (!!YYDEBUG);
return parser.parse ();
}