diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ctinput.cc | 46 | ||||
-rw-r--r-- | src/input.h | 92 |
2 files changed, 69 insertions, 69 deletions
diff --git a/src/ctinput.cc b/src/ctinput.cc index 906ef857..c0aefd4b 100644 --- a/src/ctinput.cc +++ b/src/ctinput.cc @@ -157,27 +157,6 @@ void inputStreamPatternBackup( struct stream_impl *ss ) ss->pat_item = ss->pat_item->prev; } -void inputStreamPatternPushBackBuf( struct stream_impl *ss, struct run_buf *runBuf ) -{ - char *data = runBuf->data + runBuf->offset; - long length = runBuf->length; - - if ( length == 0 ) - return; - - /* While pushing back past the current pattern item start. */ - while ( length > ss->offset ) { - length -= ss->offset; - if ( ss->offset > 0 ) - assert( memcmp( ss->pat_item->data, data-length, ss->offset ) == 0 ); - inputStreamPatternBackup( ss ); - ss->offset = ss->pat_item->data.length(); - } - - ss->offset -= length; - assert( memcmp( &ss->pat_item->data[ss->offset], data, length ) == 0 ); -} - void inputStreamPatternUndoConsumeLangEl( struct stream_impl *ss ) { inputStreamPatternBackup( ss ); @@ -371,31 +350,6 @@ void inputStreamConsBackup( struct stream_impl *ss ) ss->cons_item = ss->cons_item->prev; } -void inputStreamConsPushBackBuf( struct stream_impl *ss, struct run_buf *runBuf ) -{ - char *data = runBuf->data + runBuf->offset; - long length = runBuf->length; - - //cerr << "push back data: "; - //cerr.write( data, length ); - //cerr << endl; - - if ( length == 0 ) - return; - - /* While pushing back past the current pattern item start. */ - while ( length > ss->offset ) { - length -= ss->offset; - if ( ss->offset > 0 ) - assert( memcmp( ss->cons_item->data, data-length, ss->offset ) == 0 ); - inputStreamConsBackup( ss ); - ss->offset = ss->cons_item->data.length(); - } - - ss->offset -= length; - assert( memcmp( &ss->cons_item->data[ss->offset], data, length ) == 0 ); -} - void inputStreamConsUndoConsumeLangEl( struct stream_impl *ss ) { inputStreamConsBackup( ss ); diff --git a/src/input.h b/src/input.h index 0226b508..efd47ecc 100644 --- a/src/input.h +++ b/src/input.h @@ -79,48 +79,94 @@ struct run_buf struct run_buf *new_run_buf( int sz ); +typedef int (*get_parse_block_t)( struct stream_impl *si, int skip, char **pdp, int *copied ); + +/* Probably this should be replaced with get_parse_block calls. */ +typedef int (*get_data_t)( struct stream_impl *si, char *dest, int length ); + +/* Consuming data. */ +typedef int (*consume_data_t)( struct colm_program *prg, struct colm_tree **sp, + struct stream_impl *si, int length, struct colm_location *loc ); +typedef int (*undo_consume_data_t)( struct stream_impl *si, const char *data, int length ); + +/* Consuming trees. */ +typedef struct colm_tree *(*consume_tree_t)( struct stream_impl *si ); +typedef void (*undo_consume_tree_t)( struct stream_impl *si, + struct colm_tree *tree, int ignore ); + +/* Language elments (compile-time). */ +typedef struct LangEl *(*consume_lang_el_t)( struct stream_impl *si, + long *bind_id, char **data, long *length ); +typedef void (*undo_consume_lang_el_t)( struct stream_impl *si ); + +/* Private implmentation for some shared get data functions. */ +typedef int (*get_data_source_t)( struct stream_impl *si, char *dest, int length ); + +typedef void (*set_eof_t)( struct stream_impl *si ); +typedef void (*unset_eof_t)( struct stream_impl *si ); + +/* Prepending to a stream. */ +typedef void (*prepend_data_t)( struct stream_impl *si, const char *data, long len ); +typedef void (*prepend_tree_t)( struct stream_impl *si, struct colm_tree *tree, int ignore ); +typedef void (*prepend_stream_t)( struct stream_impl *si, struct colm_stream *stream ); + +/* Undoing prepend. */ +typedef int (*undo_prepend_data_t)( struct stream_impl *si, int length ); +typedef struct colm_tree *(*undo_prepend_tree_t)( struct stream_impl *si ); +typedef struct colm_tree *(*undo_prepend_stream_t)( struct stream_impl *si ); + +/* Appending to a stream. */ +typedef void (*append_data_t)( struct stream_impl *si, const char *data, long len ); +typedef void (*append_tree_t)( struct stream_impl *si, struct colm_tree *tree ); +typedef void (*append_stream_t)( struct stream_impl *si, struct colm_stream *stream ); + +/* Undoing append. */ +typedef struct colm_tree *(*undo_append_data_t)( struct stream_impl *si, int length ); +typedef struct colm_tree *(*undo_append_tree_t)( struct stream_impl *si ); +typedef struct colm_tree *(*undo_append_stream_t)( struct stream_impl *si ); + struct stream_funcs { - int (*get_parse_block)( struct stream_impl *ss, int skip, char **pdp, int *copied ); + int (*get_parse_block)( struct stream_impl *si, int skip, char **pdp, int *copied ); - int (*get_data)( struct stream_impl *ss, char *dest, int length ); + int (*get_data)( struct stream_impl *si, char *dest, int length ); int (*consume_data)( struct colm_program *prg, struct colm_tree **sp, - struct stream_impl *ss, int length, struct colm_location *loc ); - int (*undo_consume_data)( struct stream_impl *ss, const char *data, int length ); + struct stream_impl *si, int length, struct colm_location *loc ); + int (*undo_consume_data)( struct stream_impl *si, const char *data, int length ); - struct colm_tree *(*consume_tree)( struct stream_impl *ss ); - void (*undo_consume_tree)( struct stream_impl *ss, + struct colm_tree *(*consume_tree)( struct stream_impl *si ); + void (*undo_consume_tree)( struct stream_impl *si, struct colm_tree *tree, int ignore ); /* Language elments (compile-time). */ - struct LangEl *(*consume_lang_el)( struct stream_impl *ss, + struct LangEl *(*consume_lang_el)( struct stream_impl *si, long *bind_id, char **data, long *length ); - void (*undo_consume_lang_el)( struct stream_impl *ss ); + void (*undo_consume_lang_el)( struct stream_impl *si ); /* Private implmentation for some shared get data functions. */ - int (*get_data_source)( struct stream_impl *ss, char *dest, int length ); + int (*get_data_source)( struct stream_impl *si, char *dest, int length ); - void (*set_eof)( struct stream_impl *is ); - void (*unset_eof)( struct stream_impl *is ); + void (*set_eof)( struct stream_impl *si ); + void (*unset_eof)( struct stream_impl *si ); /* Prepending to a stream. */ - void (*prepend_data)( struct stream_impl *in, const char *data, long len ); - void (*prepend_tree)( struct stream_impl *is, struct colm_tree *tree, int ignore ); - void (*prepend_stream)( struct stream_impl *in, struct colm_stream *stream ); + void (*prepend_data)( struct stream_impl *si, const char *data, long len ); + void (*prepend_tree)( struct stream_impl *si, struct colm_tree *tree, int ignore ); + void (*prepend_stream)( struct stream_impl *si, struct colm_stream *stream ); - int (*undo_prepend_data)( struct stream_impl *is, int length ); - struct colm_tree *(*undo_prepend_tree)( struct stream_impl *is ); - struct colm_tree *(*undo_prepend_stream)( struct stream_impl *in ); + int (*undo_prepend_data)( struct stream_impl *si, int length ); + struct colm_tree *(*undo_prepend_tree)( struct stream_impl *si ); + struct colm_tree *(*undo_prepend_stream)( struct stream_impl *si ); /* Appending to a stream. */ - void (*append_data)( struct stream_impl *in, const char *data, long len ); - void (*append_tree)( struct stream_impl *in, struct colm_tree *tree ); - void (*append_stream)( struct stream_impl *in, struct colm_stream *stream ); + void (*append_data)( struct stream_impl *si, const char *data, long len ); + void (*append_tree)( struct stream_impl *si, struct colm_tree *tree ); + void (*append_stream)( struct stream_impl *si, struct colm_stream *stream ); - struct colm_tree *(*undo_append_data)( struct stream_impl *in, int length ); - struct colm_tree *(*undo_append_tree)( struct stream_impl *in ); - struct colm_tree *(*undo_append_stream)( struct stream_impl *in ); + struct colm_tree *(*undo_append_data)( struct stream_impl *si, int length ); + struct colm_tree *(*undo_append_tree)( struct stream_impl *si ); + struct colm_tree *(*undo_append_stream)( struct stream_impl *si ); }; /* List of source streams. Enables streams to be pushed/popped. */ |