summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2009-03-06 04:09:10 +0000
committerAdrian Thurston <thurston@complang.org>2009-03-06 04:09:10 +0000
commit13f3e768a8e8c5964d45d13b86a1d72f1770ce33 (patch)
treec941aa0cefb2260ec157e29b363c20f4beb9dc8d
parentf623903bfd8561877f8e968231bfdc8a1fee6258 (diff)
downloadcolm-13f3e768a8e8c5964d45d13b86a1d72f1770ce33.tar.gz
Record the matched token in emitToken and the EMIT_TOKEN code generator.
-rw-r--r--colm/fsmcodegen.cpp16
-rw-r--r--colm/fsmexec.cpp5
-rw-r--r--colm/fsmrun.cpp18
-rw-r--r--colm/fsmrun.h1
4 files changed, 24 insertions, 16 deletions
diff --git a/colm/fsmcodegen.cpp b/colm/fsmcodegen.cpp
index 0f5b1960..9e1ff32d 100644
--- a/colm/fsmcodegen.cpp
+++ b/colm/fsmcodegen.cpp
@@ -197,12 +197,14 @@ void FsmCodeGen::SET_TOKSTART( ostream &ret, InlineItem *item )
void FsmCodeGen::EMIT_TOKEN( ostream &ret, KlangEl *token )
{
- if ( token->transBlock != 0 )
- ret << " execGen( " << token->id << " );\n";
- else if ( token->ignore )
- ret << " sendIgnore( " << token->id << " );\n";
- else
- ret << " sendToken( " << token->id << " );\n";
+// if ( token->transBlock != 0 )
+// ret << " execGen( " << token->id << " );\n";
+// else if ( token->ignore )
+// ret << " sendIgnore( " << token->id << " );\n";
+// else
+// ret << " sendToken( " << token->id << " );\n";
+
+ ret << " matchedToken = " << token->id << ";\n";
}
void FsmCodeGen::LM_SWITCH( ostream &ret, InlineItem *item,
@@ -1010,7 +1012,7 @@ void FsmCodeGen::writeExec()
out <<
"void FsmRun::execute()\n"
"{\n"
- "_resume:\n";
+ "/*_resume:*/\n";
if ( redFsm->errState != 0 ) {
out <<
diff --git a/colm/fsmexec.cpp b/colm/fsmexec.cpp
index d08158b3..4a118ff5 100644
--- a/colm/fsmexec.cpp
+++ b/colm/fsmexec.cpp
@@ -99,7 +99,10 @@ void FsmRun::execute()
unsigned int _nacts;
const char *_keys;
-//_resume:
+ /* Init the token match to nothing (the sentinal). */
+ matchedToken = 0;
+
+/*_resume:*/
if ( cs == tables->errorState )
goto out;
diff --git a/colm/fsmrun.cpp b/colm/fsmrun.cpp
index 7281c76b..c1be11d7 100644
--- a/colm/fsmrun.cpp
+++ b/colm/fsmrun.cpp
@@ -703,14 +703,16 @@ void FsmRun::sendToken( long id )
void FsmRun::emitToken( KlangEl *token )
{
- bool ctxDepParsing = prg->ctxDepParsing;
- LangElInfo *lelInfo = parser->tables->rtd->lelInfo;
- if ( ctxDepParsing && lelInfo[token->id].frameId >= 0 )
- execGen( token->id );
- else if ( token->ignore )
- sendIgnore( token->id );
- else
- sendToken( token->id );
+// bool ctxDepParsing = prg->ctxDepParsing;
+// LangElInfo *lelInfo = parser->tables->rtd->lelInfo;
+// if ( ctxDepParsing && lelInfo[token->id].frameId >= 0 )
+// execGen( token->id );
+// else if ( token->ignore )
+// sendIgnore( token->id );
+// else
+// sendToken( token->id );
+
+ matchedToken = token->id;
}
/* Load up a token, starting from tokstart if it is set. If not set then
diff --git a/colm/fsmrun.h b/colm/fsmrun.h
index 1da1c266..ac3274ca 100644
--- a/colm/fsmrun.h
+++ b/colm/fsmrun.h
@@ -125,6 +125,7 @@ struct FsmRun
RunBuf *runBuf;
bool returnResult;
char *mark[MARK_SLOTS];
+ long matchedToken;
};
void send_queued_tokens( FsmRun *fsmRun, PdaRun *parser );