X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/0fb669f9d648dfdd7a39478a6b658511455ae966..55f0c7b1f26afabb7f356343f2650626e09fce51:/src/symtab.c diff --git a/src/symtab.c b/src/symtab.c index aabf3343..8cbfc54f 100644 --- a/src/symtab.c +++ b/src/symtab.c @@ -74,6 +74,25 @@ symbol_new (uniqstr tag, location loc) } +/*-----------------. +| Print a symbol. | +`-----------------*/ + +#define SYMBOL_ATTR_PRINT(Attr) \ + if (s->Attr) \ + fprintf (f, " %s { %s }", #Attr, s->Attr) + +void +symbol_print (symbol *s, FILE *f) +{ + fprintf (f, "\"%s\"", s->tag); + SYMBOL_ATTR_PRINT (type_name); + SYMBOL_ATTR_PRINT (destructor); + SYMBOL_ATTR_PRINT (printer); +} + +#undef SYMBOL_ATTR_PRINT + /*------------------------------------------------------------------. | Complain that S's WHAT is redeclared at SECOND, and was first set | | at FIRST. | @@ -111,7 +130,7 @@ symbol_type_set (symbol *sym, uniqstr type_name, location loc) `------------------------------------------------------------------*/ void -symbol_destructor_set (symbol *sym, char *destructor, location loc) +symbol_destructor_set (symbol *sym, const char *destructor, location loc) { if (destructor) { @@ -128,7 +147,7 @@ symbol_destructor_set (symbol *sym, char *destructor, location loc) `---------------------------------------------------------------*/ void -symbol_printer_set (symbol *sym, char *printer, location loc) +symbol_printer_set (symbol *sym, const char *printer, location loc) { if (printer) {