diff options
author | Adrian Thurston <thurston@complang.org> | 2013-02-09 13:40:03 -0500 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2013-02-09 13:40:03 -0500 |
commit | 0e22038b0cd1230e88888547fe862e26b6ce7945 (patch) | |
tree | b96f8e7375f11006a0e0e6550908fe95a6b97754 | |
parent | 3853e924647f680a8ec7d70367562cf11a29189d (diff) | |
download | colm-0e22038b0cd1230e88888547fe862e26b6ce7945.tar.gz |
store FsmRun inside PdaRun, remove from Parser
-rw-r--r-- | colm/bytecode.c | 14 | ||||
-rw-r--r-- | colm/compiler.cc | 6 | ||||
-rw-r--r-- | colm/pdarun.c | 2 | ||||
-rw-r--r-- | colm/pdarun.h | 2 | ||||
-rw-r--r-- | colm/tree.c | 8 | ||||
-rw-r--r-- | colm/tree.h | 1 |
6 files changed, 18 insertions, 15 deletions
diff --git a/colm/bytecode.c b/colm/bytecode.c index e8a89c7d..1b105a76 100644 --- a/colm/bytecode.c +++ b/colm/bytecode.c @@ -192,7 +192,7 @@ case PcrStart: if ( ! parser->pdaRun->parseError ) { parser->pdaRun->stopTarget = stopId; - long pcr = parseLoop( prg, sp, parser->pdaRun, parser->fsmRun, parser->input->in, entry ); + long pcr = parseLoop( prg, sp, parser->pdaRun, parser->pdaRun->fsmRun, parser->input->in, entry ); while ( pcr != PcrDone ) { @@ -202,7 +202,7 @@ case PcrGeneration: case PcrPreEof: case PcrReverse: - pcr = parseLoop( prg, sp, parser->pdaRun, parser->fsmRun, parser->input->in, entry ); + pcr = parseLoop( prg, sp, parser->pdaRun, parser->pdaRun->fsmRun, parser->input->in, entry ); } } @@ -222,7 +222,7 @@ case PcrStart: parser->input->in->funcs->setEof( parser->input->in ); if ( ! parser->pdaRun->parseError ) { - long pcr = parseLoop( prg, sp, parser->pdaRun, parser->fsmRun, parser->input->in, entry ); + long pcr = parseLoop( prg, sp, parser->pdaRun, parser->pdaRun->fsmRun, parser->input->in, entry ); while ( pcr != PcrDone ) { @@ -232,7 +232,7 @@ case PcrGeneration: case PcrPreEof: case PcrReverse: - pcr = parseLoop( prg, sp, parser->pdaRun, parser->fsmRun, parser->input->in, entry ); + pcr = parseLoop( prg, sp, parser->pdaRun, parser->pdaRun->fsmRun, parser->input->in, entry ); } } } @@ -259,7 +259,7 @@ break; } long undoParseFrag( Program *prg, Tree **sp, Parser *parser, long steps, long entry ) { StreamImpl *is = parser->input->in; - FsmRun *fsmRun = parser->fsmRun; + FsmRun *fsmRun = parser->pdaRun->fsmRun; PdaRun *pdaRun = parser->pdaRun; debug( REALM_PARSE, "undo parse frag, target steps: %ld, pdarun steps: %ld\n", steps, pdaRun->steps ); @@ -1153,7 +1153,7 @@ again: /* If there are captures (this is a translate block) then copy them into * the local frame now. */ LangElInfo *lelInfo = prg->rtd->lelInfo; - char **mark = exec->parser->fsmRun->mark; + char **mark = exec->parser->pdaRun->fsmRun->mark; int i; for ( i = 0; i < lelInfo[exec->parser->pdaRun->tokenId].numCaptureAttr; i++ ) { @@ -2457,7 +2457,7 @@ again: Stream *accumStream = (Stream*)vm_pop(); Tree *len = vm_pop(); - Tree *string = streamPullBc( prg, exec->parser->fsmRun, accumStream->in, len ); + Tree *string = streamPullBc( prg, exec->parser->pdaRun->fsmRun, accumStream->in, len ); treeUpref( string ); vm_push( string ); diff --git a/colm/compiler.cc b/colm/compiler.cc index f87f39ad..23262385 100644 --- a/colm/compiler.cc +++ b/colm/compiler.cc @@ -1239,11 +1239,11 @@ PdaRun *Compiler::parsePattern( Program *prg, Tree **sp, const InputLoc &loc, int parserId, StreamImpl *sourceStream ) { StreamImpl *in = new StreamImpl; - FsmRun *fsmRun = new FsmRun; PdaRun *pdaRun = new PdaRun; + pdaRun->fsmRun = new FsmRun; initStreamImpl( in ); - initPdaRun( prg, pdaRun, fsmRun, pdaTables, parserId, 0, false, 0 ); + initPdaRun( prg, pdaRun, pdaRun->fsmRun, pdaTables, parserId, 0, false, 0 ); Stream *res = streamAllocate( prg ); res->id = LEL_ID_STREAM; @@ -1251,7 +1251,7 @@ PdaRun *Compiler::parsePattern( Program *prg, Tree **sp, const InputLoc &loc, in->funcs->appendStream( in, (Tree*)res ); in->funcs->setEof( in ); - long pcr = parseLoop( prg, sp, pdaRun, fsmRun, in, PcrStart ); + long pcr = parseLoop( prg, sp, pdaRun, pdaRun->fsmRun, in, PcrStart ); assert( pcr == PcrDone ); if ( pdaRun->parseError ) { cout << "PARSE ERROR " << loc.line << ":" << loc.col; diff --git a/colm/pdarun.c b/colm/pdarun.c index 360d426f..0e48efc0 100644 --- a/colm/pdarun.c +++ b/colm/pdarun.c @@ -1479,6 +1479,8 @@ void initPdaRun( Program *prg, PdaRun *pdaRun, FsmRun *fsmRun, PdaTables *tables pdaRun->rcBlockCount = 0; + pdaRun->fsmRun = fsmRun; + initFsmRun( prg, fsmRun ); newToken( prg, pdaRun, fsmRun ); } diff --git a/colm/pdarun.h b/colm/pdarun.h index 6b9b065c..818a753c 100644 --- a/colm/pdarun.h +++ b/colm/pdarun.h @@ -346,6 +346,8 @@ typedef struct _PdaRun int rcBlockCount; Tree *parseErrorText; + + FsmRun *fsmRun; } PdaRun; void rtCodeVectReplace( RtCodeVect *vect, long pos, const Code *val, long len ); diff --git a/colm/tree.c b/colm/tree.c index 86474779..767dc35d 100644 --- a/colm/tree.c +++ b/colm/tree.c @@ -986,11 +986,11 @@ Tree *createGeneric( Program *prg, long genericId ) Parser *parser = (Parser*)mapElAllocate( prg ); parser->id = genericInfo->langElId; parser->genericInfo = genericInfo; - parser->fsmRun = malloc( sizeof(FsmRun) ); parser->pdaRun = malloc( sizeof(PdaRun) ); + parser->pdaRun->fsmRun = malloc( sizeof(FsmRun) ); /* Start off the parsing process. */ - initPdaRun( prg, parser->pdaRun, parser->fsmRun, prg->rtd->pdaTables, + initPdaRun( prg, parser->pdaRun, parser->pdaRun->fsmRun, prg->rtd->pdaTables, genericInfo->parserId, false, false, 0 ); newGeneric = (Tree*) parser; @@ -1043,10 +1043,10 @@ free_tree: } else if ( generic->type == GEN_PARSER ) { Parser *parser = (Parser*)tree; - clearFsmRun( prg, parser->fsmRun ); + clearFsmRun( prg, parser->pdaRun->fsmRun ); clearPdaRun( prg, sp, parser->pdaRun ); + free( parser->pdaRun->fsmRun ); free( parser->pdaRun ); - free( parser->fsmRun ); treeDownref( prg, sp, (Tree*)parser->input ); mapElFree( prg, (MapEl*)parser ); } diff --git a/colm/tree.h b/colm/tree.h index 8b6d509d..529c0185 100644 --- a/colm/tree.h +++ b/colm/tree.h @@ -203,7 +203,6 @@ typedef struct _Parser GenericInfo *genericInfo; struct _PdaRun *pdaRun; - struct _FsmRun *fsmRun; struct _Stream *input; Tree *result; } Parser; |