summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2011-11-19 07:05:03 +0000
committerAdrian Thurston <thurston@complang.org>2011-11-19 07:05:03 +0000
commit68e669e01e5505492ab0ddb0f78d70981eb6fdb8 (patch)
treee621d811bc8358f942e85fe7c24ad8aeb1fbdf8e
parent1afd6c564f69918e6f5beea1984f56856b169beb (diff)
downloadcolm-68e669e01e5505492ab0ddb0f78d70981eb6fdb8.tar.gz
Some cleanup. Don't need PdaRun::input2.
-rw-r--r--colm/bytecode.c2
-rw-r--r--colm/ctinput.cc2
-rw-r--r--colm/fsmrun.c27
-rw-r--r--colm/pdarun.h5
-rw-r--r--colm/tree.c2
-rw-r--r--colm/tree.h2
6 files changed, 18 insertions, 22 deletions
diff --git a/colm/bytecode.c b/colm/bytecode.c
index 30218e37..ce4f9cac 100644
--- a/colm/bytecode.c
+++ b/colm/bytecode.c
@@ -2874,7 +2874,7 @@ again:
debug( REALM_BYTECODE, "IN_MAKE_TOKEN\n" );
- Tree *result = makeToken2( prg, sp, nargs );
+ Tree *result = constructToken( prg, sp, nargs );
long i;
for ( i = 0; i < nargs; i++ ) {
Tree *arg = vm_pop();
diff --git a/colm/ctinput.cc b/colm/ctinput.cc
index 60aa51e2..1882c2fe 100644
--- a/colm/ctinput.cc
+++ b/colm/ctinput.cc
@@ -358,7 +358,7 @@ Kid *sendNamedLangEl( Program *prg, Tree **sp, PdaRun *pdaRun, FsmRun *fsmRun, I
if ( data != 0 )
tokdata = stringAllocFull( prg, data, length );
- Kid *input = makeToken( prg, pdaRun, fsmRun, inputStream, klangEl->id, tokdata, true, bindId );
+ Kid *input = makeTokenWithData( prg, pdaRun, fsmRun, inputStream, klangEl->id, tokdata, true, bindId );
pdaRun->consumed += 1;
diff --git a/colm/fsmrun.c b/colm/fsmrun.c
index a64988fc..6904224f 100644
--- a/colm/fsmrun.c
+++ b/colm/fsmrun.c
@@ -507,7 +507,7 @@ void ignoreTree( Program *prg, PdaRun *pdaRun, Tree *tree )
pdaRun->accumIgnore = ignore;
}
-Kid *makeToken( Program *prg, PdaRun *pdaRun, FsmRun *fsmRun, InputStream *inputStream, int id,
+Kid *makeTokenWithData( Program *prg, PdaRun *pdaRun, FsmRun *fsmRun, InputStream *inputStream, int id,
Head *tokdata, int namedLangEl, int bindId )
{
/* Make the token object. */
@@ -786,7 +786,7 @@ Kid *sendToken( Program *prg, Tree **sp, InputStream *inputStream, FsmRun *fsmRu
updatePosition( inputStream, fsmRun->tokstart, tokdata->length );
- Kid *input = makeToken( prg, pdaRun, fsmRun, inputStream, id, tokdata, false, 0 );
+ Kid *input = makeTokenWithData( prg, pdaRun, fsmRun, inputStream, id, tokdata, false, 0 );
incrementConsumed( pdaRun );
@@ -1075,12 +1075,13 @@ case PcrStart:
break;
}
- pdaRun->input2 = 0;
+ assert( pdaRun->input1 == 0 );
+ pdaRun->input1 = 0;
/* Check for EOF. */
if ( pdaRun->tokenId == SCAN_EOF ) {
inputStream->eofSent = true;
- pdaRun->input2 = sendEof( prg, sp, inputStream, fsmRun, pdaRun );
+ pdaRun->input1 = sendEof( prg, sp, inputStream, fsmRun, pdaRun );
pdaRun->frameId = prg->rtd->regionInfo[fsmRun->region].eofFrameId;
if ( prg->ctxDepParsing && pdaRun->frameId >= 0 ) {
@@ -1096,7 +1097,7 @@ case PcrPreEof:
}
}
else if ( pdaRun->tokenId == SCAN_UNDO ) {
- /* Fall through with input2 = 0. FIXME: Do we need to send back ignore? */
+ /* Fall through with input1 = 0. FIXME: Do we need to send back ignore? */
debug( REALM_PARSE, "invoking undo from the scanner\n" );
}
else if ( pdaRun->tokenId == SCAN_ERROR ) {
@@ -1130,13 +1131,13 @@ case PcrPreEof:
debug( REALM_PARSE, "sending an named lang el\n" );
/* A named language element (parsing colm program). */
- pdaRun->input2 = sendNamedLangEl( prg, sp, pdaRun, fsmRun, inputStream );
+ pdaRun->input1 = sendNamedLangEl( prg, sp, pdaRun, fsmRun, inputStream );
}
else if ( pdaRun->tokenId == SCAN_TREE ) {
debug( REALM_PARSE, "sending a tree\n" );
/* A tree already built. */
- pdaRun->input2 = sendTree( prg, sp, pdaRun, fsmRun, inputStream );
+ pdaRun->input1 = sendTree( prg, sp, pdaRun, fsmRun, inputStream );
}
else if ( pdaRun->tokenId == SCAN_IGNORE ) {
debug( REALM_PARSE, "sending an ignore token\n" );
@@ -1188,22 +1189,18 @@ case PcrGeneration:
prg->rtd->lelInfo[pdaRun->tokenId].name );
/* Is a plain token. */
- pdaRun->input2 = sendToken( prg, sp, inputStream, fsmRun, pdaRun, pdaRun->tokenId );
+ pdaRun->input1 = sendToken( prg, sp, inputStream, fsmRun, pdaRun, pdaRun->tokenId );
}
- if ( pdaRun->input2 != 0 && pdaRun->cs >= 0 ) {
+ if ( pdaRun->input1 != 0 && pdaRun->cs >= 0 ) {
if ( pdaRun->accumIgnore == 0 ) {
/* Recording the next region. */
- pt(pdaRun->input2->tree)->region = pdaRun->nextRegionInd;
- if ( pdaRun->tables->tokenRegions[pt(pdaRun->input2->tree)->region+1] != 0 )
+ pt(pdaRun->input1->tree)->region = pdaRun->nextRegionInd;
+ if ( pdaRun->tables->tokenRegions[pt(pdaRun->input1->tree)->region+1] != 0 )
pdaRun->numRetry += 1;
}
}
- assert( pdaRun->input1 == 0 );
- pdaRun->input1 = pdaRun->input2;
- pdaRun->input2 = 0;
-
long pcr = parseToken( prg, sp, pdaRun, fsmRun, inputStream, PcrStart );
while ( pcr != PcrDone ) {
diff --git a/colm/pdarun.h b/colm/pdarun.h
index 41a0283e..6de16846 100644
--- a/colm/pdarun.h
+++ b/colm/pdarun.h
@@ -253,7 +253,6 @@ typedef struct _PdaRun
int tokenId;
Head *tokdata;
int frameId;
- Kid *input2;
Kid *ignore2;
Kid *ignore3;
int next;
@@ -354,8 +353,8 @@ long sendBack( struct ColmProgram *prg, Tree **sp, PdaRun *pdaRun, FsmRun *fsmRu
InputStream *inputStream, Kid *input, long entry );
void unbind( struct ColmProgram *prg, Tree **sp, PdaRun *pdaRun, Tree *tree );
void queueBackTree( struct ColmProgram *prg, Tree **sp, PdaRun *pdaRun, FsmRun *fsmRun, InputStream *inputStream, Kid *input );
-Kid *makeToken( struct ColmProgram *prg, PdaRun *pdaRun, FsmRun *fsmRun, InputStream *inputStream, int id,
- Head *tokdata, int namedLangEl, int bindId );
+Kid *makeTokenWithData( struct ColmProgram *prg, PdaRun *pdaRun, FsmRun *fsmRun,
+ InputStream *inputStream, int id, Head *tokdata, int namedLangEl, int bindId );
void makeTokenPushBinding( PdaRun *pdaRun, int bindId, Tree *tree );
void executeGenerationAction( struct ColmProgram *prg, Tree **sp, FsmRun *fsmRun, PdaRun *pdaRun,
InputStream *inputStream, int frameId, Code *code, long id, Head *tokdata );
diff --git a/colm/tree.c b/colm/tree.c
index 2e512ed1..6cd8c535 100644
--- a/colm/tree.c
+++ b/colm/tree.c
@@ -454,7 +454,7 @@ Kid *constructReplacementKid( Tree **bindings, Program *prg, Kid *prev, long pat
return kid;
}
-Tree *makeToken2( Program *prg, Tree **root, long nargs )
+Tree *constructToken( Program *prg, Tree **root, long nargs )
{
Tree **const sp = root;
Tree **base = vm_ptop() + nargs;
diff --git a/colm/tree.h b/colm/tree.h
index 106492f7..c9389126 100644
--- a/colm/tree.h
+++ b/colm/tree.h
@@ -278,8 +278,8 @@ 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 *makeToken2( struct ColmProgram *prg, Tree **root, long nargs );
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 );