Index: ChangeLog from +2003-02-19 Akim Demaille * 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. Index: tests/calc.at =================================================================== RCS file: /cvsroot/bison/bison/tests/calc.at,v retrieving revision 1.50 diff -u -u -r1.50 calc.at --- tests/calc.at 6 Feb 2003 10:04:29 -0000 1.50 +++ tests/calc.at 19 Feb 2003 13:36:15 -0000 @@ -116,7 +116,8 @@ | '-' 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_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 @@ [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 @@ # 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"])