summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2013-02-10 21:04:21 -0500
committerAdrian Thurston <thurston@complang.org>2013-02-10 21:04:21 -0500
commit563cffb88a6a9d8e60457bd7898c4c941a8b8843 (patch)
treefa13315e3e82a9e54039eda0647b603300c089e5
parentb81b01924867d507f6ebacc7e9bf4bff533b46a6 (diff)
downloadcolm-563cffb88a6a9d8e60457bd7898c4c941a8b8843.tar.gz
the FsmRun struct is now contained in PdaRun
Still accessing it with a pointer though, instead of changing all the access points.
-rw-r--r--colm/compiler.cc7
-rw-r--r--colm/pdarun.c12
-rw-r--r--colm/pdarun.h4
-rw-r--r--colm/tree.c5
4 files changed, 13 insertions, 15 deletions
diff --git a/colm/compiler.cc b/colm/compiler.cc
index 25d95397..4bf9d7c1 100644
--- a/colm/compiler.cc
+++ b/colm/compiler.cc
@@ -1239,11 +1239,10 @@ PdaRun *Compiler::parsePattern( Program *prg, Tree **sp, const InputLoc &loc,
int parserId, StreamImpl *sourceStream )
{
StreamImpl *in = new StreamImpl;
- PdaRun *pdaRun = new PdaRun;
- pdaRun->fsmRun = new FsmRun;
-
initStreamImpl( in );
- initPdaRun( prg, pdaRun, pdaRun->fsmRun, pdaTables, parserId, 0, false, 0 );
+
+ PdaRun *pdaRun = new PdaRun;
+ initPdaRun( prg, pdaRun, pdaTables, parserId, 0, false, 0 );
Stream *res = streamAllocate( prg );
res->id = LEL_ID_STREAM;
diff --git a/colm/pdarun.c b/colm/pdarun.c
index 3ed94374..c1c4fb71 100644
--- a/colm/pdarun.c
+++ b/colm/pdarun.c
@@ -1416,6 +1416,8 @@ free_tree:
void clearPdaRun( Program *prg, Tree **sp, PdaRun *pdaRun )
{
+ clearFsmRun( prg, pdaRun->fsmRun );
+
/* Remaining stack and parse trees underneath. */
clearParseTree( prg, sp, pdaRun->stackTop );
pdaRun->stackTop = 0;
@@ -1462,10 +1464,11 @@ int isParserStopFinished( PdaRun *pdaRun )
return done;
}
-void initPdaRun( Program *prg, PdaRun *pdaRun, FsmRun *fsmRun, PdaTables *tables,
+void initPdaRun( Program *prg, PdaRun *pdaRun, PdaTables *tables,
int parserId, long stopTarget, int revertOn, Tree *context )
{
memset( pdaRun, 0, sizeof(PdaRun) );
+
pdaRun->tables = tables;
pdaRun->parserId = parserId;
pdaRun->stopTarget = stopTarget;
@@ -1512,10 +1515,9 @@ void initPdaRun( Program *prg, PdaRun *pdaRun, FsmRun *fsmRun, PdaTables *tables
pdaRun->rcBlockCount = 0;
- pdaRun->fsmRun = fsmRun;
-
- initFsmRun( prg, fsmRun );
- newToken( prg, pdaRun, fsmRun );
+ pdaRun->fsmRun = &pdaRun->_fsmRun;
+ initFsmRun( prg, pdaRun->fsmRun );
+ newToken( prg, pdaRun, pdaRun->fsmRun );
}
long stackTopTarget( Program *prg, PdaRun *pdaRun )
diff --git a/colm/pdarun.h b/colm/pdarun.h
index 00f07885..5b81853b 100644
--- a/colm/pdarun.h
+++ b/colm/pdarun.h
@@ -348,6 +348,7 @@ typedef struct _PdaRun
Tree *parseErrorText;
FsmRun *fsmRun;
+ FsmRun _fsmRun;
} PdaRun;
void rtCodeVectReplace( RtCodeVect *vect, long pos, const Code *val, long len );
@@ -400,9 +401,8 @@ void decrementSteps( PdaRun *pdaRun );
int makeReverseCode( PdaRun *pdaRun );
void transferReverseCode( PdaRun *pdaRun, ParseTree *tree );
-void initPdaRun( struct ColmProgram *prg, PdaRun *pdaRun, FsmRun *fsmRun, PdaTables *tables,
+void initPdaRun( struct ColmProgram *prg, PdaRun *pdaRun, PdaTables *tables,
int parserId, long stopTarget, int revertOn, Tree *context );
-void clearPdaRun( struct ColmProgram *prg, Tree **root, PdaRun *pdaRun );
void initStreamImpl( StreamImpl *inputStream );
void clearStreamImpl( struct ColmProgram *prg, Tree **sp, StreamImpl *inputStream );
diff --git a/colm/tree.c b/colm/tree.c
index 341aad8d..36325847 100644
--- a/colm/tree.c
+++ b/colm/tree.c
@@ -987,10 +987,9 @@ Tree *createGeneric( Program *prg, long genericId )
parser->id = genericInfo->langElId;
parser->genericInfo = genericInfo;
parser->pdaRun = malloc( sizeof(PdaRun) );
- parser->pdaRun->fsmRun = malloc( sizeof(FsmRun) );
/* Start off the parsing process. */
- initPdaRun( prg, parser->pdaRun, parser->pdaRun->fsmRun, prg->rtd->pdaTables,
+ initPdaRun( prg, parser->pdaRun, prg->rtd->pdaTables,
genericInfo->parserId, false, false, 0 );
newGeneric = (Tree*) parser;
@@ -1043,9 +1042,7 @@ free_tree:
}
else if ( generic->type == GEN_PARSER ) {
Parser *parser = (Parser*)tree;
- clearFsmRun( prg, parser->pdaRun->fsmRun );
clearPdaRun( prg, sp, parser->pdaRun );
- free( parser->pdaRun->fsmRun );
free( parser->pdaRun );
treeDownref( prg, sp, (Tree*)parser->input );
mapElFree( prg, (MapEl*)parser );