diff options
-rw-r--r-- | colm/bytecode.c | 2 | ||||
-rw-r--r-- | colm/pdarun.c | 18 | ||||
-rw-r--r-- | colm/tree.c | 14 | ||||
-rw-r--r-- | colm/tree.h | 2 |
4 files changed, 12 insertions, 24 deletions
diff --git a/colm/bytecode.c b/colm/bytecode.c index 68b983e9..92c7a194 100644 --- a/colm/bytecode.c +++ b/colm/bytecode.c @@ -157,7 +157,7 @@ Tree *prepParseTree( Program *prg, Tree **sp, Tree *tree ) debug( REALM_BYTECODE, "copying tree in send function\n" ); Kid *unused = 0; - tree = copyRealTree( prg, tree, 0, &unused, true ); + tree = copyRealTree( prg, tree, 0, &unused ); return tree; } diff --git a/colm/pdarun.c b/colm/pdarun.c index e59b4b5d..1dc28d71 100644 --- a/colm/pdarun.c +++ b/colm/pdarun.c @@ -508,6 +508,7 @@ void ignoreTree( Program *prg, PdaRun *pdaRun, Tree *tree ) Kid *ignore = kidAllocate( prg ); ignore->tree = (Tree*)parseTreeAllocate( prg ); + ignore->tree->flags |= AF_PARSE_TREE; pt(ignore->tree)->shadow = kidAllocate( prg ); pt(ignore->tree)->shadow->tree = tree; @@ -528,9 +529,9 @@ Kid *makeTokenWithData( Program *prg, PdaRun *pdaRun, FsmRun *fsmRun, InputStrea Kid *input = 0; input = kidAllocate( prg ); - input->tree = (Tree*)parseTreeAllocate( prg ); + input->tree = treeAllocate( prg ); + debug( REALM_PARSE, "made token %p\n", input->tree ); - input->tree->flags |= AF_PARSE_TREE; if ( namedLangEl ) input->tree->flags |= AF_NAMED; @@ -732,8 +733,7 @@ void sendIgnore( Program *prg, Tree **sp, InputStream *inputStream, FsmRun *fsmR debug( REALM_PARSE, "ignoring: %.*s\n", ignoreStr->length, ignoreStr->data ); - Tree *tree = (Tree*)parseTreeAllocate( prg ); - tree->flags |= AF_PARSE_TREE; + Tree *tree = treeAllocate( prg ); tree->refs = 1; tree->id = id; tree->tokdata = ignoreStr; @@ -854,8 +854,7 @@ static void sendEof( Program *prg, Tree **sp, InputStream *inputStream, FsmRun * head->location->byte = inputStream->byte; Kid *input = kidAllocate( prg ); - input->tree = (Tree*)parseTreeAllocate( prg ); - input->tree->flags |= AF_PARSE_TREE; + input->tree = treeAllocate( prg ); input->tree->refs = 1; input->tree->id = prg->rtd->eofLelIds[pdaRun->parserId]; @@ -1386,9 +1385,7 @@ void initPdaRun( PdaRun *pdaRun, Program *prg, PdaTables *tables, pdaRun->stackTop->tree->refs = 1; pt(pdaRun->stackTop->tree)->shadow = kidAllocate( prg ); - pt(pdaRun->stackTop->tree)->shadow->tree = (Tree*)parseTreeAllocate( prg ); - pt(pdaRun->stackTop->tree)->shadow->tree->flags |= AF_PARSE_TREE; - pt(pt(pdaRun->stackTop->tree)->shadow->tree)->state = -1; + pt(pdaRun->stackTop->tree)->shadow->tree = treeAllocate( prg ); pt(pdaRun->stackTop->tree)->shadow->tree->refs = 1; pdaRun->numRetry = 0; @@ -1810,8 +1807,7 @@ again: pt(pdaRun->lel->tree)->retryLower = 0; pt(pdaRun->redLel->tree)->shadow = kidAllocate( prg ); - pt(pdaRun->redLel->tree)->shadow->tree = (Tree*)parseTreeAllocate( prg ); - pt(pdaRun->redLel->tree)->shadow->tree->flags |= AF_PARSE_TREE; + pt(pdaRun->redLel->tree)->shadow->tree = treeAllocate( prg ); pt(pdaRun->redLel->tree)->shadow->tree->refs = 1; pt(pdaRun->redLel->tree)->shadow->tree->id = prg->rtd->prodInfo[pdaRun->reduction].lhsId; pt(pdaRun->redLel->tree)->shadow->tree->prodNum = prg->rtd->prodInfo[pdaRun->reduction].prodNum; diff --git a/colm/tree.c b/colm/tree.c index f020d767..a6f3ccda 100644 --- a/colm/tree.c +++ b/colm/tree.c @@ -593,19 +593,11 @@ Kid *copyKidList( Program *prg, Kid *kidList ) } /* New tree has zero ref. */ -Tree *copyRealTree( Program *prg, Tree *tree, Kid *oldNextDown, - Kid **newNextDown, int parseTree ) +Tree *copyRealTree( Program *prg, Tree *tree, Kid *oldNextDown, Kid **newNextDown ) { /* Need to keep a lookout for next down. If * copying it, return the copy. */ - Tree *newTree; - if ( parseTree ) { - newTree = (Tree*) parseTreeAllocate( prg ); - newTree->flags |= AF_PARSE_TREE; - } - else { - newTree = treeAllocate( prg ); - } + Tree *newTree = treeAllocate( prg ); newTree->id = tree->id; newTree->tokdata = stringCopy( prg, tree->tokdata ); @@ -753,7 +745,7 @@ Tree *copyTree( Program *prg, Tree *tree, Kid *oldNextDown, Kid **newNextDown ) else if ( tree->id == LEL_ID_STREAM ) assert(false); else { - tree = copyRealTree( prg, tree, oldNextDown, newNextDown, false ); + tree = copyRealTree( prg, tree, oldNextDown, newNextDown ); } assert( tree->refs == 0 ); diff --git a/colm/tree.h b/colm/tree.h index 895ac409..f1b1bd8b 100644 --- a/colm/tree.h +++ b/colm/tree.h @@ -327,7 +327,7 @@ Tree *treeIterDerefCur( TreeIter *iter ); /* For making references of attributes. */ Kid *getFieldKid( Tree *tree, Word field ); -Tree *copyRealTree( struct ColmProgram *prg, Tree *tree, Kid *oldNextDown, Kid **newNextDown, int parsed ); +Tree *copyRealTree( struct ColmProgram *prg, Tree *tree, Kid *oldNextDown, Kid **newNextDown ); void splitIterCur( struct ColmProgram *prg, Tree ***psp, TreeIter *iter ); Tree *setListMem( List *list, Half field, Tree *value ); |