]> git.saurik.com Git - bison.git/blobdiff - src/symtab.c
* data/glr.c: Reformat whitespace with tabs.
[bison.git] / src / symtab.c
index 3b5683a2c6fdcf42efec1db1a395152a2d9b6b4f..bf231628a1da0f6bf603dae60a53699dca3d5062 100644 (file)
 
    You should have received a copy of the GNU General Public License
    along with Bison; see the file COPYING.  If not, write to
-   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
-
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
 
+#include <config.h>
 #include "system.h"
 
 #include <hash.h>
@@ -74,6 +74,30 @@ 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)
+{
+  if (s)
+    {
+      fprintf (f, "\"%s\"", s->tag);
+      SYMBOL_ATTR_PRINT (type_name);
+      SYMBOL_ATTR_PRINT (destructor);
+      SYMBOL_ATTR_PRINT (printer);
+    }
+  else
+    fprintf (f, "<NULL>");
+}
+
+#undef SYMBOL_ATTR_PRINT
+
 /*------------------------------------------------------------------.
 | Complain that S's WHAT is redeclared at SECOND, and was first set |
 | at FIRST.                                                         |
@@ -111,7 +135,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 +152,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)
     {