summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2011-09-28 04:52:07 +0000
committerAdrian Thurston <thurston@complang.org>2011-09-28 04:52:07 +0000
commit734b5b50461b2e03542afc42cffab1f46667a483 (patch)
treebec34ebfd60f18f09646413472f5769b92169b38
parentae0d30b6d54ac9bb06b01430616d65ddffb1dbfd (diff)
downloadcolm-734b5b50461b2e03542afc42cffab1f46667a483.tar.gz
Setting the ignore list generation. refs #323.
-rw-r--r--colm/fsmrun.c15
-rw-r--r--colm/pdarun.c5
-rw-r--r--colm/tree.c11
3 files changed, 22 insertions, 9 deletions
diff --git a/colm/fsmrun.c b/colm/fsmrun.c
index 69973e74..0e0016d7 100644
--- a/colm/fsmrun.c
+++ b/colm/fsmrun.c
@@ -669,12 +669,6 @@ void sendWithIgnore( Tree **sp, PdaRun *pdaRun, FsmRun *fsmRun, InputStream *inp
if ( ignoreKid != 0 ) {
ignoreKid = reverseKidList( ignoreKid );
- /* Make the ignore list for the left-ignore. */
- IgnoreList *leftIgnore = ilAllocate( pdaRun->prg );
- leftIgnore->id = LEL_ID_IGNORE_LIST;
- leftIgnore->child = ignoreKid;
- leftIgnore->flags |= AF_IS_LEFT_IGNORE;
-
/* Copy the ignore list first if we need to attach it as a right
* ignore. */
IgnoreList *rightIgnore = 0;
@@ -683,8 +677,17 @@ void sendWithIgnore( Tree **sp, PdaRun *pdaRun, FsmRun *fsmRun, InputStream *inp
rightIgnore->id = LEL_ID_IGNORE_LIST;
rightIgnore->child = copyKidList( pdaRun->prg, ignoreKid );
rightIgnore->flags |= AF_IS_RIGHT_IGNORE;
+ rightIgnore->generation = pdaRun->prg->nextIlGen++;
}
+ /* Make the ignore list for the left-ignore. */
+ IgnoreList *leftIgnore = ilAllocate( pdaRun->prg );
+ leftIgnore->id = LEL_ID_IGNORE_LIST;
+ leftIgnore->child = ignoreKid;
+ leftIgnore->flags |= AF_IS_LEFT_IGNORE;
+ leftIgnore->generation = pdaRun->prg->nextIlGen++;
+
+
/* Attach as left ignore to the token we are sending. */
if ( input->tree->flags & AF_LEFT_IGNORE ) {
/* The token already has a left-ignore. Merge by attaching it as a
diff --git a/colm/pdarun.c b/colm/pdarun.c
index 8efc1675..385e389e 100644
--- a/colm/pdarun.c
+++ b/colm/pdarun.c
@@ -412,7 +412,10 @@ again:
}
else {
Kid *kid = kidAllocate( pdaRun->prg );
- kid->tree = (Tree*)ilAllocate( pdaRun->prg );
+ IgnoreList *ignoreList = ilAllocate( pdaRun->prg );
+ ignoreList->generation = pdaRun->prg->nextIlGen++;
+
+ kid->tree = (Tree*)ignoreList;
kid->tree->id = LEL_ID_IGNORE_LIST;
kid->tree->refs = 1;
kid->tree->child = lel;
diff --git a/colm/tree.c b/colm/tree.c
index d17ebb53..b7ad8840 100644
--- a/colm/tree.c
+++ b/colm/tree.c
@@ -273,6 +273,7 @@ Tree *constructReplacementTree( Tree **bindings, Program *prg, long pat )
ignoreList->id = LEL_ID_IGNORE_LIST;
ignoreList->refs = 1;
ignoreList->child = ignore;
+ ignoreList->generation = prg->nextIlGen++;
Kid *ignoreHead = kidAllocate( prg );
ignoreHead->tree = (Tree*)ignoreList;
@@ -303,6 +304,7 @@ Tree *constructReplacementTree( Tree **bindings, Program *prg, long pat )
ignoreList->id = LEL_ID_IGNORE_LIST;
ignoreList->refs = 1;
ignoreList->child = ignore;
+ ignoreList->generation = prg->nextIlGen++;
Kid *ignoreHead = kidAllocate( prg );
ignoreHead->tree = (Tree*)ignoreList;
@@ -799,10 +801,11 @@ free_tree:
else if ( tree->id == LEL_ID_STREAM )
streamFree( prg, (Stream*) tree );
else {
- stringFree( prg, tree->tokdata );
- Kid *child = tree->child;
+ if ( tree->id != LEL_ID_IGNORE_LIST )
+ stringFree( prg, tree->tokdata );
/* Attributes and grammar-based children. */
+ Kid *child = tree->child;
while ( child != 0 ) {
Kid *next = child->next;
vm_push( child->tree );
@@ -2061,6 +2064,7 @@ rec_call:
if ( leadingIgnore != 0 ) {
long leadingPrintFlags = 0;
Kid *ignore = 0, *last = 0;
+ long youngest = -1;
debug( REALM_PRINT, "printing ignore %p\n", leadingIgnore->tree );
@@ -2074,6 +2078,9 @@ rec_call:
if ( leadingIgnore->tree->flags & AF_IS_LEFT_IGNORE )
leadingPrintFlags |= IPF_LEFT_PRESENT;
+ if ( ((IgnoreList*)leadingIgnore->tree)->generation > youngest )
+ youngest = ((IgnoreList*)leadingIgnore->tree)->generation;
+
if ( next == 0 )
break;