summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2013-02-07 20:48:58 -0500
committerAdrian Thurston <thurston@complang.org>2013-02-07 20:48:58 -0500
commit7ac8061c708f32140be747dc5a6f312f3ebbfb29 (patch)
tree4d6d2cece35a7e555c9110b5335fe5805e3709d0
parent26b94103c203c9210fa9ce368084ee75356ab882 (diff)
downloadcolm-7ac8061c708f32140be747dc5a6f312f3ebbfb29.tar.gz
the eof marker is now a single bit rather than a pointer
-rw-r--r--colm/fsmcodegen.cc2
-rw-r--r--colm/fsmcodegen.h2
-rw-r--r--colm/fsmexec.cc2
-rw-r--r--colm/pdarun.c21
-rw-r--r--colm/pdarun.h10
5 files changed, 19 insertions, 18 deletions
diff --git a/colm/fsmcodegen.cc b/colm/fsmcodegen.cc
index 708922de..e82198c4 100644
--- a/colm/fsmcodegen.cc
+++ b/colm/fsmcodegen.cc
@@ -731,7 +731,7 @@ std::ostream &FsmCodeGen::EXIT_STATES()
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
out << " case " << st->id << ": out" << st->id << ": ";
if ( st->eofTrans != 0 ) {
- out << "if ( " << PE() << " == " << PEOF() << " ) {";
+ out << "if ( " << DATA_EOF() << " ) {";
TRANS_GOTO( st->eofTrans, 0 );
out << "\n";
out << "}";
diff --git a/colm/fsmcodegen.h b/colm/fsmcodegen.h
index d1f23166..5a24a0d2 100644
--- a/colm/fsmcodegen.h
+++ b/colm/fsmcodegen.h
@@ -99,7 +99,7 @@ protected:
string P() { return ACCESS() + "p"; }
string PE() { return ACCESS() + "pe"; }
- string PEOF() { return ACCESS() + "peof"; }
+ string DATA_EOF() { return ACCESS() + "eof"; }
string CS();
string TOP() { return ACCESS() + "top"; }
diff --git a/colm/fsmexec.cc b/colm/fsmexec.cc
index 94d2e18e..d3b06555 100644
--- a/colm/fsmexec.cc
+++ b/colm/fsmexec.cc
@@ -197,7 +197,7 @@ _again:
if ( ++fsmRun->p != fsmRun->pe )
goto _loop_head;
out:
- if ( fsmRun->p == fsmRun->peof ) {
+ if ( fsmRun->eof ) {
fsmRun->returnResult = false;
fsmRun->skipToklen = false;
_acts = fsmRun->tables->actions + fsmRun->tables->eofActions[fsmRun->cs];
diff --git a/colm/pdarun.c b/colm/pdarun.c
index af1967c6..1b30af27 100644
--- a/colm/pdarun.c
+++ b/colm/pdarun.c
@@ -65,7 +65,7 @@ void initFsmRun( FsmRun *fsmRun, Program *prg )
fsmRun->p = fsmRun->pe = 0;
fsmRun->toklen = 0;
- fsmRun->peof = (char*)-1;
+ fsmRun->eof = 0;
fsmRun->preRegion = -1;
}
@@ -140,7 +140,6 @@ Head *streamPull( Program *prg, FsmRun *fsmRun, StreamImpl *is, long length )
fsmRun->p = fsmRun->pe = 0;
fsmRun->toklen = 0;
- //fsmRun->peof = (char*)-1;
Head *tokdata = stringAllocPointer( prg, runBuf->data, length );
updatePosition( is, runBuf->data, length );
@@ -269,7 +268,7 @@ void resetToken( FsmRun *fsmRun )
if ( fsmRun->tokstart != 0 ) {
fsmRun->p = fsmRun->pe = 0;
fsmRun->toklen = 0;
- fsmRun->peof = (char*)-1;
+ fsmRun->eof = 0;
}
}
@@ -767,7 +766,6 @@ Head *peekMatch( Program *prg, FsmRun *fsmRun, StreamImpl *is )
fsmRun->p = fsmRun->pe = 0;
fsmRun->toklen = 0;
- //fsmRun->peof = (char*)-1;
Head *head = stringAllocPointer( prg, runBuf->data, length );
@@ -799,7 +797,6 @@ Head *extractMatch( Program *prg, FsmRun *fsmRun, StreamImpl *is )
fsmRun->p = fsmRun->pe = 0;
fsmRun->toklen = 0;
fsmRun->tokstart = 0;
- //fsmRun->peof = (char*)-1;
Head *head = stringAllocPointer( prg, runBuf->data, length );
@@ -934,7 +931,7 @@ void newToken( Program *prg, PdaRun *pdaRun, FsmRun *fsmRun )
{
fsmRun->p = fsmRun->pe = 0;
fsmRun->toklen = 0;
- fsmRun->peof = (char*)-1;
+ fsmRun->eof = 0;
/* Init the scanner vars. */
fsmRun->act = 0;
@@ -1047,7 +1044,7 @@ long scanToken( Program *prg, PdaRun *pdaRun, FsmRun *fsmRun, StreamImpl *is )
fsmRun->p = fsmRun->pe = 0;
//fsmRun->have = 0;
if ( fsmRun->tokstart != 0 )
- fsmRun->peof = fsmRun->pe;
+ fsmRun->eof = 1;
debug( REALM_SCAN, "EOS *******************\n" );
//else {
// return SCAN_EOS;
@@ -1058,7 +1055,7 @@ long scanToken( Program *prg, PdaRun *pdaRun, FsmRun *fsmRun, StreamImpl *is )
fsmRun->p = fsmRun->pe = 0;
//fsmRun->have = 0;
if ( fsmRun->tokstart != 0 )
- fsmRun->peof = fsmRun->pe;
+ fsmRun->eof = 1;
else
return SCAN_EOF;
break;
@@ -1069,20 +1066,20 @@ long scanToken( Program *prg, PdaRun *pdaRun, FsmRun *fsmRun, StreamImpl *is )
case INPUT_LANG_EL:
if ( fsmRun->tokstart != 0 )
- fsmRun->peof = fsmRun->pe;
+ fsmRun->eof = 1;
else
return SCAN_LANG_EL;
break;
case INPUT_TREE:
if ( fsmRun->tokstart != 0 )
- fsmRun->peof = fsmRun->pe;
+ fsmRun->eof = 1;
else
return SCAN_TREE;
break;
case INPUT_IGNORE:
if ( fsmRun->tokstart != 0 )
- fsmRun->peof = fsmRun->pe;
+ fsmRun->eof = 1;
else
return SCAN_IGNORE;
break;
@@ -1228,7 +1225,7 @@ case PcrPreEof:
fsmRun->p = fsmRun->pe = 0;
fsmRun->toklen = 0;
- fsmRun->peof = (char*)-1;
+ fsmRun->eof = 0;
pdaRun->fi = &prg->rtd->frameInfo[prg->rtd->lelInfo[pdaRun->tokenId].frameId];
pdaRun->frameId = prg->rtd->lelInfo[pdaRun->tokenId].frameId;
diff --git a/colm/pdarun.h b/colm/pdarun.h
index 350c10fb..1da0ef42 100644
--- a/colm/pdarun.h
+++ b/colm/pdarun.h
@@ -82,9 +82,13 @@ typedef struct _FsmRun
char *tokstart;
long tokend;
long toklen;
- char *p, *pe, *peof;
- int returnResult;
- int skipToklen;
+ char *p, *pe;
+
+ /* Bits. */
+ char eof;
+ char returnResult;
+ char skipToklen;
+
char *mark[MARK_SLOTS];
long matchedToken;
} FsmRun;