Use the new code_props interface for destructors and printers.

* src/symtab.h (symbol, semantic_type): Remove destructor_location and
printer_location members, and change the type of the destructor and
printer members to code_props.
(symbol_destructor_set, symbol_destructor_get, symbol_printer_set,
symbol_printer_get, semantic_type_destructor_set,
semantic_type_printer_set, default_tagged_destructor_set,
default_tagless_destructor_set, default_tagged_printer_set,
default_tagless_printer_set): Use code_props in arguments and return
types in place of char const * and location.
(symbol_destructor_location_get, symbol_printer_location_get): Remove
since the locations are now contained in the return of
symbol_destructor_get and symbol_printer_get.
* src/output.c (symbol_destructors_output, symbol_printers_output):
Replace with...
(symbol_code_props_output): ... this to eliminate duplicate code.
(output_skeleton): Update to use symbol_code_props_output.
* src/reader.c (symbol_should_be_used): Update use of
symbol_destructor_get.
* src/symlist.c (symbol_list_destructor_set, symbol_list_printer_set):
Update uses of the various _destructor_set and _printer_set functions.
* src/symtab.c: (default_tagged_destructor_location,
default_tagless_destructor_location, default_tagged_printer_location,
default_tagless_printer_location): Remove since we...
(default_tagged_destructor, default_tagless_destructor,
default_tagged_printer, default_tagless_printer): ... change the type
of these to code_props.
(symbol_new, semantic_type_new, symbol_destructor_set,
semantic_type_destructor_set, symbol_destructor_get,
symbol_printer_set, semantic_type_printer_set, symbol_printer_get,
symbol_check_alias_consistency, default_tagged_destructor_set,
default_tagless_destructor_set, default_tagged_printer_set,
default_tagless_printer_set): Update.
(symbol_destructor_location_get, symbol_printer_location_get): Remove.
(SYMBOL_CODE_PRINT): New similar to SYMBOL_ATTR_PRINT but for
code_props members.
(symbol_print): Use SYMBOL_CODE_PRINT.
This commit is contained in:
Joel E. Denny
2007-01-04 04:51:22 +00:00
parent f6857bbf8c
commit 95021767a1
6 changed files with 209 additions and 279 deletions

View File

@@ -1,3 +1,43 @@
2007-01-03 Joel E. Denny <jdenny@ces.clemson.edu>
Use the new code_props interface for destructors and printers.
* src/symtab.h (symbol, semantic_type): Remove destructor_location and
printer_location members, and change the type of the destructor and
printer members to code_props.
(symbol_destructor_set, symbol_destructor_get, symbol_printer_set,
symbol_printer_get, semantic_type_destructor_set,
semantic_type_printer_set, default_tagged_destructor_set,
default_tagless_destructor_set, default_tagged_printer_set,
default_tagless_printer_set): Use code_props in arguments and return
types in place of char const * and location.
(symbol_destructor_location_get, symbol_printer_location_get): Remove
since the locations are now contained in the return of
symbol_destructor_get and symbol_printer_get.
* src/output.c (symbol_destructors_output, symbol_printers_output):
Replace with...
(symbol_code_props_output): ... this to eliminate duplicate code.
(output_skeleton): Update to use symbol_code_props_output.
* src/reader.c (symbol_should_be_used): Update use of
symbol_destructor_get.
* src/symlist.c (symbol_list_destructor_set, symbol_list_printer_set):
Update uses of the various _destructor_set and _printer_set functions.
* src/symtab.c: (default_tagged_destructor_location,
default_tagless_destructor_location, default_tagged_printer_location,
default_tagless_printer_location): Remove since we...
(default_tagged_destructor, default_tagless_destructor,
default_tagged_printer, default_tagless_printer): ... change the type
of these to code_props.
(symbol_new, semantic_type_new, symbol_destructor_set,
semantic_type_destructor_set, symbol_destructor_get,
symbol_printer_set, semantic_type_printer_set, symbol_printer_get,
symbol_check_alias_consistency, default_tagged_destructor_set,
default_tagless_destructor_set, default_tagged_printer_set,
default_tagless_printer_set): Update.
(symbol_destructor_location_get, symbol_printer_location_get): Remove.
(SYMBOL_CODE_PRINT): New similar to SYMBOL_ATTR_PRINT but for
code_props members.
(symbol_print): Use SYMBOL_CODE_PRINT.
2007-01-03 Joel E. Denny <jdenny@ces.clemson.edu>
Use the new code_props interface for rule actions.
@@ -18400,8 +18440,8 @@
-----
Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996,
1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free
Software Foundation, Inc.
1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
Free Software Foundation, Inc.
Copying and distribution of this file, with or without
modification, are permitted provided the copyright notice and this

View File

@@ -373,70 +373,41 @@ token_definitions_output (FILE *out)
}
/*---------------------------------------.
| Output the symbol destructors to OUT. |
`---------------------------------------*/
/*---------------------------------------------------.
| Output the symbol destructors or printers to OUT. |
`---------------------------------------------------*/
static void
symbol_destructors_output (FILE *out)
symbol_code_props_output (FILE *out, char const *what,
code_props const *(*get)(symbol const *))
{
int i;
char const *sep = "";
fputs ("m4_define([b4_symbol_destructors], \n[", out);
fputs ("m4_define([b4_symbol_", out);
fputs (what, out);
fputs ("], \n[", out);
for (i = 0; i < nsyms; ++i)
if (symbol_destructor_get (symbols[i]))
{
symbol *sym = symbols[i];
/* Filename, lineno,
Symbol-name, Symbol-number,
destructor, optional typename. */
fprintf (out, "%s[", sep);
sep = ",\n";
escaped_output (out, symbol_destructor_location_get (sym).start.file);
fprintf (out, ", %d, ",
symbol_destructor_location_get (sym).start.line);
escaped_output (out, sym->tag);
fprintf (out, ", %d, [[%s]]", sym->number,
symbol_destructor_get (sym));
if (sym->type_name)
fprintf (out, ", [[%s]]", sym->type_name);
fputc (']', out);
}
fputs ("])\n\n", out);
}
/*------------------------------------.
| Output the symbol printers to OUT. |
`------------------------------------*/
static void
symbol_printers_output (FILE *out)
{
int i;
char const *sep = "";
fputs ("m4_define([b4_symbol_printers], \n[", out);
for (i = 0; i < nsyms; ++i)
if (symbol_printer_get (symbols[i]))
{
symbol *sym = symbols[i];
/* Filename, lineno,
Symbol-name, Symbol-number,
printer, optional typename. */
fprintf (out, "%s[", sep);
sep = ",\n";
escaped_output (out, symbol_printer_location_get (sym).start.file);
fprintf (out, ", %d, ", symbol_printer_location_get (sym).start.line);
escaped_output (out, sym->tag);
fprintf (out, ", %d, [[%s]]", sym->number, symbol_printer_get (sym));
if (sym->type_name)
fprintf (out, ", [[%s]]", sym->type_name);
fputc (']', out);
}
{
symbol *sym = symbols[i];
char const *code = (*get) (sym)->code;
if (code)
{
location loc = (*get) (sym)->location;
/* Filename, lineno,
Symbol-name, Symbol-number,
code, optional typename. */
fprintf (out, "%s[", sep);
sep = ",\n";
escaped_output (out, loc.start.file);
fprintf (out, ", %d, ", loc.start.line);
escaped_output (out, sym->tag);
fprintf (out, ", %d, [[%s]]", sym->number, code);
if (sym->type_name)
fprintf (out, ", [[%s]]", sym->type_name);
fputc (']', out);
}
}
fputs ("])\n\n", out);
}
@@ -561,8 +532,8 @@ output_skeleton (void)
user_actions_output (out);
merger_output (out);
token_definitions_output (out);
symbol_destructors_output (out);
symbol_printers_output (out);
symbol_code_props_output (out, "destructors", &symbol_destructor_get);
symbol_code_props_output (out, "printers", &symbol_printer_get);
muscles_m4_output (out);
@@ -604,10 +575,10 @@ prepare (void)
MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser);
MUSCLE_INSERT_BOOL ("pull_flag", pull_parser);
MUSCLE_INSERT_BOOL ("pure_flag", pure_parser);
MUSCLE_INSERT_BOOL ("use_push_for_pull_flag", use_push_for_pull_flag);
MUSCLE_INSERT_BOOL ("push_flag", push_parser);
MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen);
MUSCLE_INSERT_BOOL ("use_push_for_pull_flag", use_push_for_pull_flag);
MUSCLE_INSERT_BOOL ("yacc_flag", yacc_flag);
/* File names. */

View File

@@ -253,7 +253,7 @@ grammar_current_rule_begin (symbol *lhs, location loc)
static bool
symbol_should_be_used (symbol_list const *s)
{
if (symbol_destructor_get (s->content.sym))
if (symbol_destructor_get (s->content.sym)->code)
return true;
if (warnings_flag & warnings_midrule_values)
return ((s->midrule && s->midrule->action_props.is_value_used)

View File

@@ -207,27 +207,25 @@ symbol_list_n_type_name_get (symbol_list *l, location loc, int n)
void
symbol_list_destructor_set (symbol_list *node, char const *code,
location loc)
symbol_list_destructor_set (symbol_list *node, char const *code, location loc)
{
code_props destructor;
code_props_symbol_action_init (&destructor, code, loc);
code_props_translate_code (&destructor);
code = destructor.code;
switch (node->content_type)
{
case SYMLIST_SYMBOL:
symbol_destructor_set (node->content.sym, code, loc);
symbol_destructor_set (node->content.sym, &destructor);
break;
case SYMLIST_TYPE:
semantic_type_destructor_set (
semantic_type_get (node->content.type_name), code, loc);
semantic_type_get (node->content.type_name), &destructor);
break;
case SYMLIST_DEFAULT_TAGGED:
default_tagged_destructor_set (code, loc);
default_tagged_destructor_set (&destructor);
break;
case SYMLIST_DEFAULT_TAGLESS:
default_tagless_destructor_set (code, loc);
default_tagless_destructor_set (&destructor);
break;
}
}
@@ -238,21 +236,20 @@ symbol_list_printer_set (symbol_list *node, char const *code, location loc)
code_props printer;
code_props_symbol_action_init (&printer, code, loc);
code_props_translate_code (&printer);
code = printer.code;
switch (node->content_type)
{
case SYMLIST_SYMBOL:
symbol_printer_set (node->content.sym, code, loc);
symbol_printer_set (node->content.sym, &printer);
break;
case SYMLIST_TYPE:
semantic_type_printer_set (
semantic_type_get (node->content.type_name), code, loc);
semantic_type_get (node->content.type_name), &printer);
break;
case SYMLIST_DEFAULT_TAGGED:
default_tagged_printer_set (code, loc);
default_tagged_printer_set (&printer);
break;
case SYMLIST_DEFAULT_TAGLESS:
default_tagless_printer_set (code, loc);
default_tagless_printer_set (&printer);
break;
}
}

View File

@@ -1,6 +1,6 @@
/* Symbol table manager for Bison.
Copyright (C) 1984, 1989, 2000, 2001, 2002, 2004, 2005, 2006 Free
Copyright (C) 1984, 1989, 2000, 2001, 2002, 2004, 2005, 2006, 2007 Free
Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -45,15 +45,10 @@ location startsymbol_location;
| Default %destructor's and %printer's. |
`---------------------------------------*/
static const char *default_tagged_destructor = NULL;
static location default_tagged_destructor_location;
static const char *default_tagless_destructor = NULL;
static location default_tagless_destructor_location;
static const char *default_tagged_printer = NULL;
static location default_tagged_printer_location;
static const char *default_tagless_printer = NULL;
static location default_tagless_printer_location;
static code_props default_tagged_destructor = CODE_PROPS_NONE_INIT;
static code_props default_tagless_destructor = CODE_PROPS_NONE_INIT;
static code_props default_tagged_printer = CODE_PROPS_NONE_INIT;
static code_props default_tagless_printer = CODE_PROPS_NONE_INIT;
/*---------------------------------.
| Create a new symbol, named TAG. |
@@ -69,8 +64,8 @@ symbol_new (uniqstr tag, location loc)
res->location = loc;
res->type_name = NULL;
res->destructor = NULL;
res->printer = NULL;
code_props_none_init (&res->destructor);
code_props_none_init (&res->printer);
res->number = NUMBER_UNDEFINED;
res->prec = 0;
@@ -99,8 +94,8 @@ semantic_type_new (uniqstr tag)
uniqstr_assert (tag);
res->tag = tag;
res->destructor = NULL;
res->printer = NULL;
code_props_none_init (&res->destructor);
code_props_none_init (&res->printer);
return res;
}
@@ -114,6 +109,10 @@ semantic_type_new (uniqstr tag)
if (s->Attr) \
fprintf (f, " %s { %s }", #Attr, s->Attr)
#define SYMBOL_CODE_PRINT(Attr) \
if (s->Attr.code) \
fprintf (f, " %s { %s }", #Attr, s->Attr.code)
void
symbol_print (symbol *s, FILE *f)
{
@@ -121,14 +120,15 @@ symbol_print (symbol *s, FILE *f)
{
fprintf (f, "\"%s\"", s->tag);
SYMBOL_ATTR_PRINT (type_name);
SYMBOL_ATTR_PRINT (destructor);
SYMBOL_ATTR_PRINT (printer);
SYMBOL_CODE_PRINT (destructor);
SYMBOL_CODE_PRINT (printer);
}
else
fprintf (f, "<NULL>");
}
#undef SYMBOL_ATTR_PRINT
#undef SYMBOL_CODE_PRINT
/*------------------------------------------------------------------.
| Complain that S's WHAT is redeclared at SECOND, and was first set |
@@ -171,170 +171,117 @@ symbol_type_set (symbol *sym, uniqstr type_name, location loc)
}
/*------------------------------------------------------------------.
| Set the DESTRUCTOR associated with SYM. Do nothing if passed 0. |
`------------------------------------------------------------------*/
/*-----------------------------------------.
| Set the DESTRUCTOR associated with SYM. |
`-----------------------------------------*/
void
symbol_destructor_set (symbol *sym, const char *destructor, location loc)
symbol_destructor_set (symbol *sym, code_props const *destructor)
{
if (destructor)
{
if (sym->destructor)
symbol_redeclaration (sym, "%destructor", sym->destructor_location,
loc);
sym->destructor = destructor;
sym->destructor_location = loc;
}
if (sym->destructor.code)
symbol_redeclaration (sym, "%destructor", sym->destructor.location,
destructor->location);
sym->destructor = *destructor;
}
/*-------------------------------------------------------------------.
| Set the DESTRUCTOR associated with TYPE. Do nothing if passed 0. |
`-------------------------------------------------------------------*/
/*------------------------------------------.
| Set the DESTRUCTOR associated with TYPE. |
`------------------------------------------*/
void
semantic_type_destructor_set (semantic_type *type, const char *destructor,
location loc)
semantic_type_destructor_set (semantic_type *type,
code_props const *destructor)
{
if (destructor)
{
if (type->destructor)
semantic_type_redeclaration (type, "%destructor",
type->destructor_location, loc);
type->destructor = destructor;
type->destructor_location = loc;
}
if (type->destructor.code)
semantic_type_redeclaration (type, "%destructor",
type->destructor.location,
destructor->location);
type->destructor = *destructor;
}
/*---------------------------------------.
| Get the computed %destructor for SYM. |
`---------------------------------------*/
const char *
symbol_destructor_get (symbol *sym)
code_props const *
symbol_destructor_get (symbol const *sym)
{
/* Per-symbol %destructor. */
if (sym->destructor != NULL)
return sym->destructor;
if (sym->destructor.code)
return &sym->destructor;
/* Per-type %destructor. */
if (sym->type_name)
{
semantic_type *type = semantic_type_get (sym->type_name);
if (type->destructor)
return type->destructor;
code_props const *destructor =
&semantic_type_get (sym->type_name)->destructor;
if (destructor->code)
return destructor;
}
/* Apply default %destructor's only to user-defined symbols. */
if (sym->tag[0] == '$' || sym == errtoken)
return NULL;
return &code_props_none;
if (sym->type_name)
return default_tagged_destructor;
return default_tagless_destructor;
return &default_tagged_destructor;
return &default_tagless_destructor;
}
/*---------------------------------------------------------------.
| Get the grammar location of the %destructor computed for SYM. |
`---------------------------------------------------------------*/
location
symbol_destructor_location_get (symbol *sym)
{
if (sym->destructor != NULL)
return sym->destructor_location;
if (sym->type_name)
{
semantic_type *type = semantic_type_get (sym->type_name);
if (type->destructor)
return type->destructor_location;
return default_tagged_destructor_location;
}
return default_tagless_destructor_location;
}
/*---------------------------------------------------------------.
| Set the PRINTER associated with SYM. Do nothing if passed 0. |
`---------------------------------------------------------------*/
/*--------------------------------------.
| Set the PRINTER associated with SYM. |
`--------------------------------------*/
void
symbol_printer_set (symbol *sym, const char *printer, location loc)
symbol_printer_set (symbol *sym, code_props const *printer)
{
if (printer)
{
if (sym->printer)
symbol_redeclaration (sym, "%printer", sym->printer_location, loc);
sym->printer = printer;
sym->printer_location = loc;
}
if (sym->printer.code)
symbol_redeclaration (sym, "%printer",
sym->printer.location, printer->location);
sym->printer = *printer;
}
/*----------------------------------------------------------------.
| Set the PRINTER associated with TYPE. Do nothing if passed 0. |
`----------------------------------------------------------------*/
/*---------------------------------------.
| Set the PRINTER associated with TYPE. |
`---------------------------------------*/
void
semantic_type_printer_set (semantic_type *type, const char *printer,
location loc)
semantic_type_printer_set (semantic_type *type, code_props const *printer)
{
if (printer)
{
if (type->printer)
semantic_type_redeclaration (type, "%printer", type->printer_location,
loc);
type->printer = printer;
type->printer_location = loc;
}
if (type->printer.code)
semantic_type_redeclaration (type, "%printer",
type->printer.location, printer->location);
type->printer = *printer;
}
/*------------------------------------.
| Get the computed %printer for SYM. |
`------------------------------------*/
const char *
symbol_printer_get (symbol *sym)
code_props const *
symbol_printer_get (symbol const *sym)
{
/* Per-symbol %printer. */
if (sym->printer != NULL)
return sym->printer;
if (sym->printer.code)
return &sym->printer;
/* Per-type %printer. */
if (sym->type_name)
{
semantic_type *type = semantic_type_get (sym->type_name);
if (type->printer)
return type->printer;
code_props const *printer = &semantic_type_get (sym->type_name)->printer;
if (printer->code)
return printer;
}
/* Apply the default %printer only to user-defined symbols. */
if (sym->tag[0] == '$' || sym == errtoken)
return NULL;
return &code_props_none;
if (sym->type_name)
return default_tagged_printer;
return default_tagless_printer;
return &default_tagged_printer;
return &default_tagless_printer;
}
/*------------------------------------------------------------.
| Get the grammar location of the %printer computed for SYM. |
`------------------------------------------------------------*/
location
symbol_printer_location_get (symbol *sym)
{
if (sym->printer != NULL)
return sym->printer_location;
if (sym->type_name)
{
semantic_type *type = semantic_type_get (sym->type_name);
if (type->printer)
return type->printer_location;
return default_tagged_printer_location;
}
return default_tagless_printer_location;
}
/*-----------------------------------------------------------------.
| Set the PRECEDENCE associated with SYM. Does nothing if invoked |
| with UNDEF_ASSOC as ASSOC. |
@@ -498,22 +445,20 @@ symbol_check_alias_consistency (symbol *this)
}
if (orig->destructor || alias->destructor)
if (orig->destructor.code || alias->destructor.code)
{
if (orig->destructor)
symbol_destructor_set (alias, orig->destructor,
orig->destructor_location);
if (orig->destructor.code)
symbol_destructor_set (alias, &orig->destructor);
else
symbol_destructor_set (orig, alias->destructor,
alias->destructor_location);
symbol_destructor_set (orig, &alias->destructor);
}
if (orig->printer || alias->printer)
if (orig->printer.code || alias->printer.code)
{
if (orig->printer)
symbol_printer_set (alias, orig->printer, orig->printer_location);
if (orig->printer.code)
symbol_printer_set (alias, &orig->printer);
else
symbol_printer_set (orig, alias->printer, alias->printer_location);
symbol_printer_set (orig, &alias->printer);
}
if (alias->prec || orig->prec)
@@ -942,53 +887,54 @@ symbols_pack (void)
`--------------------------------------------------*/
void
default_tagged_destructor_set (const char *destructor, location loc)
default_tagged_destructor_set (code_props const *destructor)
{
if (default_tagged_destructor != NULL)
if (default_tagged_destructor.code)
{
complain_at (loc, _("redeclaration for default tagged %%destructor"));
complain_at (default_tagged_destructor_location,
complain_at (destructor->location,
_("redeclaration for default tagged %%destructor"));
complain_at (default_tagged_destructor.location,
_("previous declaration"));
}
default_tagged_destructor = destructor;
default_tagged_destructor_location = loc;
default_tagged_destructor = *destructor;
}
void
default_tagless_destructor_set (const char *destructor, location loc)
default_tagless_destructor_set (code_props const *destructor)
{
if (default_tagless_destructor != NULL)
if (default_tagless_destructor.code)
{
complain_at (loc, _("redeclaration for default tagless %%destructor"));
complain_at (default_tagless_destructor_location,
complain_at (destructor->location,
_("redeclaration for default tagless %%destructor"));
complain_at (default_tagless_destructor.location,
_("previous declaration"));
}
default_tagless_destructor = destructor;
default_tagless_destructor_location = loc;
default_tagless_destructor = *destructor;
}
void
default_tagged_printer_set (const char *printer, location loc)
default_tagged_printer_set (code_props const *printer)
{
if (default_tagged_printer != NULL)
if (default_tagged_printer.code)
{
complain_at (loc, _("redeclaration for default tagged %%printer"));
complain_at (default_tagged_printer_location,
complain_at (printer->location,
_("redeclaration for default tagged %%printer"));
complain_at (default_tagged_printer.location,
_("previous declaration"));
}
default_tagged_printer = printer;
default_tagged_printer_location = loc;
default_tagged_printer = *printer;
}
void
default_tagless_printer_set (const char *printer, location loc)
default_tagless_printer_set (code_props const *printer)
{
if (default_tagless_printer != NULL)
if (default_tagless_printer.code)
{
complain_at (loc, _("redeclaration for default tagless %%printer"));
complain_at (default_tagless_printer_location,
complain_at (printer->location,
_("redeclaration for default tagless %%printer"));
complain_at (default_tagless_printer.location,
_("previous declaration"));
}
default_tagless_printer = printer;
default_tagless_printer_location = loc;
default_tagless_printer = *printer;
}

View File

@@ -1,6 +1,6 @@
/* Definitions for symtab.c and callers, part of Bison.
Copyright (C) 1984, 1989, 1992, 2000, 2001, 2002, 2004, 2005, 2006
Copyright (C) 1984, 1989, 1992, 2000, 2001, 2002, 2004, 2005, 2006, 2007
Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -30,6 +30,7 @@
# include "assoc.h"
# include "location.h"
# include "scan-code.h"
# include "uniqstr.h"
/*----------.
@@ -72,25 +73,13 @@ struct symbol
example, if <tt>symbol::destructor = NULL</tt>, a default \c \%destructor
or a per-type \c \%destructor might be appropriate, and
\c symbol_destructor_get will compute the correct one. */
const char *destructor;
/** The location of \c symbol::destructor.
Access this field only through <tt>symbol</tt>'s interface functions.
\sa symbol::destructor */
location destructor_location;
code_props destructor;
/** Any \c \%printer declared specifically for this symbol.
Access this field only through <tt>symbol</tt>'s interface functions.
\sa symbol::destructor */
const char *printer;
/** The location of \c symbol::printer.
Access this field only through <tt>symbol</tt>'s interface functions.
\sa symbol::destructor */
location printer_location;
code_props printer;
symbol_number number;
location prec_location;
@@ -144,26 +133,18 @@ void symbol_make_alias (symbol *sym, symbol *symval, location loc);
void symbol_type_set (symbol *sym, uniqstr type_name, location loc);
/** Set the \c destructor associated with \c sym. */
void symbol_destructor_set (symbol *sym, const char *destructor, location loc);
void symbol_destructor_set (symbol *sym, code_props const *destructor);
/** Get the computed \c \%destructor for \c sym, or \c NULL if none. */
const char *symbol_destructor_get (symbol *sym);
/** Get the grammar location of the computed \c \%destructor for \c sym.
\pre <tt>symbol_destructor_get (sym) != NULL</tt> */
location symbol_destructor_location_get (symbol *sym);
/** Get the computed \c \%destructor for \c sym, which was initialized with
\c code_props_none_init if there's no \c \%destructor. */
code_props const *symbol_destructor_get (symbol const *sym);
/** Set the \c printer associated with \c sym. */
void symbol_printer_set (symbol *sym, const char *printer, location loc);
void symbol_printer_set (symbol *sym, code_props const *printer);
/** Get the computed \c \%printer for \c sym, or \c NULL if none. */
const char *symbol_printer_get (symbol *sym);
/** Get the grammar location of the computed \c \%printer for \c sym.
\pre <tt>symbol_printer_get (sym) != NULL</tt> */
location symbol_printer_location_get (symbol *sym);
/** Get the computed \c \%printer for \c sym, which was initialized with
\c code_props_none_init if there's no \c \%printer. */
code_props const *symbol_printer_get (symbol const *sym);
/* Set the \c precedence associated with \c sym.
@@ -209,14 +190,9 @@ typedef struct {
uniqstr tag;
/** Any \c %destructor declared for this semantic type. */
const char *destructor;
/** The location of \c semantic_type::destructor. */
location destructor_location;
code_props destructor;
/** Any \c %printer declared for this semantic type. */
const char *printer;
/** The location of \c semantic_type::printer. */
location printer_location;
code_props printer;
} semantic_type;
/** Fetch (or create) the semantic type associated to KEY. */
@@ -226,12 +202,12 @@ semantic_type *semantic_type_from_uniqstr (const uniqstr key);
semantic_type *semantic_type_get (const char *key);
/** Set the \c destructor associated with \c type. */
void semantic_type_destructor_set (semantic_type *type, const char *destructor,
location loc);
void semantic_type_destructor_set (semantic_type *type,
code_props const *destructor);
/** Set the \c printer associated with \c type. */
void semantic_type_printer_set (semantic_type *type, const char *printer,
location loc);
void semantic_type_printer_set (semantic_type *type,
code_props const *printer);
/*----------------------------------.
| Symbol and semantic type tables. |
@@ -260,13 +236,13 @@ void symbols_pack (void);
`---------------------------------------*/
/** Set the default \c \%destructor for tagged values. */
void default_tagged_destructor_set (const char *destructor, location loc);
void default_tagged_destructor_set (code_props const *destructor);
/** Set the default \c \%destructor for tagless values. */
void default_tagless_destructor_set (const char *destructor, location loc);
void default_tagless_destructor_set (code_props const *destructor);
/** Set the default \c \%printer for tagged values. */
void default_tagged_printer_set (const char *printer, location loc);
void default_tagged_printer_set (code_props const *printer);
/** Set the default \c \%printer for tagless values. */
void default_tagless_printer_set (const char *printer, location loc);
void default_tagless_printer_set (code_props const *printer);
#endif /* !SYMTAB_H_ */