diff options
author | Adrian Thurston <thurston@colm.net> | 2018-06-25 18:14:28 +0700 |
---|---|---|
committer | Adrian Thurston <thurston@colm.net> | 2018-06-25 18:14:28 +0700 |
commit | d1829badfa217ab54a5a8f96eb4af1f1d382ea55 (patch) | |
tree | 65a5cebfc7d831ecc9659e73615d027e4407cf38 /src/input.c | |
parent | 91b3a371209af25225b715778accec0079126efe (diff) | |
download | colm-d1829badfa217ab54a5a8f96eb4af1f1d382ea55.tar.gz |
some simplification of tree functions
Diffstat (limited to 'src/input.c')
-rw-r--r-- | src/input.c | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/src/input.c b/src/input.c index e1ec273b..e56a4b8c 100644 --- a/src/input.c +++ b/src/input.c @@ -886,24 +886,17 @@ static tree_t *stream_consume_tree( struct colm_program *prg, struct stream_impl static void stream_undo_consume_tree( struct colm_program *prg, struct stream_impl_seq *is, tree_t *tree, int ignore ) { - /* Create a new buffer for the data. This is the easy implementation. - * Something better is needed here. It puts a max on the amount of - * data that can be pushed back to the inputStream. */ - struct seq_buf *b = input_stream_pop_stash( is ); input_stream_seq_prepend( is, b ); + assert( b->tree == tree ); } static struct LangEl *stream_consume_lang_el( struct colm_program *prg, struct stream_impl_seq *is, long *bind_id, char **data, long *length ) { - if ( is_source_stream( is ) ) { - struct stream_impl *si = is->queue->si; - return si->funcs->consume_lang_el( prg, si, bind_id, data, length ); - } - else { - assert( false ); - } + assert( is_source_stream( is ) ); + struct stream_impl *si = is->queue->si; + return si->funcs->consume_lang_el( prg, si, bind_id, data, length ); } static void stream_undo_consume_lang_el( struct colm_program *prg, struct stream_impl_seq *is ) @@ -1036,24 +1029,16 @@ static int stream_data_undo_prepend_data( struct colm_program *prg, struct strea static tree_t *stream_undo_prepend_tree( struct colm_program *prg, struct stream_impl_seq *is ) { - while ( is->queue != 0 && ( is->queue->type == SEQ_BUF_SOURCE_TYPE ) ) - { - struct seq_buf *seq_buf = input_stream_seq_pop_head( is ); - free( seq_buf ); - } + debug( prg, REALM_INPUT, "undo prepend tree\n" ); - if ( is->queue != 0 && (is->queue->type == SEQ_BUF_TOKEN_TYPE || - is->queue->type == SEQ_BUF_IGNORE_TYPE) ) - { - struct seq_buf *seq_buf = input_stream_seq_pop_head( is ); + assert( is->queue != 0 && ( is->queue->type == SEQ_BUF_TOKEN_TYPE || + is->queue->type == SEQ_BUF_IGNORE_TYPE ) ); - /* FIXME: using runbufs here for this is a poor use of memory. */ - tree_t *tree = seq_buf->tree; - free(seq_buf); - return tree; - } + struct seq_buf *seq_buf = input_stream_seq_pop_head( is ); - return 0; + tree_t *tree = seq_buf->tree; + free(seq_buf); + return tree; } static tree_t *stream_undo_append_data( struct colm_program *prg, struct stream_impl_seq *is, int length ) |