summaryrefslogtreecommitdiff
path: root/colm
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2009-02-07 19:12:35 +0000
committerAdrian Thurston <thurston@complang.org>2009-02-07 19:12:35 +0000
commitbf06f1c0f5b3d0fd0e039d36b610272965dc4c60 (patch)
treeec5b097db2fd0e759242a7fd2cb0cdc05a194c7c /colm
parentfa95840873220d4d1b5f80bb6cb8d06e8e3cea59 (diff)
downloadcolm-bf06f1c0f5b3d0fd0e039d36b610272965dc4c60.tar.gz
Colm logging and target logging are now turned on with -v and -l. No need to
reconfigure and recompile colm.
Diffstat (limited to 'colm')
-rw-r--r--colm/Makefile.in43
-rw-r--r--colm/bytecode.cpp10
-rw-r--r--colm/bytecode.h3
-rw-r--r--colm/colm.h1
-rw-r--r--colm/fsmcodegen.cpp7
-rw-r--r--colm/main.cpp30
6 files changed, 67 insertions, 27 deletions
diff --git a/colm/Makefile.in b/colm/Makefile.in
index 435dd3eb..131bd771 100644
--- a/colm/Makefile.in
+++ b/colm/Makefile.in
@@ -26,7 +26,10 @@
# rt_clm: rt on/off
INCS += -I../aapl
-DEFS +=
+
+DEFS_COLM += -DCOLM_LOG
+DEFS_RT_P +=
+DEFS_RT_D += -DCOLM_LOG
CFLAGS += -g -Wall -Wwrite-strings
LDFLAGS +=
@@ -64,7 +67,8 @@ ALL_SRC = $(COLM_SRC) $(RUNTIME_SRC)
# Files in ALL_SRC that are generated.
GEN_SRC = version.h lmscan.cpp lmparse.h lmparse.cpp
-RUNTIME = runtime.a
+RUNTIME_P = runtime_p.a
+RUNTIME_D = runtime_d.a
LIBS =
@@ -82,18 +86,22 @@ CXX = @CXX@
# Get objects and dependencies from sources.
COLM_OBJ = $(COLM_SRC:%.cpp=%.o)
-RUNTIME_OBJ = $(RUNTIME_SRC:%.cpp=%.o)
+RUNTIME_OBJ_P = $(RUNTIME_SRC:%.cpp=%_p.o)
+RUNTIME_OBJ_D = $(RUNTIME_SRC:%.cpp=%_d.o)
-DEPS = $(CC_SRCS:%.cpp=.%.d)
+DEPS = $(COLM_SRC:%.cpp=.%.d) $(RUNTIME_SRC:%.cpp=.%_p.d) $(RUNTIME_SRC:%.cpp=.%_d.d)
# Rules.
-all: colm $(RUNTIME)
+all: colm $(RUNTIME_P) $(RUNTIME_D)
+
+colm: $(GEN_SRC) $(COLM_OBJ) $(RUNTIME_OBJ_D) $(LIBS)
+ $(CXX) $(LDFLAGS) -o $@ $(COLM_OBJ) $(RUNTIME_OBJ_D) $(LIBS)
-colm: $(GEN_SRC) $(COLM_OBJ) $(RUNTIME_OBJ) $(LIBS)
- $(CXX) $(LDFLAGS) -o $@ $(COLM_OBJ) $(RUNTIME_OBJ) $(LIBS)
+$(RUNTIME_P): $(RUNTIME_OBJ_P)
+ ar -cr $@ $^
-$(RUNTIME): $(RUNTIME_OBJ)
- ar -cr $@ $(RUNTIME_OBJ)
+$(RUNTIME_D): $(RUNTIME_OBJ_D)
+ ar -cr $@ $^
version.h: ../version.mk
echo '#define VERSION "$(VERSION)"' > version.h
@@ -114,9 +122,18 @@ lmscan.cpp: lmscan.rl
endif
-%.o: %.cpp
- @$(CXX) -M $(DEFS) $(INCS) $< > .$*.d
- $(CXX) -c $(CFLAGS) $(DEFS) $(INCS) -o $@ $<
+$(COLM_OBJ): %.o: %.cpp
+ @$(CXX) -M $(DEFS_COLM) $(INCS) $< > .$*.d
+ $(CXX) -c $(CFLAGS) $(DEFS_COLM) $(INCS) -o $@ $<
+
+$(RUNTIME_OBJ_P): %_p.o: %.cpp
+ @$(CXX) -M -MT $@ $(DEFS_RT_P) $(INCS) $< > .$*_p.d
+ $(CXX) -c $(CFLAGS) $(DEFS_RT_P) $(INCS) -o $@ $<
+
+$(RUNTIME_OBJ_D): %_d.o: %.cpp
+ @$(CXX) -M -MT $@ $(DEFS_RT_D) $(INCS) $< > .$*_d.d
+ $(CXX) -c $(CFLAGS) $(DEFS_RT_D) $(INCS) -o $@ $<
+
distclean: clean
rm -f Makefile config.h
@@ -126,7 +143,7 @@ EXTRA_CLEAN = $(GEN_SRC)
endif
clean:
- rm -f tags .*.d *.o colm $(EXTRA_CLEAN) $(RUNTIME)
+ rm -f tags .*.d *.o colm $(EXTRA_CLEAN) $(RUNTIME_P) $(RUNTIME_D)
install: all
install -d $(PREFIX)/bin
diff --git a/colm/bytecode.cpp b/colm/bytecode.cpp
index 25d4d38b..787fa353 100644
--- a/colm/bytecode.cpp
+++ b/colm/bytecode.cpp
@@ -77,11 +77,11 @@ using std::endl;
i |= ((Word) *instr++) << 8; \
} while(0)
-int colm_log_bytecode = 1;
-int colm_log_parse = 1;
-int colm_log_match = 1;
-int colm_log_compile = 1;
-int colm_log_conds = 1;
+int colm_log_bytecode = 0;
+int colm_log_parse = 0;
+int colm_log_match = 0;
+int colm_log_compile = 0;
+int colm_log_conds = 0;
Tree *prep_parse_tree( Program *prg, Tree **sp, Tree *tree )
{
diff --git a/colm/bytecode.h b/colm/bytecode.h
index 52e4d216..c13578a7 100644
--- a/colm/bytecode.h
+++ b/colm/bytecode.h
@@ -583,7 +583,8 @@ template <class T> T *PoolAlloc<T>::allocate()
if ( pool == 0 ) {
if ( nextel == FRESH_BLOCK ) {
#ifdef COLM_LOG_BYTECODE
- cerr << "allocating " << FRESH_BLOCK << " Elements of type T" << endl;
+ if ( colm_log_bytecode )
+ cerr << "allocating " << FRESH_BLOCK << " Elements of type T" << endl;
#endif
PoolBlock<T> *newBlock = new PoolBlock<T>;
diff --git a/colm/colm.h b/colm/colm.h
index 6ae9fc68..b3a99e0d 100644
--- a/colm/colm.h
+++ b/colm/colm.h
@@ -47,6 +47,7 @@ extern const char *outputFileName;
extern std::ostream *outStream;
extern bool generateGraphviz;
extern bool branchPointInfo;
+extern bool verbose, logging;
extern bool addUniqueEmptyProductions;
extern int gblErrorCount;
diff --git a/colm/fsmcodegen.cpp b/colm/fsmcodegen.cpp
index 94a2307e..29d840ee 100644
--- a/colm/fsmcodegen.cpp
+++ b/colm/fsmcodegen.cpp
@@ -1061,6 +1061,13 @@ void FsmCodeGen::writeCode()
out <<
"int main( int argc, char **argv )\n"
"{\n"
+ " /* Always on because because logging is controlled with ifdefs in\n"
+ " * the runtime lib. */\n"
+ " colm_log_bytecode = 1;\n"
+ " colm_log_parse = 1;\n"
+ " colm_log_match = 1;\n"
+ " colm_log_compile = 1;\n"
+ " colm_log_conds = 1;\n"
" Program program( true, &main_runtimeData );\n"
" program.run();\n"
" return 0;\n"
diff --git a/colm/main.cpp b/colm/main.cpp
index 3c50e882..db2336a5 100644
--- a/colm/main.cpp
+++ b/colm/main.cpp
@@ -73,6 +73,8 @@ const char *inputFileName = 0;
const char *outputFileName = 0;
bool generateGraphviz = false;
+bool verbose = false;
+bool logging = false;
bool branchPointInfo = false;
bool addUniqueEmptyProductions = false;
@@ -150,9 +152,11 @@ void usage()
"usage: colm [options] file\n"
"general:\n"
" -h, -H, -?, --help print this usage and exit\n"
-" -v, --version print version information and exit\n"
+" --version print version information and exit\n"
" -o <file> write output to <file>\n"
" -i show conflict information\n"
+" -v make colm verbose\n"
+" -l compile logging into the output executable\n"
;
}
@@ -289,8 +293,8 @@ void compileOutput( const char *argv0 )
" -g"
" -o %s"
" %s"
- " %s/../colm/runtime.a",
- location, location, location, exec, outputFileName, location );
+ " %s/../colm/runtime_%c.a",
+ location, location, location, exec, outputFileName, location, logging ? 'd' : 'p' );
if ( colm_log_compile ) {
cout << "compiling: " << outputFileName << endl;
}
@@ -301,12 +305,18 @@ void compileOutput( const char *argv0 )
void process_args( int argc, const char **argv )
{
- ParamCheck pc( "io:S:M:vHh?-:s", argc, argv );
+ ParamCheck pc( "vlio:S:M:vHh?-:s", argc, argv );
while ( pc.check() ) {
switch ( pc.state ) {
case ParamCheck::match:
switch ( pc.parameter ) {
+ case 'v':
+ verbose = true;
+ break;
+ case 'l':
+ logging = true;
+ break;
case 'i':
branchPointInfo = true;
break;
@@ -322,10 +332,6 @@ void process_args( int argc, const char **argv )
}
break;
- /* Version and help. */
- case 'v':
- version();
- exit(0);
case 'H': case 'h': case '?':
usage();
exit(0);
@@ -372,6 +378,14 @@ int main(int argc, const char **argv)
{
process_args( argc, argv );
+ if ( verbose ) {
+ colm_log_bytecode = 1;
+ colm_log_parse = 1;
+ colm_log_match = 1;
+ colm_log_compile = 1;
+ colm_log_conds = 1;
+ }
+
/* Bail on above errors. */
if ( gblErrorCount > 0 )
exit(1);