summaryrefslogtreecommitdiff
path: root/src/input.c
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2018-06-18 14:25:14 +0700
committerAdrian Thurston <thurston@colm.net>2018-06-18 14:25:14 +0700
commite706bc4c2a396c3a60658072412e26d9bee83fca (patch)
tree1dcb55ec10189f69c1575e2a806c0cfef7660dcc /src/input.c
parent922038be0f1924e7fe6a52a843d090c47bf7d29c (diff)
downloadcolm-e706bc4c2a396c3a60658072412e26d9bee83fca.tar.gz
added print_tree to stream funcs
Selects between file and collect. Will want to also ensure only called on a "data" stream_impl.
Diffstat (limited to 'src/input.c')
-rw-r--r--src/input.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/input.c b/src/input.c
index fda79789..6474ba19 100644
--- a/src/input.c
+++ b/src/input.c
@@ -337,6 +337,15 @@ static void data_flush_stream( struct stream_impl_data *si )
fflush( si->file );
}
+static void data_print_tree( struct colm_program *prg, tree_t **sp,
+ struct stream_impl_data *si, tree_t *tree, int trim )
+{
+ if ( si->file != 0 )
+ colm_print_tree_file( prg, sp, (struct stream_impl*)si, tree, false );
+ else if ( si->collect != 0 )
+ colm_print_tree_collect( prg, sp, si->collect, tree, false );
+}
+
static int data_get_parse_block( struct stream_impl_data *ss, int skip, char **pdp, int *copied )
{
int ret = 0;
@@ -622,6 +631,14 @@ static void stream_flush_stream( struct stream_impl_seq *si )
{
}
+static void stream_print_tree( struct colm_program *prg, tree_t **sp,
+ struct stream_impl_seq *si, tree_t *tree, int trim )
+{
+ if ( si->file != 0 )
+ colm_print_tree_file( prg, sp, (struct stream_impl*)si, tree, false );
+ else if ( si->collect != 0 )
+ colm_print_tree_collect( prg, sp, si->collect, tree, false );
+}
static int stream_get_parse_block( struct stream_impl_seq *is, int skip, char **pdp, int *copied )
{
@@ -1190,6 +1207,7 @@ struct stream_funcs_seq stream_funcs =
.destructor = &stream_destructor,
.get_collect = &stream_get_collect,
.flush_stream = &stream_flush_stream,
+ .print_tree = &stream_print_tree,
};
struct stream_funcs_data file_funcs =
@@ -1202,6 +1220,7 @@ struct stream_funcs_data file_funcs =
.destructor = &data_destructor,
.get_collect = &data_get_collect,
.flush_stream = &data_flush_stream,
+ .print_tree = &data_print_tree,
};
struct stream_funcs_data text_funcs =
@@ -1214,6 +1233,7 @@ struct stream_funcs_data text_funcs =
.destructor = &data_destructor,
.get_collect = &data_get_collect,
.flush_stream = &data_flush_stream,
+ .print_tree = &data_print_tree,
};
static struct stream_impl *colm_impl_new_file( char *name, FILE *file )