lalr1.cc: also handle syntax_error when calling yylex.

* data/lalr1.cc (parse): Catch syntax_error around yylex and
	forward them to errlab1.
	* tests/c++.at (Syntax error as exception): Check support for
	syntax exceptions raised by the scanner.
	* NEWS, doc/bison.texinfo: Document it.
This commit is contained in:
Akim Demaille
2011-06-30 14:10:21 +02:00
parent 199a2d6d72
commit a6552c5d2a
4 changed files with 39 additions and 7 deletions

View File

@@ -492,9 +492,12 @@ item:
int
yylex (yy::parser::semantic_type *)
{
static char const *input = "as";
// 's': syntax error, 'l': lexical error.
static char const *input = "asal";
switch (int res = *input++)
{
case 'l':
throw yy::parser::syntax_error("invalid character");
default:
return res;
}
@@ -520,6 +523,8 @@ AT_COMPILE_CXX([[input]])
AT_PARSER_CHECK([[./input]], [[0]], [[]],
[[error: invalid expression
caught error
error: invalid character
caught error
]])
AT_CLEANUP