summaryrefslogtreecommitdiff
path: root/colm
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2011-10-29 22:18:52 +0000
committerAdrian Thurston <thurston@complang.org>2011-10-29 22:18:52 +0000
commit6a7333b73effa7a8d8fe96f21b84ea2e4a4d13b1 (patch)
treebf69df569d990ad875354e27df825dc235a41103 /colm
parente1334e70ecae09bcd730e4d8795e4c9e95a8cff0 (diff)
downloadcolm-6a7333b73effa7a8d8fe96f21b84ea2e4a4d13b1.tar.gz
The colm.h header now contains the bare minimum for the C++ interface. Put the
prefix Colm on the language elments in there. refs #328.
Diffstat (limited to 'colm')
-rw-r--r--colm/bytecode.c26
-rw-r--r--colm/bytecode.h12
-rw-r--r--colm/codegen.cc29
-rw-r--r--colm/colm.h61
-rw-r--r--colm/fsmcodegen.cc1
-rw-r--r--colm/fsmrun.h12
-rw-r--r--colm/global.h7
-rw-r--r--colm/input.h14
-rw-r--r--colm/lmparse.kh1
-rw-r--r--colm/lmparse.kl2
-rw-r--r--colm/parsedata.cc17
-rw-r--r--colm/pdarun.h14
-rw-r--r--colm/tree.c28
-rw-r--r--colm/tree.h21
14 files changed, 140 insertions, 105 deletions
diff --git a/colm/bytecode.c b/colm/bytecode.c
index a49c9921..3d7b1cbb 100644
--- a/colm/bytecode.c
+++ b/colm/bytecode.c
@@ -473,7 +473,7 @@ Tree *constructArgv( Program *prg, int argc, const char **argv )
* Execution environment
*/
-void initColm( long debugRealm )
+void colmInit( long debugRealm )
{
/* Always on because because logging is controlled with ifdefs in\n" the
* runtime lib. */
@@ -486,13 +486,14 @@ void initColm( long debugRealm )
initInputFuncs();
}
-void initProgram( Program *prg, int argc, const char **argv, int ctxDepParsing,
- RuntimeData *rtd )
+Program *colmNewProgram( RuntimeData *rtd, int argc, const char **argv )
{
+ Program *prg = malloc(sizeof(Program));
+ memset( prg, 0, sizeof(Program) );
prg->argc = argc;
prg->argv = argv;
- prg->ctxDepParsing = ctxDepParsing;
prg->rtd = rtd;
+ prg->ctxDepParsing = 1;
prg->global = 0;
prg->heap = 0;
prg->stdinVal = 0;
@@ -525,6 +526,7 @@ void initProgram( Program *prg, int argc, const char **argv, int ctxDepParsing,
prg->falseVal = (Tree*)falseInt;
prg->allocRunBuf = 0;
+ return prg;
}
void clearGlobal( Program *prg, Tree **sp )
@@ -559,7 +561,17 @@ Tree **stackAlloc()
PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0 );
}
-void runProgram( Program *prg )
+Tree **vm_root( struct ColmProgram *prg )
+{
+ return prg->vm_root;
+}
+
+Tree *returnVal( struct ColmProgram *prg )
+{
+ return prg->returnVal;
+}
+
+void colmRunProgram( Program *prg )
{
assert( sizeof(Int) <= sizeof(Tree) );
assert( sizeof(Str) <= sizeof(Tree) );
@@ -592,7 +604,7 @@ void runProgram( Program *prg )
}
}
-void clearProgram( Program *prg )
+void colmDeleteProgram( Program *prg )
{
Tree **vm_stack = prg->vm_stack;
Tree **sp = prg->vm_root;
@@ -673,6 +685,8 @@ void clearProgram( Program *prg )
free( rb );
rb = next;
}
+
+ free( prg );
}
diff --git a/colm/bytecode.h b/colm/bytecode.h
index e64561e7..f6b7a11a 100644
--- a/colm/bytecode.h
+++ b/colm/bytecode.h
@@ -471,13 +471,7 @@ void reverseExecution( Execution *exec, Tree **sp, RtCodeVect *allRev );
Kid *allocAttrs( Program *prg, long length );
void freeAttrs( Program *prg, Kid *attrs );
void setAttr( Tree *tree, long pos, Tree *val );
-Tree *getAttr( Tree *tree, long pos );
Kid *getAttrKid( Tree *tree, long pos );
-Tree *getRhsVal( Program *prg, Tree *tree, int *a );
-Tree *getRepeatNext( Tree *tree );
-int repeatEnd( Tree *tree );
-int listLast( Tree *tree );
-Tree *getRepeatVal( Tree *tree );
Tree *splitTree( Program *prg, Tree *t );
void rcodeDownrefAll( Program *prg, Tree **sp, RtCodeVect *cv );
@@ -491,12 +485,6 @@ void executeCode( Execution *exec, Tree **sp, Code *instr );
void rcodeDownref( Program *prg, Tree **sp, Code *instr );
Tree **stackAlloc();
-void initColm( long debugRealm );
-void initProgram( Program *program, int argc, const char **argv,
- int ctxDepParsing, RuntimeData *rtd );
-void runProgram( Program *prg );
-void clearProgram( Program *prg );
-
#ifdef __cplusplus
}
#endif
diff --git a/colm/codegen.cc b/colm/codegen.cc
index dbf742ce..41190923 100644
--- a/colm/codegen.cc
+++ b/colm/codegen.cc
@@ -47,7 +47,7 @@ void ParseData::generateExports()
"\n";
out <<
- "inline void appendString( PrintArgs *args, const char *data, int length )\n"
+ "inline void appendString( ColmPrintArgs *args, const char *data, int length )\n"
"{\n"
" std::string *str = (std::string*)args->arg;\n"
" *str += std::string( data, length );\n"
@@ -55,12 +55,12 @@ void ParseData::generateExports()
"\n";
out <<
- "inline std::string printTreeStr( Program *prg, Tree *tree )\n"
+ "inline std::string printTreeStr( ColmProgram *prg, ColmTree *tree )\n"
"{\n"
" std::string str;\n"
- " PrintArgs printArgs = { &str, 1, 0, &appendString, \n"
+ " ColmPrintArgs printArgs = { &str, 1, 0, &appendString, \n"
" &printNull, &printTermTree, &printNull };\n"
- " printTreeArgs( &printArgs, prg->vm_root, prg, tree );\n"
+ " printTreeArgs( &printArgs, vm_root(prg), prg, tree );\n"
" return str;\n"
"}\n"
"\n";
@@ -72,16 +72,15 @@ void ParseData::generateExports()
for ( LelList::Iter lel = langEls; lel.lte(); lel++ ) {
out << "struct " << lel->fullName << "\n";
out << "{\n";
- out << " Head *data() { return tree->tokdata; }\n";
out << " std::string text() { return printTreeStr( prg, tree ); }\n";
- out << " operator Tree *() { return tree; }\n";
- out << " Program *prg;\n";
- out << " Tree *tree;\n";
+ out << " operator ColmTree *() { return tree; }\n";
+ out << " ColmProgram *prg;\n";
+ out << " ColmTree *tree;\n";
if ( mainReturnUT != 0 && mainReturnUT->langEl == lel ) {
- out << " " << lel->fullName << "( Program *prg ) : prg(prg), tree(prg->returnVal) {}\n";
+ out << " " << lel->fullName << "( ColmProgram *prg ) : prg(prg), tree(returnVal(prg)) {}\n";
}
- out << " " << lel->fullName << "( Program *prg, Tree *tree ) : prg(prg), tree(tree) {}\n";
+ out << " " << lel->fullName << "( ColmProgram *prg, ColmTree *tree ) : prg(prg), tree(tree) {}\n";
if ( lel->objectDef != 0 && lel->objectDef->objFieldList != 0 ) {
ObjFieldList *objFieldList = lel->objectDef->objFieldList;
@@ -184,11 +183,11 @@ void FsmCodeGen::writeMain()
out <<
"int main( int argc, const char **argv )\n"
"{\n"
- " Program program;\n"
- " initColm( 0 );\n"
- " initProgram( &program, argc, argv, 1, &main_runtimeData );\n"
- " runProgram( &program );\n"
- " clearProgram( &program );\n"
+ " struct ColmProgram *prg;\n"
+ " colmInit( 0 );\n"
+ " prg = colmNewProgram( &main_runtimeData, argc, argv );\n"
+ " colmRunProgram( prg );\n"
+ " colmDeleteProgram( prg );\n"
" return 0;\n"
"}\n"
"\n";
diff --git a/colm/colm.h b/colm/colm.h
index a1be95ac..c73f694e 100644
--- a/colm/colm.h
+++ b/colm/colm.h
@@ -1,11 +1,54 @@
-#ifndef _COLM_H
-#define _COLM_H
-
-#include <colm/pdarun.h>
-#include <colm/fsmrun.h>
-#include <colm/bytecode.h>
-#include <colm/defs.h>
-#include <colm/input.h>
-#include <colm/tree.h>
+#ifndef __COLM_COLM_H
+#define __COLM_COLM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ColmTree;
+struct ColmKid;
+struct ColmProgram;
+struct ColmRuntimeData;
+
+void colmInit( long debugRealm );
+struct ColmProgram *colmNewProgram( struct ColmRuntimeData *rtd, int argc, const char **argv );
+void colmRunProgram( struct ColmProgram *prg );
+void colmDeleteProgram( struct ColmProgram *prg );
+
+struct ColmPrintArgs
+{
+ void *arg;
+ int comm;
+ int attr;
+ void (*out)( struct ColmPrintArgs *args, const char *data, int length );
+ void (*openTree)( struct ColmPrintArgs *args, struct ColmTree **sp,
+ struct ColmProgram *prg, struct ColmKid *parent, struct ColmKid *kid );
+ void (*printTerm)( struct ColmPrintArgs *args, struct ColmTree **sp,
+ struct ColmProgram *prg, struct ColmKid *kid );
+ void (*closeTree)( struct ColmPrintArgs *args, struct ColmTree **sp,
+ struct ColmProgram *prg, struct ColmKid *parent, struct ColmKid *kid );
+};
+
+void printNull( struct ColmPrintArgs *args, struct ColmTree **sp,
+ struct ColmProgram *prg, struct ColmKid *parent, struct ColmKid *kid );
+void printTermTree( struct ColmPrintArgs *printArgs, struct ColmTree **sp,
+ struct ColmProgram *prg, struct ColmKid *kid );
+
+struct ColmTree **vm_root( struct ColmProgram *prg );
+struct ColmTree *returnVal( struct ColmProgram *prg );
+void printTreeArgs( struct ColmPrintArgs *printArgs, struct ColmTree **sp,
+ struct ColmProgram *prg, struct ColmTree *tree );
+
+int repeatEnd( struct ColmTree *tree );
+int listLast( struct ColmTree *tree );
+struct ColmTree *getRhsVal( struct ColmProgram *prg, struct ColmTree *tree, int *a );
+struct ColmTree *getAttr( struct ColmTree *tree, long pos );
+struct ColmTree *getRepeatNext( struct ColmTree *tree );
+struct ColmTree *getRepeatVal( struct ColmTree *tree );
+
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/colm/fsmcodegen.cc b/colm/fsmcodegen.cc
index 64ea0cd7..60ffc026 100644
--- a/colm/fsmcodegen.cc
+++ b/colm/fsmcodegen.cc
@@ -1056,6 +1056,7 @@ void FsmCodeGen::writeCode()
"#include <colm/defs.h>\n"
"#include <colm/input.h>\n"
"#include <colm/tree.h>\n"
+ "#include <colm/colm.h>\n"
"\n"
"\n";
diff --git a/colm/fsmrun.h b/colm/fsmrun.h
index 649e898a..d2106f8e 100644
--- a/colm/fsmrun.h
+++ b/colm/fsmrun.h
@@ -28,6 +28,8 @@
extern "C" {
#endif
+struct ColmProgram;
+
#define MARK_SLOTS 32
typedef struct _FsmTables
@@ -64,11 +66,9 @@ typedef struct _FsmTables
long numActionSwitch;
} FsmTables;
-struct _Program;
-
typedef struct _FsmRun
{
- struct _Program *prg;
+ struct ColmProgram *prg;
FsmTables *tables;
RunBuf *runBuf;
@@ -82,11 +82,11 @@ typedef struct _FsmRun
long matchedToken;
InputStream *haveDataOf;
- struct _Tree *curStream;
+ struct ColmTree *curStream;
} FsmRun;
-void initFsmRun( FsmRun *fsmRun, struct _Program *prg );
-void clearFsmRun( struct _Program *prg, FsmRun *fsmRun );
+void initFsmRun( FsmRun *fsmRun, struct ColmProgram *prg );
+void clearFsmRun( struct ColmProgram *prg, FsmRun *fsmRun );
void updatePosition( InputStream *inputStream, const char *data, long length );
void undoPosition( InputStream *inputStream, const char *data, long length );
void takeBackBuffered( InputStream *inputStream );
diff --git a/colm/global.h b/colm/global.h
index 807b8561..24fd803f 100644
--- a/colm/global.h
+++ b/colm/global.h
@@ -19,8 +19,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _COLM_H
-#define _COLM_H
+#ifndef __COLM_GLOBAL_H
+#define __COLM_GLOBAL_H
#include <stdio.h>
#include <iostream>
@@ -87,5 +87,4 @@ void xmlEscapeHost( std::ostream &out, char *data, int len );
void openOutput();
void escapeLiteralString( std::ostream &out, const char *data );
-
-#endif /* _COLM_H */
+#endif
diff --git a/colm/input.h b/colm/input.h
index fa268979..18e372ab 100644
--- a/colm/input.h
+++ b/colm/input.h
@@ -54,7 +54,7 @@ struct PatternItem;
struct Replacement;
struct ReplItem;
struct _FsmRun;
-struct _Tree;
+struct ColmTree;
enum RunBufType {
RunBufDataType = 0,
@@ -67,7 +67,7 @@ typedef struct _RunBuf
enum RunBufType type;
char data[FSM_BUFSIZE];
long length;
- struct _Tree *tree;
+ struct ColmTree *tree;
long offset;
struct _RunBuf *next, *prev;
} RunBuf;
@@ -86,14 +86,14 @@ struct InputFuncs
int (*tryAgainLater)( InputStream *is );
int (*getData)( InputStream *is, char *dest, int length );
int (*getDataImpl)( InputStream *is, char *dest, int length );
- struct _Tree *(*getTree)( InputStream *is );
+ struct ColmTree *(*getTree)( InputStream *is );
struct LangEl *(*getLangEl)( InputStream *is, long *bindId, char **data, long *length );
- void (*pushTree)( InputStream *is, struct _Tree *tree, int ignore );
+ void (*pushTree)( InputStream *is, struct ColmTree *tree, int ignore );
void (*pushText)( InputStream *is, const char *data, long len );
- struct _Tree *(*undoPush)( InputStream *is, int length );
+ struct ColmTree *(*undoPush)( InputStream *is, int length );
void (*appendData)( InputStream *is, const char *data, long len );
- void (*appendTree)( InputStream *is, struct _Tree *tree );
- struct _Tree *(*undoAppend)( InputStream *is, int length );
+ void (*appendTree)( InputStream *is, struct ColmTree *tree );
+ struct ColmTree *(*undoAppend)( InputStream *is, int length );
void (*pushBackNamed)( InputStream *is );
void (*pushBackBuf)( InputStream *is, RunBuf *runBuf );
};
diff --git a/colm/lmparse.kh b/colm/lmparse.kh
index e2ffd5d6..a60d062d 100644
--- a/colm/lmparse.kh
+++ b/colm/lmparse.kh
@@ -104,6 +104,7 @@ struct Parser
ContextVect contextStack;
String curDefineId;
+ LelDefList *curDefList;
ProdElList *curProdElList;
PredType predType;
diff --git a/colm/lmparse.kl b/colm/lmparse.kl
index b7e1ce84..3f3c33ea 100644
--- a/colm/lmparse.kl
+++ b/colm/lmparse.kl
@@ -819,8 +819,6 @@ prod_el:
objField->isRhsGet = true;
RhsVal rhsVal( curDefList->length(), curProdElList->length() );
- cout << "rhs val: " << objField << " " << objField->name << " " <<
- rhsVal.prodNum << " " << rhsVal.childNum << endl;
objField->rhsVal.append( RhsVal( curDefList->length(), curProdElList->length() ) );
}
};
diff --git a/colm/parsedata.cc b/colm/parsedata.cc
index 63440d72..2cd25aa0 100644
--- a/colm/parsedata.cc
+++ b/colm/parsedata.cc
@@ -36,6 +36,7 @@
#include "fsmcodegen.h"
#include "fsmrun.h"
#include "pdarun.h"
+#include "colm.h"
using namespace std;
using std::ostringstream;
@@ -1330,8 +1331,10 @@ void ParseData::initEmptyScanners()
void ParseData::parsePatterns()
{
- Program prg;
- initProgram( &prg, 0, 0, false, runtimeData );
+ Program *prg = colmNewProgram( runtimeData, 0, 0 );
+
+ /* Turn off context-dependent parsing. */
+ prg->ctxDepParsing = 0;
Tree **vm_stack = stackAlloc();
Tree **root = &vm_stack[VM_STACK_SIZE];
@@ -1347,8 +1350,8 @@ void ParseData::parsePatterns()
FsmRun *fsmRun = new FsmRun;
repl->pdaRun = new PdaRun;
- initPdaRun( repl->pdaRun, &prg, pdaTables, fsmRun, repl->langEl->parserId, 0, false, 0 );
- initFsmRun( fsmRun, &prg );
+ initPdaRun( repl->pdaRun, prg, pdaTables, fsmRun, repl->langEl->parserId, 0, false, 0 );
+ initFsmRun( fsmRun, prg );
newToken( repl->pdaRun, fsmRun );
parseLoop( root, repl->pdaRun, fsmRun, in );
if ( repl->pdaRun->parseError )
@@ -1367,8 +1370,8 @@ void ParseData::parsePatterns()
FsmRun *fsmRun = new FsmRun;
pat->pdaRun = new PdaRun;
- initPdaRun( pat->pdaRun, &prg, pdaTables, fsmRun, pat->langEl->parserId, 0, false, 0 );
- initFsmRun( fsmRun, &prg );
+ initPdaRun( pat->pdaRun, prg, pdaTables, fsmRun, pat->langEl->parserId, 0, false, 0 );
+ initFsmRun( fsmRun, prg );
newToken( pat->pdaRun, fsmRun );
parseLoop( root, pat->pdaRun, fsmRun, in );
if ( pat->pdaRun->parseError )
@@ -1376,7 +1379,7 @@ void ParseData::parsePatterns()
free( in );
}
- fillInPatterns( &prg );
+ fillInPatterns( prg );
}
void ParseData::collectParserEls( BstSet<LangEl*> &parserEls )
diff --git a/colm/pdarun.h b/colm/pdarun.h
index 7f686600..a0052d6a 100644
--- a/colm/pdarun.h
+++ b/colm/pdarun.h
@@ -71,23 +71,23 @@ typedef struct _Head
Location *location;
} Head;
-typedef struct _Kid
+typedef struct ColmKid
{
/* The tree needs to be first since pointers to kids are used to reference
* trees on the stack. A pointer to the word that is a Tree* is cast to
* a Kid*. */
- struct _Tree *tree;
- struct _Kid *next;
+ struct ColmTree *tree;
+ struct ColmKid *next;
unsigned char flags;
} Kid;
typedef struct _Ref
{
- struct _Kid *kid;
+ struct ColmKid *kid;
struct _Ref *next;
} Ref;
-typedef struct _Tree
+typedef struct ColmTree
{
/* First four will be overlaid in other structures. */
short id;
@@ -339,7 +339,7 @@ typedef struct _CaptureAttr
long offset;
} CaptureAttr;
-typedef struct _RuntimeData
+typedef struct ColmRuntimeData
{
LangElInfo *lelInfo;
long numLangEls;
@@ -442,7 +442,7 @@ typedef struct _PoolAlloc
int sizeofT;
} PoolAlloc;
-typedef struct _Program
+typedef struct ColmProgram
{
int argc;
const char **argv;
diff --git a/colm/tree.c b/colm/tree.c
index f80aa705..f2269c01 100644
--- a/colm/tree.c
+++ b/colm/tree.c
@@ -1856,7 +1856,7 @@ Tree *treeSearch2( Program *prg, Tree *tree, long id )
return res;
}
-void xmlEscapeData( PrintArgs *printArgs, const char *data, long len )
+void xmlEscapeData( struct ColmPrintArgs *printArgs, const char *data, long len )
{
int i;
for ( i = 0; i < len; i++ ) {
@@ -1906,17 +1906,17 @@ void strCollectClear( StrCollect *collect )
#define INT_SZ 32
-void printStr( PrintArgs *printArgs, Head *str )
+void printStr( struct ColmPrintArgs *printArgs, Head *str )
{
printArgs->out( printArgs, (char*)(str->data), str->length );
}
-void appendCollect( PrintArgs *args, const char *data, int length )
+void appendCollect( struct ColmPrintArgs *args, const char *data, int length )
{
strCollectAppend( (StrCollect*) args->arg, data, length );
}
-void appendFile( PrintArgs *args, const char *data, int length )
+void appendFile( struct ColmPrintArgs *args, const char *data, int length )
{
fwrite( data, length, 1, (FILE*)args->arg );
}
@@ -1939,7 +1939,7 @@ enum ReturnType
/* Note that this function causes recursion, thought it is not a big
* deal since the recursion it is only caused by nonterminals that are ignored. */
-void printKid( PrintArgs *printArgs, Tree **sp, Program *prg, Kid *kid )
+void printKid( struct ColmPrintArgs *printArgs, Tree **sp, Program *prg, Kid *kid )
{
LangElInfo *lelInfo = prg->rtd->lelInfo;
Tree **root = vm_ptop();
@@ -2160,7 +2160,7 @@ skip_null:
}
}
-void printTreeArgs( PrintArgs *printArgs, Tree **sp, Program *prg, Tree *tree )
+void printTreeArgs( struct ColmPrintArgs *printArgs, Tree **sp, Program *prg, Tree *tree )
{
if ( tree == 0 )
printArgs->out( printArgs, "NIL", 3 );
@@ -2181,7 +2181,7 @@ void printTreeArgs( PrintArgs *printArgs, Tree **sp, Program *prg, Tree *tree )
}
}
-void printTermTree( PrintArgs *printArgs, Tree **sp, Program *prg, Kid *kid )
+void printTermTree( struct ColmPrintArgs *printArgs, Tree **sp, Program *prg, Kid *kid )
{
debug( REALM_PRINT, "printing term %p\n", kid->tree );
@@ -2220,11 +2220,11 @@ void printTermTree( PrintArgs *printArgs, Tree **sp, Program *prg, Kid *kid )
}
-void printNull( struct _PrintArgs *args, Tree **sp, Program *prg, Kid *parent, Kid *kid )
+void printNull( struct ColmPrintArgs *args, Tree **sp, Program *prg, Kid *parent, Kid *kid )
{
}
-void openTreeXml( struct _PrintArgs *args, Tree **sp, Program *prg, Kid *parent, Kid *kid )
+void openTreeXml( struct ColmPrintArgs *args, Tree **sp, Program *prg, Kid *parent, Kid *kid )
{
/* Skip the terminal that is for forcing trailing ignores out. */
if ( kid->tree->id == 0 )
@@ -2256,7 +2256,7 @@ void openTreeXml( struct _PrintArgs *args, Tree **sp, Program *prg, Kid *parent,
objectLength = lelInfo[kid->tree->id].objectLength;
}
-void printTermXml( PrintArgs *printArgs, Tree **sp, Program *prg, Kid *kid )
+void printTermXml( struct ColmPrintArgs *printArgs, Tree **sp, Program *prg, Kid *kid )
{
int i, depth = 1, objectLength;
LangElInfo *lelInfo = prg->rtd->lelInfo;
@@ -2298,7 +2298,7 @@ void printTermXml( PrintArgs *printArgs, Tree **sp, Program *prg, Kid *kid )
}
-void closeTreeXml( struct _PrintArgs *args, Tree **sp, Program *prg, Kid *parent, Kid *kid )
+void closeTreeXml( struct ColmPrintArgs *args, Tree **sp, Program *prg, Kid *parent, Kid *kid )
{
/* Skip the terminal that is for forcing trailing ignores out. */
if ( kid->tree->id == 0 )
@@ -2328,21 +2328,21 @@ void closeTreeXml( struct _PrintArgs *args, Tree **sp, Program *prg, Kid *parent
void printTreeCollect( StrCollect *collect, Tree **sp, Program *prg, Tree *tree )
{
- PrintArgs printArgs = { collect, 1, 0, &appendCollect,
+ struct ColmPrintArgs printArgs = { collect, 1, 0, &appendCollect,
&printNull, &printTermTree, &printNull };
printTreeArgs( &printArgs, sp, prg, tree );
}
void printTreeFile( FILE *out, Tree **sp, Program *prg, Tree *tree )
{
- PrintArgs printArgs = { out, 1, 0, &appendFile,
+ struct ColmPrintArgs printArgs = { out, 1, 0, &appendFile,
&printNull, &printTermTree, &printNull };
printTreeArgs( &printArgs, sp, prg, tree );
}
void printXmlStdout( Tree **sp, Program *prg, Tree *tree, int commAttr )
{
- PrintArgs printArgs = { stdout, commAttr, commAttr, &appendFile,
+ struct ColmPrintArgs printArgs = { stdout, commAttr, commAttr, &appendFile,
&openTreeXml, &printTermXml, &closeTreeXml };
printTreeArgs( &printArgs, sp, prg, tree );
}
diff --git a/colm/tree.h b/colm/tree.h
index 9b530f90..248c66b8 100644
--- a/colm/tree.h
+++ b/colm/tree.h
@@ -19,13 +19,15 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TREE_H
-#define _TREE_H
+#ifndef __COLM_TREE_H
+#define __COLM_TREE_H
#if defined(__cplusplus)
extern "C" {
#endif
+#include <colm/colm.h>
+
typedef struct _TreePair
{
Tree *key;
@@ -112,17 +114,6 @@ typedef struct _StrCollect
int length;
} StrCollect;
-typedef struct _PrintArgs
-{
- void *arg;
- int comm;
- int attr;
- void (*out)( struct _PrintArgs *args, const char *data, int length );
- void (*openTree)( struct _PrintArgs *args, Tree **sp, Program *prg, Kid *parent, Kid *kid );
- void (*printTerm)( struct _PrintArgs *args, Tree **sp, Program *prg, Kid *kid );
- void (*closeTree)( struct _PrintArgs *args, Tree **sp, Program *prg, Kid *parent, Kid *kid );
-} PrintArgs;
-
void initStrCollect( StrCollect *collect );
void strCollectDestroy( StrCollect *collect );
void strCollectAppend( StrCollect *collect, const char *data, long len );
@@ -130,10 +121,8 @@ void strCollectClear( StrCollect *collect );
void printTree( StrCollect *collect, Tree **sp, Program *prg, Tree *tree );
-void printTermTree( PrintArgs *printArgs, Tree **sp, Program *prg, Kid *kid );
-void printNull( struct _PrintArgs *args, Tree **sp, Program *prg, Kid *parent, Kid *kid );
+void printTermTree( struct ColmPrintArgs *printArgs, Tree **sp, Program *prg, Kid *kid );
-void printTreeArgs( PrintArgs *printArgs, Tree **sp, Program *prg, Tree *tree );
void printTreeCollect( StrCollect *collect, Tree **sp, Program *prg, Tree *tree );
void printTreeFile( FILE *out, Tree **sp, Program *prg, Tree *tree );