Generalize the display of semantic values and locations in traces.

* data/glr.c (yy_reduce_print): Fix indices (again).
* data/c++.m4 (b4_rhs_value, b4_rhs_location): Don't expect
literal integers.
* data/lalr1.cc (yyreduce_print): Rename as...
(yy_reduce_print): this.
Display values and locations.
* data/yacc.c (yy_reduce_print): Likewise.
(YY_REDUCE_PRINT): Adjust to pass the required arguments.
(yysymprint): Move higher to be visible from yy_reduce_print).
(yyparse): Adjust.
* tests/calc.at: Adjust the expected length of the traces.
This commit is contained in:
Akim Demaille
2005-11-16 14:20:48 +00:00
parent 6de5398de3
commit d1ff7a7cc6
6 changed files with 75 additions and 47 deletions

View File

@@ -465,21 +465,21 @@ _AT_CHECK_CALC([$1],
2^2^3 = 256
(2^2)^3 = 64],
[571])
[842])
# Some syntax errors.
_AT_CHECK_CALC_ERROR([$1], [1], [0 0], [13],
_AT_CHECK_CALC_ERROR([$1], [1], [0 0], [15],
[1.2: syntax error, unexpected number])
_AT_CHECK_CALC_ERROR([$1], [1], [1//2], [18],
_AT_CHECK_CALC_ERROR([$1], [1], [1//2], [20],
[1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'])
_AT_CHECK_CALC_ERROR([$1], [1], [error], [5],
[1.0: syntax error, unexpected $undefined])
_AT_CHECK_CALC_ERROR([$1], [1], [1 = 2 = 3], [26],
_AT_CHECK_CALC_ERROR([$1], [1], [1 = 2 = 3], [30],
[1.6: syntax error, unexpected '='])
_AT_CHECK_CALC_ERROR([$1], [1],
[
+1],
[16],
[20],
[2.0: syntax error, unexpected '+'])
# Exercise error messages with EOF: work on an empty file.
_AT_CHECK_CALC_ERROR([$1], [1], [/dev/null], [4],
@@ -503,7 +503,7 @@ _AT_CHECK_CALC_ERROR([$1], [1], [/dev/null], [4],
#
_AT_CHECK_CALC_ERROR([$1], [0],
[() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1],
[189],
[250],
[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 '!'
@@ -512,10 +512,10 @@ calc: error: 4444 != 1])
# The same, but this time exercising explicitly triggered syntax errors.
# POSIX says the look-ahead causing the error should not be discarded.
_AT_CHECK_CALC_ERROR([$1], [0], [(!) + (0 0) = 1], [76],
_AT_CHECK_CALC_ERROR([$1], [0], [(!) + (0 0) = 1], [102],
[1.9: syntax error, unexpected number
calc: error: 2222 != 1])
_AT_CHECK_CALC_ERROR([$1], [0], [(- *) + (0 0) = 1], [86],
_AT_CHECK_CALC_ERROR([$1], [0], [(- *) + (0 0) = 1], [113],
[1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.11: syntax error, unexpected number
calc: error: 2222 != 1])