Added tree.c

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@262 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2000-02-25 00:20:04 +00:00
commit 53b3954dbe
2 changed files with 45 additions and 2 deletions

View file

@ -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@

43
SWIG/Source/Swig/tree.c Normal file
View file

@ -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);
}