mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-12 22:03:02 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user