mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
* tests/calc.at (AT_CHECK_CALC): Check different scenarios of
error recovery, mixing with/without pops and discarding of the lookahead. Exercise YYERROR. Disable the lalr1.cc tests as currently it doesn't support YYERROR.
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
2003-02-19 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* tests/calc.at (AT_CHECK_CALC): Check different scenarios of
|
||||
error recovery, mixing with/without pops and discarding of the
|
||||
lookahead.
|
||||
Exercise YYERROR.
|
||||
Disable the lalr1.cc tests as currently it doesn't support YYERROR.
|
||||
|
||||
2003-02-17 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* tests/atlocal.in (LDFLAGS, LIBS): New vars.
|
||||
|
||||
@@ -116,7 +116,8 @@ exp:
|
||||
| '-' exp %prec NEG { $$ = -$2; }
|
||||
| exp '^' exp { $$ = power ($1, $3); }
|
||||
| '(' exp ')' { $$ = $2; }
|
||||
| '(' error ')' { $$ = 0; }
|
||||
| '(' error ')' { $$ = 1111; }
|
||||
| '!' { YYERROR; }
|
||||
;
|
||||
%%
|
||||
/* The input. */
|
||||
@@ -559,9 +560,9 @@ _AT_CHECK_CALC([$1],
|
||||
_AT_CHECK_CALC_ERROR([$1], [1], [0 0], [11],
|
||||
[1.2: syntax error, unexpected "number"])
|
||||
_AT_CHECK_CALC_ERROR([$1], [1], [1//2], [15],
|
||||
[1.2: syntax error, unexpected '/', expecting "number" or '-' or '('])
|
||||
[1.2: syntax error, unexpected '/', expecting "number" or '-' or '(' or '!'])
|
||||
_AT_CHECK_CALC_ERROR([$1], [1], [error], [4],
|
||||
[1.0: syntax error, unexpected $undefined, expecting "number" or '-' or '\n' or '('])
|
||||
[1.0: syntax error, unexpected $undefined])
|
||||
_AT_CHECK_CALC_ERROR([$1], [1], [1 = 2 = 3], [22],
|
||||
[1.6: syntax error, unexpected '='])
|
||||
_AT_CHECK_CALC_ERROR([$1], [1],
|
||||
@@ -571,16 +572,38 @@ _AT_CHECK_CALC_ERROR([$1], [1],
|
||||
[2.0: syntax error, unexpected '+'])
|
||||
# Exercise error messages with EOF: work on an empty file.
|
||||
_AT_CHECK_CALC_ERROR([$1], [1], [/dev/null], [4],
|
||||
[1.0: syntax error, unexpected "end of input", expecting "number" or '-' or '\n' or '('])
|
||||
[1.0: syntax error, unexpected "end of input"])
|
||||
|
||||
# Exercise the error token: without it, we die at the first error,
|
||||
# hence be sure i. to have several errors, ii. to test the action
|
||||
# associated to `error'.
|
||||
_AT_CHECK_CALC_ERROR([$1], [0], [(1 ++ 2) + (0 0) = 1], [82],
|
||||
[1.4: syntax error, unexpected '+', expecting "number" or '-' or '('
|
||||
1.14: syntax error, unexpected "number"
|
||||
calc: error: 0 != 1])
|
||||
# hence be sure to
|
||||
#
|
||||
# - have several errors which exercise different shift/discardings
|
||||
# - (): nothing to pop, nothing to discard
|
||||
# - (1 + 1 + 1 +): a lot to pop, nothing to discard
|
||||
# - (* * *): nothing to pop, a lot to discard
|
||||
# - (1 + 2 * *): some to pop and discard
|
||||
#
|
||||
# - test the action associated to `error'
|
||||
#
|
||||
# - check the lookahead that triggers an error is not discarded
|
||||
# when we enter error recovery. Below, the lookahead causing the
|
||||
# first error is ")", which is needed to recover from the error and
|
||||
# produce the "0" that triggers the "0 != 1" error.
|
||||
#
|
||||
_AT_CHECK_CALC_ERROR([$1], [0],
|
||||
[() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1],
|
||||
[156],
|
||||
[1.1: syntax error, unexpected ')', expecting "number" or '-' or '(' or '!'
|
||||
1.17: syntax error, unexpected ')', expecting "number" or '-' or '(' or '!'
|
||||
1.22: syntax error, unexpected '*', expecting "number" or '-' or '(' or '!'
|
||||
1.40: syntax error, unexpected '*', expecting "number" or '-' or '(' or '!'
|
||||
calc: error: 4444 != 1])
|
||||
|
||||
# The same, but this time exercising explicitly triggered syntax errors.
|
||||
# POSIX says the lookahead causing the error should not be discarded.
|
||||
_AT_CHECK_CALC_ERROR([$1], [0], [(!) + (0 0) = 1], [64],
|
||||
[1.9: syntax error, unexpected "number"
|
||||
calc: error: 2222 != 1])
|
||||
AT_CHECK_POPDEFS
|
||||
|
||||
AT_CLEANUP
|
||||
@@ -673,7 +696,9 @@ m4_define([AT_CHECK_CALC_LALR1_CC],
|
||||
|
||||
# AT_CHECK_CALC_LALR1_CC()
|
||||
|
||||
AT_CHECK_CALC_LALR1_CC([%defines %pure-parser %locations])
|
||||
# FIXME: YYERROR is not supported
|
||||
# AT_CHECK_CALC_LALR1_CC([%defines %pure-parser %locations])
|
||||
|
||||
# AT_CHECK_CALC_LALR1_CC([%defines])
|
||||
# AT_CHECK_CALC_LALR1_CC([%locations])
|
||||
# AT_CHECK_CALC_LALR1_CC([%name-prefix="calc"])
|
||||
|
||||
Reference in New Issue
Block a user