swig/SWIG/Source/Swig/tree.c
Dave Beazley 53b3954dbe Added tree.c
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@262 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2000-02-25 00:20:04 +00:00

43 lines
1.2 KiB
C

/* -----------------------------------------------------------------------------
* 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);
}