mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-13 14:23:04 +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:
34
src/output.c
34
src/output.c
@@ -639,6 +639,39 @@ symbol_destructors_output (FILE *out)
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------.
|
||||
| Output the symbol printers to OOUT. |
|
||||
`-------------------------------------*/
|
||||
|
||||
static void
|
||||
symbol_printers_output (FILE *out)
|
||||
{
|
||||
int i;
|
||||
int first = 1;
|
||||
|
||||
fputs ("m4_define([b4_symbol_printers], \n[", out);
|
||||
for (i = 0; i < nsyms; ++i)
|
||||
if (symbols[i]->destructor)
|
||||
{
|
||||
symbol_t *symbol = symbols[i];
|
||||
|
||||
/* Filename, lineno,
|
||||
Symbol-name, Symbol-number,
|
||||
destructor, typename. */
|
||||
fprintf (out, "%s[[[%s]], [[%d]], [[%s]], [[%d]], [[%s]], [[%s]]]",
|
||||
first ? "" : ",\n",
|
||||
infile, symbol->printer_location.first_line,
|
||||
symbol_tag_get (symbol),
|
||||
symbol->number,
|
||||
symbol->printer,
|
||||
symbol->type_name);
|
||||
|
||||
first = 0;
|
||||
}
|
||||
fputs ("])\n\n", out);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
save_column (int symbol, int default_state)
|
||||
{
|
||||
@@ -1053,6 +1086,7 @@ output_skeleton (void)
|
||||
actions_output (out);
|
||||
token_definitions_output (out);
|
||||
symbol_destructors_output (out);
|
||||
symbol_printers_output (out);
|
||||
|
||||
muscles_m4_output (out);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user