summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog23
-rw-r--r--colm/Makefile.am4
-rw-r--r--colm/bytecode.h42
-rw-r--r--colm/codegen.cc9
-rw-r--r--colm/colm.h85
-rw-r--r--colm/compiler.cc2
-rw-r--r--colm/debug.c2
-rw-r--r--colm/debug.h4
-rw-r--r--colm/exports.cc54
-rw-r--r--colm/global.h9
-rw-r--r--colm/input.c8
-rw-r--r--colm/input.h32
-rw-r--r--colm/loadcolm.cc17
-rw-r--r--colm/loadinit.cc8
-rw-r--r--colm/main.cc170
-rw-r--r--colm/pdabuild.cc2
-rw-r--r--colm/pdacodegen.cc4
-rw-r--r--colm/pdarun.h32
-rw-r--r--colm/program.c23
-rw-r--r--colm/program.h6
-rw-r--r--colm/tree.c78
-rw-r--r--colm/tree.h118
-rw-r--r--test/accum3.lm2
-rw-r--r--test/argv1.lm2
-rw-r--r--test/context1.lm5
-rwxr-xr-xtest/runtests.sh2
26 files changed, 402 insertions, 341 deletions
diff --git a/ChangeLog b/ChangeLog
index e55d7802..47644b4e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,25 @@
-colm 0.9 - Feb 19, 2012
+colm 0.10 - April 18, 2013
+--------------------------
+ * Implemented the colm parser in colm. Bootstrapping with a parse tree
+ construction in C++. Using that generated parser to to parse the colm
+ grammar, from which the primary parser is produced.
+ * Improved error reporting.
+ * Added some tracking of progress through a stream for better
+ backtracking over includes that are pushed onto a stream.
+ * Updated the vim syntax, no longer highlighting parser, list, etc
+ (types).
+ * Parse expressions are now returning trees again. Returning the parser
+ results in semantics inconsistent with many other areas of the
+ program.
+ * Can now put '.' or eos on the end of a send expression to terminate
+ the parse
+ * Removed the original send syntax (<<).
+ * Lowercased and otherwise improved the C interface.
+ * The default binary name no longer has .bin suffix.
+ * Fixed -o option, now using -c to mean compile on (library). The
+ export filename options are now -e and -x.
+
+colm 0.9 - Feb 19, 2013
-----------------------
* The parse loop now scans data that is owned by the input stream. It
is copied into a contiguous block in the scanner when the token is
diff --git a/colm/Makefile.am b/colm/Makefile.am
index f3f42ba4..39c49f36 100644
--- a/colm/Makefile.am
+++ b/colm/Makefile.am
@@ -86,12 +86,12 @@ colmincdir = $(includedir)/colm
colminc_HEADERS = $(RUNTIME_HDR)
parse1.c: bootstrap0
- $(builddir)/bootstrap0 -L -o parse1.c -e if1.h -c if1.cc
+ $(builddir)/bootstrap0 -c -o parse1.c -e if1.h -E if1.cc
if1.h: parse1.c
if1.cc: parse1.c
parse2.c: bootstrap1 colm.lm
- $(builddir)/bootstrap1 -L -o parse2.c -e if2.h -c if2.cc colm.lm
+ $(builddir)/bootstrap1 -c -o parse2.c -e if2.h -E if2.cc colm.lm
if2.h: parse2.c
if2.cc: parse2.c
diff --git a/colm/bytecode.h b/colm/bytecode.h
index d7785afc..10343f5f 100644
--- a/colm/bytecode.h
+++ b/colm/bytecode.h
@@ -432,10 +432,10 @@ typedef unsigned char uchar;
#define vm_local_iframe(o) (exec->iframePtr[o])
#define vm_plocal_iframe(o) (&exec->iframePtr[o])
-void vm_init( struct ColmProgram * );
-Tree** vm_bs_add( struct ColmProgram *, Tree **, int );
-Tree** vm_bs_pop( struct ColmProgram *, Tree **, int );
-void vm_clear( struct ColmProgram * );
+void vm_init( struct colm_program * );
+Tree** vm_bs_add( struct colm_program *, Tree **, int );
+Tree** vm_bs_pop( struct colm_program *, Tree **, int );
+void vm_clear( struct colm_program * );
typedef Tree *SW;
typedef Tree **StackPtr;
@@ -461,10 +461,10 @@ typedef struct _Execution
long stringLength( Head *str );
const char *stringData( Head *str );
-Head *stringAllocFull( struct ColmProgram *prg, const char *data, long length );
+Head *stringAllocFull( struct colm_program *prg, const char *data, long length );
Head *initStrSpace( long length );
-Head *stringCopy( struct ColmProgram *prg, Head *head );
-void stringFree( struct ColmProgram *prg, Head *head );
+Head *stringCopy( struct colm_program *prg, Head *head );
+void stringFree( struct colm_program *prg, Head *head );
void stringShorten( Head *tokdata, long newlen );
Head *concatStr( Head *s1, Head *s2 );
Word strAtoi( Head *str );
@@ -473,32 +473,32 @@ Word strUord8( Head *head );
Word cmpString( Head *s1, Head *s2 );
Head *stringToUpper( Head *s );
Head *stringToLower( Head *s );
-Head *stringSprintf( struct ColmProgram *prg, Str *format, Int *integer );
+Head *stringSprintf( struct colm_program *prg, Str *format, Int *integer );
-Head *makeLiteral( struct ColmProgram *prg, long litoffset );
-Head *intToStr( struct ColmProgram *prg, Word i );
+Head *makeLiteral( struct colm_program *prg, long litoffset );
+Head *intToStr( struct colm_program *prg, Word i );
-Tree *constructString( struct ColmProgram *prg, Head *s );
+Tree *constructString( struct colm_program *prg, Head *s );
-void mainExecution( struct ColmProgram *prg, Execution *exec, Code *code );
+void mainExecution( struct colm_program *prg, Execution *exec, Code *code );
void reductionExecution( Execution *exec, Tree **sp );
void generationExecution( Execution *exec, Tree **sp );
void reverseExecution( Execution *exec, Tree **sp, RtCodeVect *allRev );
-Kid *allocAttrs( struct ColmProgram *prg, long length );
-void freeAttrs( struct ColmProgram *prg, Kid *attrs );
+Kid *allocAttrs( struct colm_program *prg, long length );
+void freeAttrs( struct colm_program *prg, Kid *attrs );
void setAttr( Tree *tree, long pos, Tree *val );
Kid *getAttrKid( Tree *tree, long pos );
-Tree *splitTree( struct ColmProgram *prg, Tree *t );
-void rcodeDownrefAll( struct ColmProgram *prg, Tree **sp, RtCodeVect *cv );
-void commitFull( struct ColmProgram *prg, Tree **sp, PdaRun *pdaRun, long commitReduce );
+Tree *splitTree( struct colm_program *prg, Tree *t );
+void rcodeDownrefAll( struct colm_program *prg, Tree **sp, RtCodeVect *cv );
+void commitFull( struct colm_program *prg, Tree **sp, PdaRun *pdaRun, long commitReduce );
Tree *getParsedRoot( PdaRun *pdaRun, int stop );
-void splitRef( struct ColmProgram *prg, Tree ***sp, Ref *fromRef );
+void splitRef( struct colm_program *prg, Tree ***sp, Ref *fromRef );
-void allocGlobal( struct ColmProgram *prg );
-Tree **executeCode( struct ColmProgram *prg, Execution *exec, Tree **sp, Code *instr );
-void rcodeDownref( struct ColmProgram *prg, Tree **sp, Code *instr );
+void allocGlobal( struct colm_program *prg );
+Tree **executeCode( struct colm_program *prg, Execution *exec, Tree **sp, Code *instr );
+void rcodeDownref( struct colm_program *prg, Tree **sp, Code *instr );
Code *popReverseCode( RtCodeVect *allRev );
#ifdef __cplusplus
diff --git a/colm/codegen.cc b/colm/codegen.cc
index b08d464c..b48ebbb7 100644
--- a/colm/codegen.cc
+++ b/colm/codegen.cc
@@ -33,11 +33,12 @@ void FsmCodeGen::writeMain( long activeRealm )
out <<
"int main( int argc, const char **argv )\n"
"{\n"
- " struct ColmProgram *prg;\n"
+ " struct colm_program *prg;\n"
" int exitStatus;\n"
- " prg = colmNewProgram( &main_runtimeData, " << activeRealm << " );\n"
- " colmRunProgram( prg, argc, argv );\n"
- " exitStatus = colmDeleteProgram( prg );\n"
+ " prg = colm_new_program( &colm_object );\n"
+ " colm_set_debug( prg, " << activeRealm << " );\n"
+ " colm_run_program( prg, argc, argv );\n"
+ " exitStatus = colm_delete_program( prg );\n"
" return exitStatus;\n"
"}\n"
"\n";
diff --git a/colm/colm.h b/colm/colm.h
index f5183be2..b83cd7a1 100644
--- a/colm/colm.h
+++ b/colm/colm.h
@@ -5,51 +5,60 @@
extern "C" {
#endif
-struct ColmTree;
-struct ColmKid;
-struct ColmProgram;
-struct ColmRuntimeData;
-struct ColmTree;
-struct ColmLocation;
-
-struct ColmProgram *colmNewProgram( struct ColmRuntimeData *rtd, long debugRealm );
-void colmRunProgram( struct ColmProgram *prg, int argc, const char **argv );
-struct ColmTree *colmRunFunc( struct ColmProgram *prg, int frameId, const char **params, int paramCount );
-int colmDeleteProgram( struct ColmProgram *prg );
-
-struct ColmPrintArgs
+struct colm_tree;
+struct colm_kid;
+struct colm_program;
+struct colm_sections;
+struct colm_tree;
+struct colm_location;
+
+/*
+ * Interface
+ */
+
+struct colm_print_args
{
void *arg;
int comm;
int attr;
int trim;
- void (*out)( struct ColmPrintArgs *args, const char *data, int length );
- void (*openTree)( struct ColmProgram *prg, struct ColmTree **sp,
- struct ColmPrintArgs *args, struct ColmKid *parent, struct ColmKid *kid );
- void (*printTerm)( struct ColmProgram *prg, struct ColmTree **sp,
- struct ColmPrintArgs *args, struct ColmKid *kid );
- void (*closeTree)( struct ColmProgram *prg, struct ColmTree **sp,
- struct ColmPrintArgs *args, struct ColmKid *parent, struct ColmKid *kid );
+ void (*out)( struct colm_print_args *args, const char *data, int length );
+ void (*open_tree)( struct colm_program *prg, struct colm_tree **sp,
+ struct colm_print_args *args, struct colm_kid *parent, struct colm_kid *kid );
+ void (*print_term)( struct colm_program *prg, struct colm_tree **sp,
+ struct colm_print_args *args, struct colm_kid *kid );
+ void (*close_tree)( struct colm_program *prg, struct colm_tree **sp,
+ struct colm_print_args *args, struct colm_kid *parent, struct colm_kid *kid );
};
-void printNull( struct ColmProgram *prg, struct ColmTree **sp,
- struct ColmPrintArgs *args, struct ColmKid *parent, struct ColmKid *kid );
-void printTermTree( struct ColmProgram *prg, struct ColmTree **sp,
- struct ColmPrintArgs *printArgs, struct ColmKid *kid );
-
-struct ColmTree **vm_root( struct ColmProgram *prg );
-struct ColmTree *returnVal( struct ColmProgram *prg );
-void printTreeArgs( struct ColmProgram *prg, struct ColmTree **sp,
- struct ColmPrintArgs *printArgs, 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 *getGlobal( struct ColmProgram *prg, long pos );
-struct ColmTree *getRepeatNext( struct ColmTree *tree );
-struct ColmTree *getRepeatVal( struct ColmTree *tree );
-struct ColmLocation *findLocation( struct ColmProgram *prg, struct ColmTree *tree );
+void colm_print_null( struct colm_program *prg, struct colm_tree **sp,
+ struct colm_print_args *args, struct colm_kid *parent, struct colm_kid *kid );
+void colm_print_term_tree( struct colm_program *prg, struct colm_tree **sp,
+ struct colm_print_args *print_args, struct colm_kid *kid );
+
+struct colm_tree **colm_vm_root( struct colm_program *prg );
+struct colm_tree *colm_return_val( struct colm_program *prg );
+void colm_print_tree_args( struct colm_program *prg, struct colm_tree **sp,
+ struct colm_print_args *print_args, struct colm_tree *tree );
+
+int colm_repeat_end( struct colm_tree *tree );
+int colm_list_last( struct colm_tree *tree );
+struct colm_tree *colm_get_rhs_val( struct colm_program *prg, struct colm_tree *tree, int *a );
+struct colm_tree *colm_get_attr( struct colm_tree *tree, long pos );
+struct colm_tree *colm_get_global( struct colm_program *prg, long pos );
+struct colm_tree *colm_get_repeat_next( struct colm_tree *tree );
+struct colm_tree *colm_get_repeat_val( struct colm_tree *tree );
+struct colm_location *colm_find_location( struct colm_program *prg, struct colm_tree *tree );
+
+/*
+ * Primary interface.
+ */
+
+struct colm_program *colm_new_program( struct colm_sections *rtd );
+void colm_set_debug( struct colm_program *prg, long active_realm );
+void colm_run_program( struct colm_program *prg, int argc, const char **argv );
+struct colm_tree *colm_run_func( struct colm_program *prg, int frame_id, const char **params, int param_count );
+int colm_delete_program( struct colm_program *prg );
#ifdef __cplusplus
}
diff --git a/colm/compiler.cc b/colm/compiler.cc
index 7f7d6368..8f6ca8d3 100644
--- a/colm/compiler.cc
+++ b/colm/compiler.cc
@@ -1004,7 +1004,7 @@ PdaRun *Compiler::parsePattern( Program *prg, Tree **sp, const InputLoc &loc,
void Compiler::parsePatterns()
{
- Program *prg = colmNewProgram( runtimeData, 0 );
+ Program *prg = colm_new_program( runtimeData );
/* Turn off context-dependent parsing. */
prg->ctxDepParsing = 0;
diff --git a/colm/debug.c b/colm/debug.c
index 2dc8328b..c43f5a68 100644
--- a/colm/debug.c
+++ b/colm/debug.c
@@ -37,7 +37,7 @@ const char *const colmRealmNames[REALMS] =
"SCAN",
};
-int _debug( struct ColmProgram *prg, long realm, const char *fmt, ... )
+int _debug( struct colm_program *prg, long realm, const char *fmt, ... )
{
int result = 0;
if ( prg->activeRealm & realm ) {
diff --git a/colm/debug.h b/colm/debug.h
index aa5656ff..91e1c46c 100644
--- a/colm/debug.h
+++ b/colm/debug.h
@@ -35,9 +35,9 @@ void fatal( const char *fmt, ... );
#define check_realm( realm )
#endif
-struct ColmProgram;
+struct colm_program;
-int _debug( struct ColmProgram *prg, long realm, const char *fmt, ... );
+int _debug( struct colm_program *prg, long realm, const char *fmt, ... );
void message( const char *fmt, ... );
diff --git a/colm/exports.cc b/colm/exports.cc
index 73ac48fe..7c02c2b8 100644
--- a/colm/exports.cc
+++ b/colm/exports.cc
@@ -64,7 +64,7 @@ void Compiler::generateExports()
"\n";
out <<
- "inline void appendString( ColmPrintArgs *args, const char *data, int length )\n"
+ "inline void appendString( colm_print_args *args, const char *data, int length )\n"
"{\n"
" std::string *str = (std::string*)args->arg;\n"
" *str += std::string( data, length );\n"
@@ -72,12 +72,12 @@ void Compiler::generateExports()
"\n";
out <<
- "inline std::string printTreeStr( ColmProgram *prg, ColmTree *tree, bool trim )\n"
+ "inline std::string printTreeStr( colm_program *prg, colm_tree *tree, bool trim )\n"
"{\n"
" std::string str;\n"
- " ColmPrintArgs printArgs = { &str, 1, 0, trim, &appendString, \n"
- " &printNull, &printTermTree, &printNull };\n"
- " printTreeArgs( prg, vm_root(prg), &printArgs, tree );\n"
+ " colm_print_args printArgs = { &str, 1, 0, trim, &appendString, \n"
+ " &colm_print_null, &colm_print_term_tree, &colm_print_null };\n"
+ " colm_print_tree_args( prg, colm_vm_root(prg), &printArgs, tree );\n"
" return str;\n"
"}\n"
"\n";
@@ -102,16 +102,16 @@ void Compiler::generateExports()
out << "struct " << lel->fullName << "\n";
out << "{\n";
out << " std::string text() { return printTreeStr( __prg, __tree, true ); }\n";
- out << " ColmLocation *loc() { return findLocation( __prg, __tree ); }\n";
+ out << " colm_location *loc() { return colm_find_location( __prg, __tree ); }\n";
out << " std::string text_notrim() { return printTreeStr( __prg, __tree, false ); }\n";
- out << " operator ColmTree *() { return __tree; }\n";
- out << " ColmProgram *__prg;\n";
- out << " ColmTree *__tree;\n";
+ out << " operator colm_tree *() { return __tree; }\n";
+ out << " colm_program *__prg;\n";
+ out << " colm_tree *__tree;\n";
if ( mainReturnUT != 0 && mainReturnUT->langEl == lel ) {
- out << " " << lel->fullName << "( ColmProgram *prg ) : __prg(prg), __tree(returnVal(prg)) {}\n";
+ out << " " << lel->fullName << "( colm_program *prg ) : __prg(prg), __tree(returnVal(prg)) {}\n";
}
- out << " " << lel->fullName << "( ColmProgram *prg, ColmTree *tree ) : __prg(prg), __tree(tree) {}\n";
+ out << " " << lel->fullName << "( colm_program *prg, colm_tree *tree ) : __prg(prg), __tree(tree) {}\n";
if ( lel->objectDef != 0 && lel->objectDef->objFieldList != 0 ) {
ObjFieldList *objFieldList = lel->objectDef->objFieldList;
@@ -136,13 +136,13 @@ void Compiler::generateExports()
}
if ( lel->isRepeat ) {
- out << " " << "int end() { return repeatEnd( __tree ); }\n";
+ out << " " << "int end() { return colm_repeat_end( __tree ); }\n";
out << " " << lel->refName << " next();\n";
out << " " << lel->repeatOf->refName << " value();\n";
}
if ( lel->isList ) {
- out << " " << "int last() { return listLast( __tree ); }\n";
+ out << " " << "int last() { return colm_list_last( __tree ); }\n";
out << " " << lel->refName << " next();\n";
out << " " << lel->repeatOf->refName << " value();\n";
}
@@ -156,7 +156,7 @@ void Compiler::generateExports()
if ( field->isExport ) {
UniqueType *ut = field->typeRef->lookupType(this);
if ( ut != 0 && ut->typeId == TYPE_TREE ) {
- out << ut->langEl->refName << " " << field->name << "( ColmProgram *prg );\n";
+ out << ut->langEl->refName << " " << field->name << "( colm_program *prg );\n";
}
}
}
@@ -168,7 +168,7 @@ void Compiler::generateExports()
char *refName = func->typeRef->uniqueType->langEl->refName;
int paramCount = func->paramList->length();
out <<
- refName << " " << func->name << "( ColmProgram *prg";
+ refName << " " << func->name << "( colm_program *prg";
for ( int p = 0; p < paramCount; p++ )
out << ", const char *p" << p;
@@ -184,8 +184,8 @@ void Compiler::generateExportsImpl()
{
ostream &out = *outStream;
- if ( gblExportTo != 0 ) {
- out << "#include \"" << gblExportTo << "\"\n";
+ if ( exportHeaderFn != 0 ) {
+ out << "#include \"" << exportHeaderFn << "\"\n";
}
/* Function implementations. */
@@ -200,7 +200,7 @@ void Compiler::generateExportsImpl()
if ( ut != 0 && ut->typeId == TYPE_TREE ) {
out << ut->langEl->refName << " " << lel->declName << "::" << field->name <<
"() { return " << ut->langEl->refName <<
- "( __prg, getAttr( __tree, " << field->offset << ") ); }\n";
+ "( __prg, colm_get_attr( __tree, " << field->offset << ") ); }\n";
}
}
@@ -219,7 +219,7 @@ void Compiler::generateExportsImpl()
}
out << "}; return " << ut->langEl->refName <<
- "( __prg, getRhsVal( __prg, __tree, a ) ); }\n";
+ "( __prg, colm_get_rhs_val( __prg, __tree, a ) ); }\n";
}
}
}
@@ -228,22 +228,22 @@ void Compiler::generateExportsImpl()
if ( lel->isRepeat ) {
out << lel->refName << " " << lel->declName << "::" << " next"
"() { return " << lel->refName <<
- "( __prg, getRepeatNext( __tree ) ); }\n";
+ "( __prg, colm_get_repeat_next( __tree ) ); }\n";
out << lel->repeatOf->refName << " " << lel->declName << "::" << " value"
"() { return " << lel->repeatOf->refName <<
- "( __prg, getRepeatVal( __tree ) ); }\n";
+ "( __prg, colm_get_repeat_val( __tree ) ); }\n";
}
if ( lel->isList ) {
out << lel->refName << " " << lel->declName << "::" << " next"
"() { return " << lel->refName <<
- "( __prg, getRepeatNext( __tree ) ); }\n";
+ "( __prg, colm_get_repeat_next( __tree ) ); }\n";
out << lel->repeatOf->refName << " " << lel->declName << "::" << " value"
"() { return " << lel->repeatOf->refName <<
- "( __prg, getRepeatVal( __tree ) ); }\n";
+ "( __prg, colm_get_repeat_val( __tree ) ); }\n";
}
}
@@ -255,8 +255,8 @@ void Compiler::generateExportsImpl()
UniqueType *ut = field->typeRef->lookupType(this);
if ( ut != 0 && ut->typeId == TYPE_TREE ) {
out <<
- ut->langEl->refName << " " << field->name << "( ColmProgram *prg )\n"
- "{ return " << ut->langEl->refName << "( prg, getGlobal( prg, " <<
+ ut->langEl->refName << " " << field->name << "( colm_program *prg )\n"
+ "{ return " << ut->langEl->refName << "( prg, colm_get_global( prg, " <<
field->offset << ") ); }\n";
}
}
@@ -269,7 +269,7 @@ void Compiler::generateExportsImpl()
char *refName = func->typeRef->uniqueType->langEl->refName;
int paramCount = func->paramList->length();
out <<
- refName << " " << func->name << "( ColmProgram *prg";
+ refName << " " << func->name << "( colm_program *prg";
for ( int p = 0; p < paramCount; p++ )
out << ", const char *p" << p;
@@ -284,7 +284,7 @@ void Compiler::generateExportsImpl()
out <<
" return " << refName <<
- "( prg, colmRunFunc( prg, funcId, params, " << paramCount << " ));\n"
+ "( prg, colm_run_func( prg, funcId, params, " << paramCount << " ));\n"
"}\n";
}
}
diff --git a/colm/global.h b/colm/global.h
index 1f7a0b90..2dd6e4f1 100644
--- a/colm/global.h
+++ b/colm/global.h
@@ -42,7 +42,6 @@ extern int gblErrorCount;
std::ostream &error();
/* IO filenames and stream. */
-extern const char *outputFileName;
extern std::ostream *outStream;
extern bool generateGraphviz;
extern bool branchPointInfo;
@@ -62,16 +61,16 @@ extern std::ostream *outStream;
extern bool printStatistics;
extern int gblErrorCount;
-extern char machineMain[];
extern bool gblLibrary;
-extern const char *gblExportTo;
+extern char machineMain[];
+extern const char *exportHeaderFn;
-struct ColmLocation;
+struct colm_location;
/* Location in an input file. */
struct InputLoc
{
- InputLoc( ColmLocation *pcloc );
+ InputLoc( colm_location *pcloc );
InputLoc() : fileName(0), line(-1), col(-1) {}
diff --git a/colm/input.c b/colm/input.c
index ee62af36..a41aa5b8 100644
--- a/colm/input.c
+++ b/colm/input.c
@@ -49,7 +49,7 @@ extern struct StreamFuncs fileFuncs;
extern struct StreamFuncs fdFuncs;
extern struct StreamFuncs streamFuncs;
-void clearSourceStream( struct ColmProgram *prg, Tree **sp, StreamImpl *sourceStream )
+void clearSourceStream( struct colm_program *prg, Tree **sp, StreamImpl *sourceStream )
{
RunBuf *buf = sourceStream->queue;
while ( buf != 0 ) {
@@ -352,7 +352,7 @@ void initStreamImpl( StreamImpl *is, const char *name )
is->byte = 0;
}
-void clearStreamImpl( struct ColmProgram *prg, Tree **sp, StreamImpl *inputStream )
+void clearStreamImpl( struct colm_program *prg, Tree **sp, StreamImpl *inputStream )
{
RunBuf *buf = inputStream->queue;
while ( buf != 0 ) {
@@ -758,7 +758,7 @@ static void _prependTree( StreamImpl *is, Tree *tree, int ignore )
inputStreamPrepend( is, newBuf );
}
-static void _prependStream( StreamImpl *in, struct ColmTree *tree )
+static void _prependStream( StreamImpl *in, struct colm_tree *tree )
{
/* Create a new buffer for the data. This is the easy implementation.
* Something better is needed here. It puts a max on the amount of
@@ -900,7 +900,7 @@ static void _appendTree( StreamImpl *is, Tree *tree )
ad->length = 0;
}
-static void _appendStream( StreamImpl *in, struct ColmTree *tree )
+static void _appendStream( StreamImpl *in, struct colm_tree *tree )
{
RunBuf *ad = newRunBuf();
diff --git a/colm/input.h b/colm/input.h
index f5b39b4d..1605ebce 100644
--- a/colm/input.h
+++ b/colm/input.h
@@ -63,9 +63,9 @@ struct PatternItem;
struct Constructor;
struct ConsItem;
struct _FsmRun;
-struct ColmTree;
-struct ColmLocation;
-struct ColmProgram;
+struct colm_tree;
+struct colm_location;
+struct colm_program;
enum RunBufType {
RunBufDataType = 0,
@@ -79,7 +79,7 @@ typedef struct _RunBuf
enum RunBufType type;
char data[FSM_BUFSIZE];
long length;
- struct ColmTree *tree;
+ struct colm_tree *tree;
long offset;
struct _RunBuf *next, *prev;
} RunBuf;
@@ -94,11 +94,11 @@ struct StreamFuncs
int (*getData)( StreamImpl *ss, char *dest, int length );
- int (*consumeData)( StreamImpl *ss, int length, struct ColmLocation *loc );
+ int (*consumeData)( StreamImpl *ss, int length, struct colm_location *loc );
int (*undoConsumeData)( StreamImpl *ss, const char *data, int length );
- struct ColmTree *(*consumeTree)( StreamImpl *ss );
- void (*undoConsumeTree)( StreamImpl *ss, struct ColmTree *tree, int ignore );
+ struct colm_tree *(*consumeTree)( StreamImpl *ss );
+ void (*undoConsumeTree)( StreamImpl *ss, struct colm_tree *tree, int ignore );
/* Language elments (compile-time). */
struct LangEl *(*consumeLangEl)( StreamImpl *ss, long *bindId, char **data, long *length );
@@ -112,19 +112,19 @@ struct StreamFuncs
/* Prepending to a stream. */
void (*prependData)( StreamImpl *in, const char *data, long len );
- void (*prependTree)( StreamImpl *is, struct ColmTree *tree, int ignore );
- void (*prependStream)( StreamImpl *in, struct ColmTree *tree );
+ void (*prependTree)( StreamImpl *is, struct colm_tree *tree, int ignore );
+ void (*prependStream)( StreamImpl *in, struct colm_tree *tree );
int (*undoPrependData)( StreamImpl *is, int length );
- struct ColmTree *(*undoPrependTree)( StreamImpl *is );
- struct ColmTree *(*undoPrependStream)( StreamImpl *in );
+ struct colm_tree *(*undoPrependTree)( StreamImpl *is );
+ struct colm_tree *(*undoPrependStream)( StreamImpl *in );
/* Appending to a stream. */
void (*appendData)( StreamImpl *in, const char *data, long len );
- void (*appendTree)( StreamImpl *in, struct ColmTree *tree );
- void (*appendStream)( StreamImpl *in, struct ColmTree *tree );
- struct ColmTree *(*undoAppendData)( StreamImpl *in, int length );
- struct ColmTree *(*undoAppendTree)( StreamImpl *in );
- struct ColmTree *(*undoAppendStream)( StreamImpl *in );
+ void (*appendTree)( StreamImpl *in, struct colm_tree *tree );
+ void (*appendStream)( StreamImpl *in, struct colm_tree *tree );
+ struct colm_tree *(*undoAppendData)( StreamImpl *in, int length );
+ struct colm_tree *(*undoAppendTree)( StreamImpl *in );
+ struct colm_tree *(*undoAppendStream)( StreamImpl *in );
};
/* List of source streams. Enables streams to be pushed/popped. */
diff --git a/colm/loadcolm.cc b/colm/loadcolm.cc
index 8c31813c..27f8cc79 100644
--- a/colm/loadcolm.cc
+++ b/colm/loadcolm.cc
@@ -33,9 +33,9 @@
#include "if2.h"
#include "colm/colm.h"
-extern RuntimeData main_runtimeData;
+extern RuntimeData colm_object;
-InputLoc::InputLoc( ColmLocation *pcloc )
+InputLoc::InputLoc( colm_location *pcloc )
{
if ( pcloc != 0 ) {
fileName = pcloc->name;
@@ -635,8 +635,8 @@ struct LoadColm
argv[0] = file.data;
argv[1] = 0;
- ColmProgram *program = colmNewProgram( &main_runtimeData, 0 );
- colmRunProgram( program, 1, argv );
+ colm_program *program = colm_new_program( &colm_object );
+ colm_run_program( program, 1, argv );
/* Extract the parse tree. */
start Start = ColmTree( program );
@@ -650,7 +650,7 @@ struct LoadColm
}
StmtList *stmtList = walkRootItemList( Start.RootItemList() );
- colmDeleteProgram( program );
+ colm_delete_program( program );
return stmtList;
}
@@ -1904,8 +1904,9 @@ void LoadColm::go( long activeRealm )
argv[0] = inputFileName;
argv[1] = 0;
- ColmProgram *program = colmNewProgram( &main_runtimeData, activeRealm );
- colmRunProgram( program, 1, argv );
+ colm_program *program = colm_new_program( &colm_object );
+ colm_set_debug( program, activeRealm );
+ colm_run_program( program, 1, argv );
/* Extract the parse tree. */
start Start = ColmTree( program );
@@ -1919,7 +1920,7 @@ void LoadColm::go( long activeRealm )
}
StmtList *stmtList = walkRootItemList( Start.RootItemList() );
- colmDeleteProgram( program );
+ colm_delete_program( program );
pd->rootCodeBlock = CodeBlock::cons( stmtList, 0 );
}
diff --git a/colm/loadinit.cc b/colm/loadinit.cc
index fc6d77b5..e2b1f812 100644
--- a/colm/loadinit.cc
+++ b/colm/loadinit.cc
@@ -36,7 +36,7 @@
using std::string;
-extern RuntimeData main_runtimeData;
+extern RuntimeData colm_object;
void LoadInit::walkProdElList( ProdElList *list, prod_el_list &prodElList )
{
@@ -338,8 +338,8 @@ void LoadInit::go( long activeRealm )
argv[0] = inputFileName;
argv[1] = 0;
- ColmProgram *program = colmNewProgram( &main_runtimeData, 0 );
- colmRunProgram( program, 1, argv );
+ colm_program *program = colm_new_program( &colm_object );
+ colm_run_program( program, 1, argv );
/* Extract the parse tree. */
start Start = ColmTree( program );
@@ -362,7 +362,7 @@ void LoadInit::go( long activeRealm )
ItemList = ItemList.next();
}
- colmDeleteProgram( program );
+ colm_delete_program( program );
consParseStmt( stmtList );
consExportTree( stmtList );
diff --git a/colm/main.cc b/colm/main.cc
index eba57960..6eef7516 100644
--- a/colm/main.cc
+++ b/colm/main.cc
@@ -77,10 +77,12 @@ InputLoc internal;
/* Io globals. */
istream *inStream = 0;
ostream *outStream = 0;
-const char *inputFileName = 0;
-const char *outputFileName = 0;
-const char *gblExportTo = 0;
-const char *gblExpImplTo = 0;
+const char *inputFn = 0;
+const char *outputFn = 0;
+const char *intermedFn = 0;
+const char *binaryFn = 0;
+const char *exportHeaderFn = 0;
+const char *exportCodeFn = 0;
bool exportCode = false;
bool generateGraphviz = false;
@@ -139,15 +141,15 @@ ostream &error()
/* Print the opening to a warning, then return the error ostream. */
ostream &warning( )
{
- cerr << "warning: " << inputFileName << ": ";
+ cerr << "warning: " << inputFn << ": ";
return cerr;
}
/* Print the opening to a warning in the input, then return the error ostream. */
ostream &warning( const InputLoc &loc )
{
- assert( inputFileName != 0 );
- cerr << "warning: " << inputFileName << ":" <<
+ assert( inputFn != 0 );
+ cerr << "warning: " << inputFn << ":" <<
loc.line << ":" << loc.col << ": ";
return cerr;
}
@@ -176,9 +178,9 @@ void usage()
" -h, -H, -?, --help print this usage and exit\n"
" -v --version print version information and exit\n"
" -o <file> write output to <file>\n"
-" -i show conflict information\n"
-" -d make colm verbose\n"
-" -l compile logging into the output executable\n"
+" -c compile only (don't produce binary)\n"
+" -e <file> write C++ export header to <file>\n"
+" -x <file> write C++ export code to <file>\n"
;
}
@@ -234,46 +236,74 @@ char *fileNameFromStem( const char *stemFile, const char *suffix )
if ( ppos != 0 )
len = ppos - stemFile;
- /* Make the return string from the stem and the suffix. */
- char *retVal = new char[ len + strlen( suffix ) + 1 ];
+ int slen = suffix != 0 ? strlen( suffix ) : 0;
+ char *retVal = new char[ len + slen + 1 ];
strncpy( retVal, stemFile, len );
- strcpy( retVal + len, suffix );
+ if ( suffix != 0 )
+ strcpy( retVal + len, suffix );
+ retVal[len+slen] = 0;
return retVal;
}
-
-/* Invoked by the parser when the root element is opened. */
-void openOutput( )
+void openOutputCompiled()
{
- /* If the output format is code and no output file name is given, then
- * make a default. */
- if ( outputFileName == 0 ) {
- const char *ext = findFileExtension( inputFileName );
- if ( ext != 0 && strcmp( ext, ".rh" ) == 0 )
- outputFileName = fileNameFromStem( inputFileName, ".h" );
- else {
- const char *defExtension = ".c";
- outputFileName = fileNameFromStem( inputFileName, defExtension );
+ if ( binaryFn == 0 )
+ binaryFn = fileNameFromStem( inputFn, 0 );
+
+ if ( intermedFn == 0 )
+ intermedFn = fileNameFromStem( binaryFn, ".c" );
+
+ if ( binaryFn != 0 && inputFn != 0 &&
+ strcmp( inputFn, binaryFn ) == 0 )
+ {
+ error() << "output file \"" << binaryFn <<
+ "\" is the same as the input file" << endl;
+ }
+
+ if ( intermedFn != 0 && inputFn != 0 &&
+ strcmp( inputFn, intermedFn ) == 0 )
+ {
+ error() << "intermediate file \"" << intermedFn <<
+ "\" is the same as the input file" << endl;
+ }
+
+ if ( intermedFn != 0 ) {
+ /* Open the output stream, attaching it to the filter. */
+ ofstream *outFStream = new ofstream( intermedFn );
+
+ if ( !outFStream->is_open() ) {
+ error() << "error opening " << intermedFn << " for writing" << endl;
+ exit(1);
}
+
+ outStream = outFStream;
}
+ else {
+ /* Writing out ot std out. */
+ outStream = &cout;
+ }
+}
- //debug( REALM_PARSE, "opening output file: %s\n", outputFileName );
+void openOutputLibrary()
+{
+ if ( outputFn == 0 )
+ outputFn = fileNameFromStem( inputFn, ".c" );
/* Make sure we are not writing to the same file as the input file. */
- if ( outputFileName != 0 && inputFileName != 0 &&
- strcmp( inputFileName, outputFileName ) == 0 )
+ if ( outputFn != 0 && inputFn != 0 &&
+ strcmp( inputFn, outputFn ) == 0 )
{
- error() << "output file \"" << outputFileName <<
+ error() << "output file \"" << outputFn <<
"\" is the same as the input file" << endl;
}
- if ( outputFileName != 0 ) {
+ if ( outputFn != 0 ) {
/* Open the output stream, attaching it to the filter. */
- ofstream *outFStream = new ofstream( outputFileName );
+ ofstream *outFStream = new ofstream( outputFn );
if ( !outFStream->is_open() ) {
- error() << "error opening " << outputFileName << " for writing" << endl;
+ error() << "error opening " << outputFn << " for writing" << endl;
exit(1);
}
@@ -288,17 +318,17 @@ void openOutput( )
void openExports( )
{
/* Make sure we are not writing to the same file as the input file. */
- if ( inputFileName != 0 && gblExportTo != 0 && strcmp( inputFileName, gblExportTo ) == 0 ) {
- error() << "output file \"" << gblExportTo <<
+ if ( inputFn != 0 && exportHeaderFn != 0 && strcmp( inputFn, exportHeaderFn ) == 0 ) {
+ error() << "output file \"" << exportHeaderFn <<
"\" is the same as the input file" << endl;
}
- if ( gblExportTo != 0 ) {
+ if ( exportHeaderFn != 0 ) {
/* Open the output stream, attaching it to the filter. */
- ofstream *outFStream = new ofstream( gblExportTo );
+ ofstream *outFStream = new ofstream( exportHeaderFn );
if ( !outFStream->is_open() ) {
- error() << "error opening " << outputFileName << " for writing" << endl;
+ error() << "error opening " << exportHeaderFn << " for writing" << endl;
exit(1);
}
@@ -313,17 +343,17 @@ void openExports( )
void openExportsImpl( )
{
/* Make sure we are not writing to the same file as the input file. */
- if ( inputFileName != 0 && gblExpImplTo != 0 && strcmp( inputFileName, gblExpImplTo ) == 0 ) {
- error() << "output file \"" << gblExpImplTo <<
+ if ( inputFn != 0 && exportCodeFn != 0 && strcmp( inputFn, exportCodeFn ) == 0 ) {
+ error() << "output file \"" << exportCodeFn <<
"\" is the same as the input file" << endl;
}
- if ( gblExpImplTo != 0 ) {
+ if ( exportCodeFn != 0 ) {
/* Open the output stream, attaching it to the filter. */
- ofstream *outFStream = new ofstream( gblExpImplTo );
+ ofstream *outFStream = new ofstream( exportCodeFn );
if ( !outFStream->is_open() ) {
- error() << "error opening " << outputFileName << " for writing" << endl;
+ error() << "error opening " << exportCodeFn << " for writing" << endl;
exit(1);
}
@@ -361,9 +391,7 @@ void compileOutputInstalled( const char *argv0 )
last -= 1;
}
- char *exec = fileNameFromStem( outputFileName, ".bin" );
-
- int length = 1024 + 3*strlen(location) + strlen(outputFileName) + strlen(exec);
+ int length = 1024 + strlen(intermedFn) + strlen(binaryFn);
char command[length];
sprintf( command,
"gcc -Wall -Wwrite-strings"
@@ -373,7 +401,7 @@ void compileOutputInstalled( const char *argv0 )
" %s"
" -L" PREFIX "/lib"
" -lcolmd",
- exec, outputFileName );
+ binaryFn, intermedFn );
compileOutputCommand( command );
}
@@ -386,9 +414,7 @@ void compileOutputInSource( const char *argv0 )
assert( last != 0 );
last[1] = 0;
- char *exec = fileNameFromStem( outputFileName, ".bin" );
-
- int length = 1024 + 3*strlen(location) + strlen(outputFileName) + strlen(exec);
+ int length = 1024 + 3 * strlen(location) + strlen(intermedFn) + strlen(binaryFn);
char command[length];
sprintf( command,
"gcc -Wall -Wwrite-strings"
@@ -400,7 +426,7 @@ void compileOutputInSource( const char *argv0 )
" -L%s"
" -lcolmd",
location, location,
- exec, outputFileName, location );
+ binaryFn, intermedFn, location );
compileOutputCommand( command );
}
@@ -427,7 +453,7 @@ bool inSourceTree( const char *argv0 )
void processArgs( int argc, const char **argv )
{
- ParamCheck pc( "D:e:c:LI:vdlio:S:M:vHh?-:sV", argc, argv );
+ ParamCheck pc( "cD:e:E:I:vdlio:S:M:vHh?-:sV", argc, argv );
while ( pc.check() ) {
switch ( pc.state ) {
@@ -453,11 +479,11 @@ void processArgs( int argc, const char **argv )
case 'o':
if ( *pc.parameterArg == 0 )
error() << "a zero length output file name was given" << endl;
- else if ( outputFileName != 0 )
+ else if ( outputFn != 0 )
error() << "more than one output file name was given" << endl;
else {
/* Ok, remember the output file name. */
- outputFileName = pc.parameterArg;
+ outputFn = pc.parameterArg;
}
break;
@@ -484,14 +510,14 @@ void processArgs( int argc, const char **argv )
" is an invalid argument" << endl;
}
break;
- case 'L':
+ case 'c':
gblLibrary = true;
break;
case 'e':
- gblExportTo = pc.parameterArg;
+ exportHeaderFn = pc.parameterArg;
break;
- case 'c':
- gblExpImplTo = pc.parameterArg;
+ case 'x':
+ exportCodeFn = pc.parameterArg;
break;
case 'D':
#if DEBUG
@@ -528,11 +554,11 @@ void processArgs( int argc, const char **argv )
/* It is interpreted as an input file. */
if ( *pc.curArg == 0 )
error() << "a zero length input file name was given" << endl;
- else if ( inputFileName != 0 )
+ else if ( inputFn != 0 )
error() << "more than one input file name was given" << endl;
else {
/* OK, Remember the filename. */
- inputFileName = pc.curArg;
+ inputFn = pc.curArg;
}
break;
}
@@ -552,24 +578,24 @@ int main(int argc, const char **argv)
exit(1);
/* Make sure we are not writing to the same file as the input file. */
- if ( inputFileName != 0 && outputFileName != 0 &&
- strcmp( inputFileName, outputFileName ) == 0 )
+ if ( inputFn != 0 && outputFn != 0 &&
+ strcmp( inputFn, outputFn ) == 0 )
{
- error() << "output file \"" << outputFileName <<
+ error() << "output file \"" << outputFn <<
"\" is the same as the input file" << endl;
}
#if defined(CONS_COLM) || defined(LOAD_SRC)
/* Open the input file for reading. */
- if ( inputFileName == 0 ) {
+ if ( inputFn == 0 ) {
error() << "colm: no input file given" << endl;
}
else {
/* Open the input file for reading. */
- ifstream *inFile = new ifstream( inputFileName );
+ ifstream *inFile = new ifstream( inputFn );
if ( ! inFile->is_open() )
- error() << "could not open " << inputFileName << " for reading" << endl;
+ error() << "could not open " << inputFn << " for reading" << endl;
delete inFile;
}
#endif
@@ -583,9 +609,9 @@ int main(int argc, const char **argv)
#if defined(CONS_INIT)
BaseParser *parser = new ConsInit( pd );
#elif defined(LOAD_INIT)
- BaseParser *parser = new LoadInit( pd, inputFileName );
+ BaseParser *parser = new LoadInit( pd, inputFn );
#else
- BaseParser *parser = consLoadColm( pd, inputFileName );
+ BaseParser *parser = consLoadColm( pd, inputFn );
#endif
parser->go( gblActiveRealm );
@@ -605,7 +631,11 @@ int main(int argc, const char **argv)
pd->writeDotFile();
}
else {
- openOutput();
+ if ( gblLibrary )
+ openOutputLibrary();
+ else
+ openOutputCompiled();
+
pd->generateOutput( gblActiveRealm );
if ( outStream != 0 )
delete outStream;
@@ -617,12 +647,12 @@ int main(int argc, const char **argv)
compileOutputInstalled( argv[0] );
}
- if ( gblExportTo != 0 ) {
+ if ( exportHeaderFn != 0 ) {
openExports();
pd->generateExports();
delete outStream;
}
- if ( gblExpImplTo != 0 ) {
+ if ( exportCodeFn != 0 ) {
openExportsImpl();
pd->generateExportsImpl();
delete outStream;
diff --git a/colm/pdabuild.cc b/colm/pdabuild.cc
index c64f460f..8c8541e7 100644
--- a/colm/pdabuild.cc
+++ b/colm/pdabuild.cc
@@ -1699,7 +1699,7 @@ void fillNodes( Program *prg, int &nextAvail, Bindings *bindings, long &bindId,
// CaptureAttr *cap = prg->rtd->captureAttr +
// prg->rtd->lelInfo[kid->tree->id].captureAttr + i;
//
- // Tree *attr = getAttr( kid->tree, cap->offset );
+ // Tree *attr = colm_get_attr( kid->tree, cap->offset );
//
// PatConsNode &node = nodes[nextAvail++];
// memset( &node, 0, sizeof(PatConsNode) );
diff --git a/colm/pdacodegen.cc b/colm/pdacodegen.cc
index 29614388..469f95c0 100644
--- a/colm/pdacodegen.cc
+++ b/colm/pdacodegen.cc
@@ -66,7 +66,7 @@ void escapeLiteralString( std::ostream &out, const char *path )
void PdaCodeGen::defineRuntime()
{
out <<
- "extern RuntimeData main_runtimeData;\n"
+ "extern RuntimeData colm_program_text;\n"
"\n";
}
@@ -414,7 +414,7 @@ void PdaCodeGen::writeRuntimeData( RuntimeData *runtimeData, PdaTables *pdaTable
out << "};\n\n";
out <<
- "RuntimeData main_runtimeData = \n"
+ "RuntimeData colm_object = \n"
"{\n"
" " << lelInfo() << ",\n"
" " << runtimeData->numLangEls << ",\n"
diff --git a/colm/pdarun.h b/colm/pdarun.h
index afc687f0..6b5cafd4 100644
--- a/colm/pdarun.h
+++ b/colm/pdarun.h
@@ -30,7 +30,7 @@
extern "C" {
#endif
-struct ColmProgram;
+struct colm_program;
#define MARK_SLOTS 32
@@ -344,9 +344,9 @@ typedef struct _PdaRun
FsmRun _fsmRun;
} PdaRun;
-void initPdaRun( struct ColmProgram *prg, PdaRun *pdaRun, PdaTables *tables,
+void initPdaRun( struct colm_program *prg, PdaRun *pdaRun, PdaTables *tables,
int parserId, long stopTarget, int revertOn, Tree *context );
-void clearPdaRun( struct ColmProgram *prg, struct ColmTree **sp, PdaRun *pdaRun );
+void clearPdaRun( struct colm_program *prg, struct colm_tree **sp, PdaRun *pdaRun );
void rtCodeVectReplace( RtCodeVect *vect, long pos, const Code *val, long len );
void rtCodeVectEmpty( RtCodeVect *vect );
void rtCodeVectRemove( RtCodeVect *vect, long pos, long len );
@@ -397,14 +397,14 @@ void decrementSteps( PdaRun *pdaRun );
int makeReverseCode( PdaRun *pdaRun );
void transferReverseCode( PdaRun *pdaRun, ParseTree *tree );
-void clearStreamImpl( struct ColmProgram *prg, Tree **sp, StreamImpl *inputStream );
+void clearStreamImpl( struct colm_program *prg, Tree **sp, StreamImpl *inputStream );
void initSourceStream( StreamImpl *in );
-void clearSourceStream( struct ColmProgram *prg, Tree **sp, StreamImpl *sourceStream );
+void clearSourceStream( struct colm_program *prg, Tree **sp, StreamImpl *sourceStream );
void clearContext( PdaRun *pdaRun, Tree **sp );
Kid *extractIgnore( PdaRun *pdaRun );
-long stackTopTarget( struct ColmProgram *prg, PdaRun *pdaRun );
+long stackTopTarget( struct colm_program *prg, PdaRun *pdaRun );
void runCommit( PdaRun *pdaRun );
int isParserStopFinished( PdaRun *pdaRun );
void pdaRunMatch( PdaRun *pdaRun, Kid *tree, Kid *pattern );
@@ -420,32 +420,32 @@ int pdaRunGetNextPreRegion( PdaRun *pdaRun );
#define PcrPreEof 5
#define PcrReverse 6
-long parseToken( struct ColmProgram *prg, Tree **sp, PdaRun *pdaRun,
+long parseToken( struct colm_program *prg, Tree **sp, PdaRun *pdaRun,
FsmRun *fsmRun, StreamImpl *inputStream, long entry );
long undoParse( Tree **sp, PdaRun *pdaRun, FsmRun *fsmRun, StreamImpl *inputStream, Tree *tree );
-Head *streamPull( struct ColmProgram *prg, PdaRun *pdaRun, StreamImpl *is, long length );
-Head *stringAllocPointer( struct ColmProgram *prg, const char *data, long length );
+Head *streamPull( struct colm_program *prg, PdaRun *pdaRun, StreamImpl *is, long length );
+Head *stringAllocPointer( struct colm_program *prg, const char *data, long length );
void streamPushText( StreamImpl *inputStream, const char *data, long length );
void streamPushTree( StreamImpl *inputStream, Tree *tree, int ignore );
void streamPushStream( StreamImpl *inputStream, Tree *tree );
-void undoStreamPush( struct ColmProgram *prg, Tree **sp, StreamImpl *inputStream, long length );
-void undoStreamAppend( struct ColmProgram *prg, Tree **sp, StreamImpl *inputStream, struct ColmTree *tree, long length );
-Kid *makeTokenWithData( struct ColmProgram *prg, PdaRun *pdaRun, FsmRun *fsmRun,
+void undoStreamPush( struct colm_program *prg, Tree **sp, StreamImpl *inputStream, long length );
+void undoStreamAppend( struct colm_program *prg, Tree **sp, StreamImpl *inputStream, struct colm_tree *tree, long length );
+Kid *makeTokenWithData( struct colm_program *prg, PdaRun *pdaRun, FsmRun *fsmRun,
StreamImpl *inputStream, int id, Head *tokdata );
void pushBinding( PdaRun *pdaRun, ParseTree *parseTree );
-void executeGenerationAction( struct ColmProgram *prg, Tree **sp, FsmRun *fsmRun, PdaRun *pdaRun,
+void executeGenerationAction( struct colm_program *prg, Tree **sp, FsmRun *fsmRun, PdaRun *pdaRun,
StreamImpl *inputStream, int frameId, Code *code, long id, Head *tokdata );
Kid *extractIgnore( PdaRun *pdaRun );
-void clearIgnoreList( struct ColmProgram *prg, Tree **sp, Kid *kid );
-long parseLoop( struct ColmProgram *prg, Tree **sp, PdaRun *pdaRun,
+void clearIgnoreList( struct colm_program *prg, Tree **sp, Kid *kid );
+long parseLoop( struct colm_program *prg, Tree **sp, PdaRun *pdaRun,
StreamImpl *inputStream, long entry );
Tree *getParsedRoot( PdaRun *pdaRun, int stop );
-void undoParseStream( struct ColmProgram *prg, Tree **sp, StreamImpl *inputStream, FsmRun *fsmRun,
+void undoParseStream( struct colm_program *prg, Tree **sp, StreamImpl *inputStream, FsmRun *fsmRun,
PdaRun *pdaRun, long steps );
void clearBuffered( FsmRun *fsmRun );
diff --git a/colm/program.c b/colm/program.c
index 6548cba4..fc728344 100644
--- a/colm/program.c
+++ b/colm/program.c
@@ -39,8 +39,8 @@ void clearGlobal( Program *prg, Tree **sp )
/* Downref all the fields in the global object. */
int g;
for ( g = 0; g < prg->rtd->globalSize; g++ ) {
- //assert( getAttr( global, g )->refs == 1 );
- treeDownref( prg, sp, getAttr( prg->global, g ) );
+ //assert( colm_get_attr( global, g )->refs == 1 );
+ treeDownref( prg, sp, colm_get_attr( prg->global, g ) );
}
/* Free the global object. */
@@ -74,7 +74,7 @@ void vm_init( Program *prg )
prg->stackRoot = prg->sb_end;
}
-struct ColmTree **vm_root( struct ColmProgram *prg )
+Tree **colm_vm_root( Program *prg )
{
return prg->stackRoot;
}
@@ -174,18 +174,21 @@ void vm_clear( Program *prg )
}
}
-Tree *returnVal( struct ColmProgram *prg )
+Tree *colm_return_val( struct colm_program *prg )
{
return prg->returnVal;
}
-Program *colmNewProgram( RuntimeData *rtd, long activeRealm )
+void colm_set_debug( Program *prg, long activeRealm )
+{
+ prg->activeRealm = activeRealm;
+}
+
+Program *colm_new_program( RuntimeData *rtd )
{
Program *prg = malloc(sizeof(Program));
memset( prg, 0, sizeof(Program) );
- prg->activeRealm = activeRealm;
-
assert( sizeof(Int) <= sizeof(Tree) );
assert( sizeof(Str) <= sizeof(Tree) );
assert( sizeof(Pointer) <= sizeof(Tree) );
@@ -226,7 +229,7 @@ Program *colmNewProgram( RuntimeData *rtd, long activeRealm )
return prg;
}
-void colmRunProgram( Program *prg, int argc, const char **argv )
+void colm_run_program( Program *prg, int argc, const char **argv )
{
if ( prg->rtd->rootCodeLen == 0 )
return;
@@ -246,7 +249,7 @@ void colmRunProgram( Program *prg, int argc, const char **argv )
prg->argv = 0;
}
-Tree *colmRunFunc( struct ColmProgram *prg, int frameId, const char **params, int paramCount )
+Tree *colm_run_func( struct colm_program *prg, int frameId, const char **params, int paramCount )
{
/* Make the arguments available to the program. */
prg->argc = 0;
@@ -295,7 +298,7 @@ Tree *colmRunFunc( struct ColmProgram *prg, int frameId, const char **params, in
return prg->returnVal;
};
-int colmDeleteProgram( Program *prg )
+int colm_delete_program( Program *prg )
{
Tree **sp = prg->stackRoot;
int exitStatus = prg->exitStatus;
diff --git a/colm/program.h b/colm/program.h
index 60cede1e..225dc140 100644
--- a/colm/program.h
+++ b/colm/program.h
@@ -32,7 +32,7 @@ typedef struct ColmStackBlock
struct ColmStackBlock *next;
} StackBlock;
-typedef struct ColmRuntimeData
+typedef struct colm_sections
{
LangElInfo *lelInfo;
long numLangEls;
@@ -90,7 +90,7 @@ typedef struct ColmRuntimeData
long noTokenId;
void (*fsmExecute)( struct _FsmRun *fsmRun, struct _StreamImpl *inputStream );
- void (*sendNamedLangEl)( struct ColmProgram *prg, Tree **tree, struct _PdaRun *pdaRun,
+ void (*sendNamedLangEl)( struct colm_program *prg, Tree **tree, struct _PdaRun *pdaRun,
struct _FsmRun *fsmRun, struct _StreamImpl *inputStream );
void (*initBindings)( struct _PdaRun *pdaRun );
void (*popBinding)( struct _PdaRun *pdaRun, ParseTree *tree );
@@ -98,7 +98,7 @@ typedef struct ColmRuntimeData
} RuntimeData;
-typedef struct ColmProgram
+typedef struct colm_program
{
long activeRealm;
diff --git a/colm/tree.c b/colm/tree.c
index fe103a7b..3ffd8194 100644
--- a/colm/tree.c
+++ b/colm/tree.c
@@ -133,10 +133,10 @@ void setAttr( Tree *tree, long pos, Tree *val )
kid->tree = val;
}
-Tree *getGlobal( Program *prg, long pos )
- { return getAttr( prg->global, pos ); }
+Tree *colm_get_global( Program *prg, long pos )
+ { return colm_get_attr( prg->global, pos ); }
-Tree *getAttr( Tree *tree, long pos )
+Tree *colm_get_attr( Tree *tree, long pos )
{
long i;
Kid *kid = tree->child;
@@ -152,7 +152,7 @@ Tree *getAttr( Tree *tree, long pos )
}
-Tree *getRepeatNext( Tree *tree )
+Tree *colm_get_repeat_next( Tree *tree )
{
Kid *kid = tree->child;
@@ -164,7 +164,7 @@ Tree *getRepeatNext( Tree *tree )
return kid->next->tree;
}
-Tree *getRepeatVal( Tree *tree )
+Tree *colm_get_repeat_val( Tree *tree )
{
Kid *kid = tree->child;
@@ -176,7 +176,7 @@ Tree *getRepeatVal( Tree *tree )
return kid->tree;
}
-int repeatEnd( Tree *tree )
+int colm_repeat_end( Tree *tree )
{
Kid *kid = tree->child;
@@ -188,7 +188,7 @@ int repeatEnd( Tree *tree )
return kid == 0;
}
-int listLast( Tree *tree )
+int colm_list_last( Tree *tree )
{
Kid *kid = tree->child;
@@ -697,7 +697,7 @@ Tree *constructToken( Program *prg, Tree **root, long nargs )
long id;
for ( id = 0; id < nargs-2; id++ ) {
setAttr( tree, id, base[-3-id] );
- treeUpref( getAttr( tree, id) );
+ treeUpref( colm_get_attr( tree, id) );
}
}
return tree;
@@ -1233,7 +1233,7 @@ Tree *getRhsEl( Program *prg, Tree *lhs, long position )
return pos->tree;
}
-Tree *getRhsVal( Program *prg, Tree *tree, int *a )
+Tree *colm_get_rhs_val( Program *prg, Tree *tree, int *a )
{
int i, len = a[0];
for ( i = 0; i < len; i++ ) {
@@ -1255,7 +1255,7 @@ void setField( Program *prg, Tree *tree, long field, Tree *value )
Tree *getField( Tree *tree, Word field )
{
- return getAttr( tree, field );
+ return colm_get_attr( tree, field );
}
Kid *getFieldKid( Tree *tree, Word field )
@@ -1265,7 +1265,7 @@ Kid *getFieldKid( Tree *tree, Word field )
Tree *getFieldSplit( Program *prg, Tree *tree, Word field )
{
- Tree *val = getAttr( tree, field );
+ Tree *val = colm_get_attr( tree, field );
Tree *split = splitTree( prg, val );
setAttr( tree, field, split );
return split;
@@ -2012,12 +2012,12 @@ Location *locSearch( Program *prg, Tree *tree )
return res;
}
-struct ColmLocation *findLocation( Program *prg, Tree *tree )
+struct colm_location *colm_find_location( Program *prg, Tree *tree )
{
return locSearch( prg, tree );
}
-void xmlEscapeData( struct ColmPrintArgs *printArgs, const char *data, long len )
+void xmlEscapeData( struct colm_print_args *printArgs, const char *data, long len )
{
int i;
for ( i = 0; i < len; i++ ) {
@@ -2070,22 +2070,22 @@ void strCollectClear( StrCollect *collect )
#define INT_SZ 32
-void printStr( struct ColmPrintArgs *printArgs, Head *str )
+void printStr( struct colm_print_args *printArgs, Head *str )
{
printArgs->out( printArgs, (char*)(str->data), str->length );
}
-void appendCollect( struct ColmPrintArgs *args, const char *data, int length )
+void appendCollect( struct colm_print_args *args, const char *data, int length )
{
strCollectAppend( (StrCollect*) args->arg, data, length );
}
-void appendFile( struct ColmPrintArgs *args, const char *data, int length )
+void appendFile( struct colm_print_args *args, const char *data, int length )
{
fwrite( data, 1, length, (FILE*)args->arg );
}
-void appendFd( struct ColmPrintArgs *args, const char *data, int length )
+void appendFd( struct colm_print_args *args, const char *data, int length )
{
int res = write( (long)args->arg, data, length );
if ( res != 0 ) {
@@ -2093,7 +2093,7 @@ void appendFd( struct ColmPrintArgs *args, const char *data, int length )
}
}
-Tree *treeTrim( struct ColmProgram *prg, Tree **sp, Tree *tree )
+Tree *treeTrim( struct colm_program *prg, Tree **sp, Tree *tree )
{
debug( prg, REALM_PARSE, "attaching left ignore\n" );
@@ -2137,7 +2137,7 @@ enum VisitType
#define TF_TERM_SEEN 0x1
-void printKid( Program *prg, Tree **sp, struct ColmPrintArgs *printArgs, Kid *kid )
+void printKid( Program *prg, Tree **sp, struct colm_print_args *printArgs, Kid *kid )
{
enum ReturnType rt;
Kid *parent = 0;
@@ -2271,7 +2271,7 @@ rec_call:
if ( visitType == Term || visitType == NonTerm ) {
/* Open the tree. */
- printArgs->openTree( prg, sp, printArgs, parent, kid );
+ printArgs->open_tree( prg, sp, printArgs, parent, kid );
}
if ( visitType == Term )
@@ -2282,7 +2282,7 @@ rec_call:
if ( kid->tree->id < prg->rtd->firstNonTermId ) {
debug( prg, REALM_PRINT, "printing terminal %p\n", kid->tree );
if ( kid->tree->id != 0 )
- printArgs->printTerm( prg, sp, printArgs, kid );
+ printArgs->print_term( prg, sp, printArgs, kid );
}
}
@@ -2310,7 +2310,7 @@ rec_call:
if ( visitType == Term || visitType == NonTerm ) {
/* close the tree. */
- printArgs->closeTree( prg, sp, printArgs, parent, kid );
+ printArgs->close_tree( prg, sp, printArgs, parent, kid );
}
skip_node:
@@ -2354,7 +2354,7 @@ skip_null:
}
}
-void printTreeArgs( Program *prg, Tree **sp, struct ColmPrintArgs *printArgs, Tree *tree )
+void colm_print_tree_args( Program *prg, Tree **sp, struct colm_print_args *printArgs, Tree *tree )
{
if ( tree == 0 )
printArgs->out( printArgs, "NIL", 3 );
@@ -2376,7 +2376,7 @@ void printTreeArgs( Program *prg, Tree **sp, struct ColmPrintArgs *printArgs, Tr
}
}
-void printTermTree( Program *prg, Tree **sp, struct ColmPrintArgs *printArgs, Kid *kid )
+void colm_print_term_tree( Program *prg, Tree **sp, struct colm_print_args *printArgs, Kid *kid )
{
debug( prg, REALM_PRINT, "printing term %p\n", kid->tree );
@@ -2415,11 +2415,11 @@ void printTermTree( Program *prg, Tree **sp, struct ColmPrintArgs *printArgs, Ki
}
-void printNull( Program *prg, Tree **sp, struct ColmPrintArgs *args, Kid *parent, Kid *kid )
+void colm_print_null( Program *prg, Tree **sp, struct colm_print_args *args, Kid *parent, Kid *kid )
{
}
-void openTreeXml( Program *prg, Tree **sp, struct ColmPrintArgs *args, Kid *parent, Kid *kid )
+void openTreeXml( Program *prg, Tree **sp, struct colm_print_args *args, Kid *parent, Kid *kid )
{
/* Skip the terminal that is for forcing trailing ignores out. */
if ( kid->tree->id == 0 )
@@ -2441,7 +2441,7 @@ void openTreeXml( Program *prg, Tree **sp, struct ColmPrintArgs *args, Kid *pare
args->out( args, ">", 1 );
}
-void printTermXml( Program *prg, Tree **sp, struct ColmPrintArgs *printArgs, Kid *kid )
+void printTermXml( Program *prg, Tree **sp, struct colm_print_args *printArgs, Kid *kid )
{
//Kid *child;
@@ -2478,7 +2478,7 @@ void printTermXml( Program *prg, Tree **sp, struct ColmPrintArgs *printArgs, Kid
}
-void closeTreeXml( Program *prg, Tree **sp, struct ColmPrintArgs *args, Kid *parent, Kid *kid )
+void closeTreeXml( Program *prg, Tree **sp, struct colm_print_args *args, Kid *parent, Kid *kid )
{
/* Skip the terminal that is for forcing trailing ignores out. */
if ( kid->tree->id == 0 )
@@ -2502,29 +2502,29 @@ void closeTreeXml( Program *prg, Tree **sp, struct ColmPrintArgs *args, Kid *par
void printTreeCollect( Program *prg, Tree **sp, StrCollect *collect, Tree *tree, int trim )
{
- struct ColmPrintArgs printArgs = { collect, true, false, trim, &appendCollect,
- &printNull, &printTermTree, &printNull };
- printTreeArgs( prg, sp, &printArgs, tree );
+ struct colm_print_args printArgs = { collect, true, false, trim, &appendCollect,
+ &colm_print_null, &colm_print_term_tree, &colm_print_null };
+ colm_print_tree_args( prg, sp, &printArgs, tree );
}
void printTreeFile( Program *prg, Tree **sp, FILE *out, Tree *tree, int trim )
{
- struct ColmPrintArgs printArgs = { out, true, false, trim, &appendFile,
- &printNull, &printTermTree, &printNull };
- printTreeArgs( prg, sp, &printArgs, tree );
+ struct colm_print_args printArgs = { out, true, false, trim, &appendFile,
+ &colm_print_null, &colm_print_term_tree, &colm_print_null };
+ colm_print_tree_args( prg, sp, &printArgs, tree );
}
void printTreeFd( Program *prg, Tree **sp, int fd, Tree *tree, int trim )
{
- struct ColmPrintArgs printArgs = { (void*)((long)fd), true, false, trim, &appendFd,
- &printNull, &printTermTree, &printNull };
- printTreeArgs( prg, sp, &printArgs, tree );
+ struct colm_print_args printArgs = { (void*)((long)fd), true, false, trim, &appendFd,
+ &colm_print_null, &colm_print_term_tree, &colm_print_null };
+ colm_print_tree_args( prg, sp, &printArgs, tree );
}
void printXmlStdout( Program *prg, Tree **sp, Tree *tree, int commAttr, int trim )
{
- struct ColmPrintArgs printArgs = { stdout, commAttr, commAttr, trim, &appendFile,
+ struct colm_print_args printArgs = { stdout, commAttr, commAttr, trim, &appendFile,
&openTreeXml, &printTermXml, &closeTreeXml };
- printTreeArgs( prg, sp, &printArgs, tree );
+ colm_print_tree_args( prg, sp, &printArgs, tree );
}
diff --git a/colm/tree.h b/colm/tree.h
index 8496918c..d1f26d5c 100644
--- a/colm/tree.h
+++ b/colm/tree.h
@@ -33,7 +33,7 @@ typedef unsigned long Word;
typedef unsigned long Half;
struct Bindings;
-typedef struct ColmLocation
+typedef struct colm_location
{
const char *name;
long line;
@@ -49,23 +49,23 @@ typedef struct _Head
Location *location;
} Head;
-typedef struct ColmKid
+typedef struct colm_kid
{
/* 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 ColmTree *tree;
- struct ColmKid *next;
+ struct colm_tree *tree;
+ struct colm_kid *next;
unsigned char flags;
} Kid;
typedef struct _Ref
{
- struct ColmKid *kid;
+ Kid *kid;
struct _Ref *next;
} Ref;
-typedef struct ColmTree
+typedef struct colm_tree
{
/* First four will be overlaid in other structures. */
short id;
@@ -242,75 +242,75 @@ typedef struct _UserIter
void treeUpref( Tree *tree );
-void treeDownref( struct ColmProgram *prg, Tree **sp, Tree *tree );
-long cmpTree( struct ColmProgram *prg, const Tree *tree1, const Tree *tree2 );
-
-Tree *pushRightIgnore( struct ColmProgram *prg, Tree *pushTo, Tree *rightIgnore );
-Tree *pushLeftIgnore( struct ColmProgram *prg, Tree *pushTo, Tree *leftIgnore );
-Tree *popRightIgnore( struct ColmProgram *prg, Tree **sp, Tree *popFrom, Tree **rightIgnore );
-Tree *popLeftIgnore( struct ColmProgram *prg, Tree **sp, Tree *popFrom, Tree **leftIgnore );
-Tree *treeLeftIgnore( struct ColmProgram *prg, Tree *tree );
-Tree *treeRightIgnore( struct ColmProgram *prg, Tree *tree );
-Kid *treeLeftIgnoreKid( struct ColmProgram *prg, Tree *tree );
-Kid *treeRightIgnoreKid( struct ColmProgram *prg, Tree *tree );
-Kid *treeChild( struct ColmProgram *prg, const Tree *tree );
-Kid *treeAttr( struct ColmProgram *prg, const Tree *tree );
+void treeDownref( struct colm_program *prg, Tree **sp, Tree *tree );
+long cmpTree( struct colm_program *prg, const Tree *tree1, const Tree *tree2 );
+
+Tree *pushRightIgnore( struct colm_program *prg, Tree *pushTo, Tree *rightIgnore );
+Tree *pushLeftIgnore( struct colm_program *prg, Tree *pushTo, Tree *leftIgnore );
+Tree *popRightIgnore( struct colm_program *prg, Tree **sp, Tree *popFrom, Tree **rightIgnore );
+Tree *popLeftIgnore( struct colm_program *prg, Tree **sp, Tree *popFrom, Tree **leftIgnore );
+Tree *treeLeftIgnore( struct colm_program *prg, Tree *tree );
+Tree *treeRightIgnore( struct colm_program *prg, Tree *tree );
+Kid *treeLeftIgnoreKid( struct colm_program *prg, Tree *tree );
+Kid *treeRightIgnoreKid( struct colm_program *prg, Tree *tree );
+Kid *treeChild( struct colm_program *prg, const Tree *tree );
+Kid *treeAttr( struct colm_program *prg, const Tree *tree );
Kid *kidListConcat( Kid *list1, Kid *list2 );
-Kid *treeExtractChild( struct ColmProgram *prg, Tree *tree );
+Kid *treeExtractChild( struct colm_program *prg, Tree *tree );
Kid *reverseKidList( Kid *kid );
-Tree *constructInteger( struct ColmProgram *prg, long i );
-Tree *constructPointer( struct ColmProgram *prg, Tree *tree );
-Tree *constructTerm( struct ColmProgram *prg, Word id, Head *tokdata );
-Tree *constructReplacementTree( Kid *kid, Tree **bindings, struct ColmProgram *prg, long pat );
-Tree *createGeneric( struct ColmProgram *prg, long genericId );
-Tree *constructToken( struct ColmProgram *prg, Tree **root, long nargs );
-Tree *constructStream( struct ColmProgram *prg );
+Tree *constructInteger( struct colm_program *prg, long i );
+Tree *constructPointer( struct colm_program *prg, Tree *tree );
+Tree *constructTerm( struct colm_program *prg, Word id, Head *tokdata );
+Tree *constructReplacementTree( Kid *kid, Tree **bindings, struct colm_program *prg, long pat );
+Tree *createGeneric( struct colm_program *prg, long genericId );
+Tree *constructToken( struct colm_program *prg, Tree **root, long nargs );
+Tree *constructStream( struct colm_program *prg );
-int testFalse( struct ColmProgram *prg, Tree *tree );
-Tree *makeTree( struct ColmProgram *prg, Tree **root, long nargs );
-Stream *openFile( struct ColmProgram *prg, Tree *name, Tree *mode );
-Stream *openStreamFd( struct ColmProgram *prg, char *name, long fd );
-Kid *copyIgnoreList( struct ColmProgram *prg, Kid *ignoreHeader );
-Kid *copyKidList( struct ColmProgram *prg, Kid *kidList );
-void streamFree( struct ColmProgram *prg, Stream *s );
-Tree *copyTree( struct ColmProgram *prg, Tree *tree, Kid *oldNextDown, Kid **newNextDown );
+int testFalse( struct colm_program *prg, Tree *tree );
+Tree *makeTree( struct colm_program *prg, Tree **root, long nargs );
+Stream *openFile( struct colm_program *prg, Tree *name, Tree *mode );
+Stream *openStreamFd( struct colm_program *prg, char *name, long fd );
+Kid *copyIgnoreList( struct colm_program *prg, Kid *ignoreHeader );
+Kid *copyKidList( struct colm_program *prg, Kid *kidList );
+void streamFree( struct colm_program *prg, Stream *s );
+Tree *copyTree( struct colm_program *prg, Tree *tree, Kid *oldNextDown, Kid **newNextDown );
Tree *getPtrVal( Pointer *ptr );
-Tree *getPtrValSplit( struct ColmProgram *prg, Pointer *ptr );
+Tree *getPtrValSplit( struct colm_program *prg, Pointer *ptr );
Tree *getField( Tree *tree, Word field );
-Tree *getFieldSplit( struct ColmProgram *prg, Tree *tree, Word field );
-Tree *getRhsEl( struct ColmProgram *prg, Tree *lhs, long position );
-void setField( struct ColmProgram *prg, Tree *tree, long field, Tree *value );
+Tree *getFieldSplit( struct colm_program *prg, Tree *tree, Word field );
+Tree *getRhsEl( struct colm_program *prg, Tree *lhs, long position );
+void setField( struct colm_program *prg, Tree *tree, long field, Tree *value );
-void setTriterCur( struct ColmProgram *prg, TreeIter *iter, Tree *tree );
-void setUiterCur( struct ColmProgram *prg, UserIter *uiter, Tree *tree );
+void setTriterCur( struct colm_program *prg, TreeIter *iter, Tree *tree );
+void setUiterCur( struct colm_program *prg, UserIter *uiter, Tree *tree );
void refSetValue( Ref *ref, Tree *v );
-Tree *treeSearch( struct ColmProgram *prg, Tree *tree, long id );
-Location *locSearch( struct ColmProgram *prg, Tree *tree );
+Tree *treeSearch( struct colm_program *prg, Tree *tree, long id );
+Location *locSearch( struct colm_program *prg, Tree *tree );
-int matchPattern( Tree **bindings, struct ColmProgram *prg, long pat, Kid *kid, int checkNext );
+int matchPattern( Tree **bindings, struct colm_program *prg, long pat, Kid *kid, int checkNext );
Tree *treeIterDerefCur( TreeIter *iter );
/* For making references of attributes. */
Kid *getFieldKid( Tree *tree, Word field );
-Tree *copyRealTree( struct ColmProgram *prg, Tree *tree, Kid *oldNextDown, Kid **newNextDown );
-void splitIterCur( struct ColmProgram *prg, Tree ***psp, TreeIter *iter );
+Tree *copyRealTree( struct colm_program *prg, Tree *tree, Kid *oldNextDown, Kid **newNextDown );
+void splitIterCur( struct colm_program *prg, Tree ***psp, TreeIter *iter );
Tree *setListMem( List *list, Half field, Tree *value );
-void listAppend2( struct ColmProgram *prg, List *list, Tree *val );
-Tree *listRemoveEnd( struct ColmProgram *prg, List *list );
+void listAppend2( struct colm_program *prg, List *list, Tree *val );
+Tree *listRemoveEnd( struct colm_program *prg, List *list );
Tree *getListMem( List *list, Word field );
-Tree *getListMemSplit( struct ColmProgram *prg, List *list, Word field );
+Tree *getListMemSplit( struct colm_program *prg, List *list, Word field );
Tree *getParserMem( Parser *parser, Word field );
-Tree *treeIterAdvance( struct ColmProgram *prg, Tree ***psp, TreeIter *iter );
-Tree *treeIterNextChild( struct ColmProgram *prg, Tree ***psp, TreeIter *iter );
-Tree *treeRevIterPrevChild( struct ColmProgram *prg, Tree ***psp, RevTreeIter *iter );
-Tree *treeIterNextRepeat( struct ColmProgram *prg, Tree ***psp, TreeIter *iter );
-Tree *treeIterPrevRepeat( struct ColmProgram *prg, Tree ***psp, TreeIter *iter );
+Tree *treeIterAdvance( struct colm_program *prg, Tree ***psp, TreeIter *iter );
+Tree *treeIterNextChild( struct colm_program *prg, Tree ***psp, TreeIter *iter );
+Tree *treeRevIterPrevChild( struct colm_program *prg, Tree ***psp, RevTreeIter *iter );
+Tree *treeIterNextRepeat( struct colm_program *prg, Tree ***psp, TreeIter *iter );
+Tree *treeIterPrevRepeat( struct colm_program *prg, Tree ***psp, TreeIter *iter );
/* An automatically grown buffer for collecting tokens. Always reuses space;
* never down resizes. */
@@ -325,12 +325,12 @@ void initStrCollect( StrCollect *collect );
void strCollectDestroy( StrCollect *collect );
void strCollectAppend( StrCollect *collect, const char *data, long len );
void strCollectClear( StrCollect *collect );
-Tree *treeTrim( struct ColmProgram *prg, Tree **sp, Tree *tree );
+Tree *treeTrim( struct colm_program *prg, Tree **sp, Tree *tree );
-void printTreeCollect( struct ColmProgram *prg, Tree **sp, StrCollect *collect, Tree *tree, int trim );
-void printTreeFile( struct ColmProgram *prg, Tree **sp, FILE *out, Tree *tree, int trim );
-void printTreeFd( struct ColmProgram *prg, Tree **sp, int fd, Tree *tree, int trim );
-void printXmlStdout( struct ColmProgram *prg, Tree **sp, Tree *tree, int commAttr, int trim );
+void printTreeCollect( struct colm_program *prg, Tree **sp, StrCollect *collect, Tree *tree, int trim );
+void printTreeFile( struct colm_program *prg, Tree **sp, FILE *out, Tree *tree, int trim );
+void printTreeFd( struct colm_program *prg, Tree **sp, int fd, Tree *tree, int trim );
+void printXmlStdout( struct colm_program *prg, Tree **sp, Tree *tree, int commAttr, int trim );
/*
* Iterators.
diff --git a/test/accum3.lm b/test/accum3.lm
index b86f5635..3c2c83c9 100644
--- a/test/accum3.lm
+++ b/test/accum3.lm
@@ -33,4 +33,4 @@ print( '\n' )
##### ARGS #####
-qv -h -o output sdf -i eth0 file
##### EXP #####
-<args><word>./working/accum3.bin</word><zero>&#0;</zero><_repeat_item><item><_literal_0001>-</_literal_0001><_repeat_single><single>q</single><single>v</single></_repeat_single><zero>&#0;</zero></item><item><_literal_0001>-</_literal_0001><_repeat_single><single>h</single></_repeat_single><zero>&#0;</zero></item><item><_literal_0001>-</_literal_0001><with_opt>o</with_opt><_opt_zero><zero>&#0;</zero></_opt_zero><word>output</word><zero>&#0;</zero></item><item><file>sdf</file><zero>&#0;</zero></item><item><_literal_0001>-</_literal_0001><with_opt>i</with_opt><_opt_zero><zero>&#0;</zero></_opt_zero><word>eth0</word><zero>&#0;</zero></item><item><file>file</file><zero>&#0;</zero></item></_repeat_item></args>
+<args><word>./working/accum3</word><zero>&#0;</zero><_repeat_item><item><_literal_0001>-</_literal_0001><_repeat_single><single>q</single><single>v</single></_repeat_single><zero>&#0;</zero></item><item><_literal_0001>-</_literal_0001><_repeat_single><single>h</single></_repeat_single><zero>&#0;</zero></item><item><_literal_0001>-</_literal_0001><with_opt>o</with_opt><_opt_zero><zero>&#0;</zero></_opt_zero><word>output</word><zero>&#0;</zero></item><item><file>sdf</file><zero>&#0;</zero></item><item><_literal_0001>-</_literal_0001><with_opt>i</with_opt><_opt_zero><zero>&#0;</zero></_opt_zero><word>eth0</word><zero>&#0;</zero></item><item><file>file</file><zero>&#0;</zero></item></_repeat_item></args>
diff --git a/test/argv1.lm b/test/argv1.lm
index 9ffd4467..74086e71 100644
--- a/test/argv1.lm
+++ b/test/argv1.lm
@@ -5,4 +5,4 @@ print( '\n' )
##### ARGS #####
a b c 1 2 3
##### EXP #####
-<__list0><str>./working/argv1.bin</str><str>a</str><str>b</str><str>c</str><str>1</str><str>2</str><str>3</str></__list0>
+<__list0><str>./working/argv1</str><str>a</str><str>b</str><str>c</str><str>1</str><str>2</str><str>3</str></__list0>
diff --git a/test/context1.lm b/test/context1.lm
index e0caf7ef..cf696963 100644
--- a/test/context1.lm
+++ b/test/context1.lm
@@ -27,10 +27,7 @@ context ctx
[item*]
end # ctx
-CTX: ctx = cons CTX: ctx[]
-
-send
-
+cons CTX: ctx[]
parse Input: ctx::start( CTX ) [ stdin ]
print( Input '\n' )
diff --git a/test/runtests.sh b/test/runtests.sh
index 93474404..a0e54eb3 100755
--- a/test/runtests.sh
+++ b/test/runtests.sh
@@ -104,7 +104,7 @@ function runtests()
section LM 0 $TST $LM
- BIN=$WORKING/$ROOT.bin
+ BIN=$WORKING/$ROOT
OUT=$WORKING/$ROOT.out
DIFF=$WORKING/$ROOT.diff
LOG=$WORKING/$ROOT.log