diff options
author | Adrian Thurston <thurston@complang.org> | 2008-11-02 00:03:19 +0000 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2008-11-02 00:03:19 +0000 |
commit | 5b919dce01b8f6c1df5507905fb318f5ca7d8a2c (patch) | |
tree | 50c355e8f5774b2d345c930fe31cd6fc2abee28c | |
parent | 8036f23c96d6f0dea1a25fde68fbb18ac4793b9f (diff) | |
download | colm-5b919dce01b8f6c1df5507905fb318f5ca7d8a2c.tar.gz |
We cannot always clear the rcode at the end of a full commit. We have to
compute when it is safe to do so.
Need to set the fsmRun->parser field before invoking a full parse undo.
-rw-r--r-- | colm/bytecode.cpp | 4 | ||||
-rw-r--r-- | colm/fsmrun.cpp | 7 | ||||
-rw-r--r-- | colm/pdarun.cpp | 6 |
3 files changed, 11 insertions, 6 deletions
diff --git a/colm/bytecode.cpp b/colm/bytecode.cpp index 8c25079d..d418aedc 100644 --- a/colm/bytecode.cpp +++ b/colm/bytecode.cpp @@ -1963,7 +1963,7 @@ again: default: { cerr << "UNKNOWN INSTRUCTION: " << (ulong)instr[-1] << " -- reverse code downref" << endl; - exit(1); + assert(false); break; } } @@ -4084,7 +4084,7 @@ again: default: { cerr << "UNKNOWN INSTRUCTION: " << (ulong)instr[-1] << " -- something is wrong" << endl; - exit(1); + assert(false); break; } } diff --git a/colm/fsmrun.cpp b/colm/fsmrun.cpp index 8eb2101b..d4726d87 100644 --- a/colm/fsmrun.cpp +++ b/colm/fsmrun.cpp @@ -82,8 +82,6 @@ void FsmRun::streamPush( const char *data, long length ) assert(false); } else { - cerr << "case 3" << endl; - /* Send back the second half of the current run buffer. */ RunBuf *dup = new RunBuf; memcpy( dup, runBuf, sizeof(RunBuf) ); @@ -717,8 +715,13 @@ long PdaRun::undoParse( Tree *tree, CodeVect *rev ) numRetry += 1; allReverseCode.transfer( *rev ); + PdaRun *prevParser = fsmRun->parser; + fsmRun->parser = this; + parseToken( 0 ); + fsmRun->parser = prevParser; + assert( stackTop->next == 0 ); prg->algPool.free( stackTop->tree->alg ); diff --git a/colm/pdarun.cpp b/colm/pdarun.cpp index 04e2adef..3980c6b9 100644 --- a/colm/pdarun.cpp +++ b/colm/pdarun.cpp @@ -260,8 +260,10 @@ void PdaRun::commit() * was when we started. */ assert( sp == root ); - /* Now clear all the rcode. */ - rcode_downref_all( root, prg, &allReverseCode ); + /* We cannot always clear all the rcode here. We may need to backup over + * the parse statement. In the future we should compute when it is safe to + * do so, but for now just leave everything until later. */ + //rcode_downref_all( root, prg, &allReverseCode ); } |