From a04d5c74a481d73958a41f943080e914de8a4236 Mon Sep 17 00:00:00 2001 From: Dave Beazley Date: Fri, 25 Feb 2000 00:20:04 +0000 Subject: [PATCH] Added tree.c git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@262 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/Makefile.in | 4 ++-- Source/Swig/tree.c | 43 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 Source/Swig/tree.c diff --git a/Source/Swig/Makefile.in b/Source/Swig/Makefile.in index 6c912db1f..e2bdef862 100644 --- a/Source/Swig/Makefile.in +++ b/Source/Swig/Makefile.in @@ -2,8 +2,8 @@ # $Header$ #---------------------------------------------------------------- -SRCS = stype.c scanner.c include.c getopt.c misc.c super.c -OBJS = stype.o scanner.o include.o getopt.o misc.o super.o +SRCS = tree.c stype.c scanner.c include.c getopt.c misc.c super.c +OBJS = tree.o stype.o scanner.o include.o getopt.o misc.o super.o prefix = @prefix@ exec_prefix = @exec_prefix@ diff --git a/Source/Swig/tree.c b/Source/Swig/tree.c new file mode 100644 index 000000000..d39f34e70 --- /dev/null +++ b/Source/Swig/tree.c @@ -0,0 +1,43 @@ +/* ----------------------------------------------------------------------------- + * tree.c + * + * This file provides some general purpose functions for manipulating + * parse trees. + * + * Author(s) : David Beazley (beazley@cs.uchicago.edu) + * + * Copyright (C) 1999-2000. The University of Chicago + * See the file LICENSE for information on usage and redistribution. + * ----------------------------------------------------------------------------- */ + +#include "swig.h" + +static char cvsroot[] = "$Header$"; + +/* ----------------------------------------------------------------------------- + * Swig_dump_tags() + * + * Dump the tag structure of a parse tree to standard output + * ----------------------------------------------------------------------------- */ + +void +Swig_dump_tags(DOH *obj, DOH *root) { + DOH *croot, *newroot; + DOH *cobj; + + if (!root) croot = NewString(""); + else croot = root; + + while (obj) { + Printf(stdout,"%s.%s\n", croot, Getattr(obj,"tag")); + cobj = Getattr(obj,"child"); + if (cobj) { + newroot = NewStringf("%s.%s",croot,Getattr(obj,"tag")); + Swig_dump_tags(cobj,newroot); + Delete(newroot); + } + obj = Getattr(obj,"sibling"); + } + if (!root) + Delete(croot); +}