mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-12 05:43:03 +00:00
* src/symtab.h, src/symtab.c (symbol_t): printer and
printer_location are new members. (symbol_printer_set): New. * src/parse-gram.y (PERCENT_PRINTER): New token. Handle its associated rule. * src/scan-gram.l: Adjust. (handle_destructor_at, handle_destructor_dollar): Rename as... (handle_symbol_code_at, handle_symbol_code_dollar): these. * src/output.c (symbol_printers_output): New. (output_skeleton): Call it. * data/bison.simple (yysymprint): New. Cannot be named yyprint since there are already many grammar files with a user `yyprint'. Replace the calls to YYPRINT to calls to yysymprint. * tests/calc.at: Adjust. * tests/torture.at (AT_DATA_STACK_TORTURE): Remove YYPRINT: it was taking advantage of parser very internal details (stack size!).
This commit is contained in:
@@ -415,40 +415,34 @@ _AT_CHECK_CALC([$1],
|
||||
(2^2)^3 = 64], [486])
|
||||
|
||||
# Some parse errors.
|
||||
_AT_CHECK_CALC_ERROR([$1], [0 0], [12],
|
||||
_AT_CHECK_CALC_ERROR([$1], [0 0], [11],
|
||||
[1.3-1.4: parse error, unexpected "number"])
|
||||
_AT_CHECK_CALC_ERROR([$1], [1//2], [17],
|
||||
_AT_CHECK_CALC_ERROR([$1], [1//2], [15],
|
||||
[1.3-1.4: parse error, unexpected '/', expecting "number" or '-' or '('])
|
||||
_AT_CHECK_CALC_ERROR([$1], [error], [4],
|
||||
[1.1-1.2: parse error, unexpected $undefined., expecting "number" or '-' or '\n' or '('])
|
||||
_AT_CHECK_CALC_ERROR([$1], [1 = 2 = 3], [25],
|
||||
_AT_CHECK_CALC_ERROR([$1], [1 = 2 = 3], [22],
|
||||
[1.7-1.8: parse error, unexpected '='])
|
||||
_AT_CHECK_CALC_ERROR([$1],
|
||||
[
|
||||
+1],
|
||||
[15],
|
||||
[14],
|
||||
[2.1-2.2: parse error, unexpected '+'])
|
||||
# Exercise error messages with EOF: work on an empty file.
|
||||
_AT_CHECK_CALC_ERROR([$1],
|
||||
[/dev/null],
|
||||
[4],
|
||||
_AT_CHECK_CALC_ERROR([$1], [/dev/null], [4],
|
||||
[1.1-1.2: parse error, unexpected "end of file", expecting "number" or '-' or '\n' or '('])
|
||||
|
||||
# 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],
|
||||
[(1 ++ 2) + (0 0) = 1],
|
||||
[91],
|
||||
_AT_CHECK_CALC_ERROR([$1], [(1 ++ 2) + (0 0) = 1], [82],
|
||||
[1.5-1.6: parse error, unexpected '+', expecting "number" or '-' or '('
|
||||
1.15-1.16: parse error, unexpected "number"
|
||||
calc: error: 0 != 1])
|
||||
|
||||
# Add a studid example demonstrating that Bison can further improve the
|
||||
# error message. FIXME: Fix this ridiculous message.
|
||||
_AT_CHECK_CALC_ERROR([$1],
|
||||
[()],
|
||||
[21],
|
||||
_AT_CHECK_CALC_ERROR([$1], [()], [21],
|
||||
[1.2-1.3: parse error, unexpected ')', expecting error or "number" or '-' or '('])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
@@ -371,9 +371,6 @@ AT_DATA([input.y],
|
||||
]$1[
|
||||
static int yylex (void);
|
||||
static void yyerror (const char *msg);
|
||||
#define YYPRINT(File, Type, Value) \
|
||||
fprintf (File, " (%d, stack size = %d, max = %d)", \
|
||||
Value, yyssp - yyss + 1, yystacksize);
|
||||
%}
|
||||
%error-verbose
|
||||
%debug
|
||||
|
||||
Reference in New Issue
Block a user