diff options
author | Adrian Thurston <thurston@complang.org> | 2011-12-31 21:27:09 +0000 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2011-12-31 21:27:09 +0000 |
commit | f1cbc3f1b5d5f3fbf2518442c17fb2d6bbc237bb (patch) | |
tree | 0b8dd84c79f455e480509d83a06e59c7f78026af | |
parent | 863bead07680b832a07221f08291f19266a2397f (diff) | |
download | colm-f1cbc3f1b5d5f3fbf2518442c17fb2d6bbc237bb.tar.gz |
Don't use the source stream for prepending data. Still some inconsistencies
present. refs #341.
-rw-r--r-- | colm/bytecode.c | 13 | ||||
-rw-r--r-- | colm/input.c | 20 | ||||
-rw-r--r-- | colm/pdarun.c | 14 |
3 files changed, 19 insertions, 28 deletions
diff --git a/colm/bytecode.c b/colm/bytecode.c index 8de480f0..80f0def9 100644 --- a/colm/bytecode.c +++ b/colm/bytecode.c @@ -362,7 +362,7 @@ void undoPull( Program *prg, FsmRun *fsmRun, InputStream *in, Tree *str ) undoStreamPull( fsmRun, in, data, length ); } -Word streamPush( Program *prg, Tree **sp, FsmRun *fsmRun, InputStream *in, Tree *tree, int ignore ) +long streamPush( Program *prg, Tree **sp, FsmRun *fsmRun, InputStream *in, Tree *tree, int ignore ) { if ( tree->id == LEL_ID_STR ) { /* This should become a compile error. If it's text, it's up to the @@ -389,7 +389,7 @@ Word streamPush( Program *prg, Tree **sp, FsmRun *fsmRun, InputStream *in, Tree tree->flags |= AF_ARTIFICIAL; treeUpref( tree ); streamPushTree( fsmRun, in, tree, ignore ); - return 0; + return -1; } } @@ -485,7 +485,6 @@ Tree *constructArgv( Program *prg, int argc, const char **argv ) return list; } - /* * Execution environment */ @@ -2580,7 +2579,7 @@ again: Tree *accum = vm_pop(); Tree *tree = vm_pop(); - Word len = streamPush( prg, sp, ((Accum*)accum)->fsmRun, ((Accum*)accum)->accumStream->in, tree, false ); + int len = streamPush( prg, sp, ((Accum*)accum)->fsmRun, ((Accum*)accum)->accumStream->in, tree, false ); vm_push( 0 ); /* Single unit. */ @@ -2598,7 +2597,7 @@ again: Tree *accum = vm_pop(); Tree *tree = vm_pop(); - Word len = streamPush( prg, sp, ((Accum*)accum)->fsmRun, ((Accum*)accum)->accumStream->in, tree, true ); + long len = streamPush( prg, sp, ((Accum*)accum)->fsmRun, ((Accum*)accum)->accumStream->in, tree, true ); vm_push( 0 ); /* Single unit. */ @@ -2665,7 +2664,7 @@ again: AccumStream *accumStream = (AccumStream*)vm_pop(); Tree *tree = vm_pop(); - Word len = streamPush( prg, sp, 0, accumStream->in, tree, false ); + long len = streamPush( prg, sp, 0, accumStream->in, tree, false ); vm_push( 0 ); /* Single unit. */ @@ -2683,7 +2682,7 @@ again: AccumStream *accumStream = (AccumStream*)vm_pop(); Tree *tree = vm_pop(); - Word len = streamPush( prg, sp, 0, accumStream->in, tree, true ); + long len = streamPush( prg, sp, 0, accumStream->in, tree, true ); vm_push( 0 ); /* Single unit. */ diff --git a/colm/input.c b/colm/input.c index 250c7d7d..73ae6bc7 100644 --- a/colm/input.c +++ b/colm/input.c @@ -776,19 +776,13 @@ void prependData( InputStream *is, const char *data, long length ) Tree *undoPrependData( InputStream *is, int length ) { - if ( isSourceStream( is ) ) { - Stream *stream = (Stream*)is->queue->tree; - return stream->in->funcs->undoPrependData( stream->in, length ); - } - else { +// if ( isSourceStream( is ) ) { +// Stream *stream = (Stream*)is->queue->tree; +// return stream->in->funcs->undoPrependData( stream->in, length ); +// } +// else { if ( is->queue->type == RunBufDataType ) { - char tmp[length]; - int have = 0; - while ( have < length ) { - int res = 0; - getData( 0, is, 0, tmp, length-have, &res ); - have += res; - } + consumeData( is, length ); return 0; } else { @@ -798,7 +792,7 @@ Tree *undoPrependData( InputStream *is, int length ) free(rb); return tree; } - } +// } } void appendData( InputStream *is, const char *data, long len ) diff --git a/colm/pdarun.c b/colm/pdarun.c index 9a2c8053..b49aba8e 100644 --- a/colm/pdarun.c +++ b/colm/pdarun.c @@ -222,20 +222,18 @@ void streamPushTree( FsmRun *fsmRun, InputStream *inputStream, Tree *tree, int i void undoStreamPush( Program *prg, Tree **sp, FsmRun *fsmRun, InputStream *inputStream, long length ) { -// sendBackBuffered( fsmRun, inputStream ); - Tree *tree = undoPrependData( inputStream, length ); - if ( tree != 0 ) - treeDownref( prg, sp, tree ); + if ( length < 0 ) + consumeTree( inputStream ); + else + consumeData( inputStream, length ); } void undoStreamAppend( Program *prg, Tree **sp, FsmRun *fsmRun, InputStream *inputStream, Tree *input, long length ) { - if ( input->id == LEL_ID_STREAM ) { + if ( input->id == LEL_ID_STREAM ) undoAppendStream( inputStream ); - } - else { + else undoAppendData( inputStream, length ); - } } /* Should only be sending back whole tokens/ignores, therefore the send back |