diff options
-rw-r--r-- | src/bytecode.c | 22 | ||||
-rw-r--r-- | src/print.c | 100 | ||||
-rw-r--r-- | src/tree.h | 12 |
3 files changed, 65 insertions, 69 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index c26476e2..ee44b6ef 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -139,9 +139,9 @@ static head_t *tree_to_str( program_t *prg, tree_t **sp, tree_t *tree, int trim, init_str_collect( &collect ); if ( attrs ) - print_tree_collect_a( prg, sp, &collect, tree, trim ); + colm_print_tree_collect_a( prg, sp, &collect, tree, trim ); else - print_tree_collect( prg, sp, &collect, tree, trim ); + colm_print_tree_collect( prg, sp, &collect, tree, trim ); /* Set up the input stream. */ head_t *ret = string_alloc_full( prg, collect.data, collect.length ); @@ -160,7 +160,7 @@ static word_t stream_append_tree( program_t *prg, tree_t **sp, stream_t *dest, t /* Collect the tree data. */ StrCollect collect; init_str_collect( &collect ); - print_tree_collect( prg, sp, &collect, input, false ); + colm_print_tree_collect( prg, sp, &collect, input, false ); /* Load it into the input. */ impl->funcs->append_data( impl, collect.data, collect.length ); @@ -235,7 +235,7 @@ static long stream_push( program_t *prg, tree_t **sp, struct stream_impl *in, tr /* Collect the tree data. */ StrCollect collect; init_str_collect( &collect ); - print_tree_collect( prg, sp, &collect, tree, false ); + colm_print_tree_collect( prg, sp, &collect, tree, false ); colm_stream_push_text( in, collect.data, collect.length ); long length = collect.length; @@ -674,7 +674,7 @@ again: arg[i] = vm_pop_tree(); for ( i = 0; i < n; i++ ) - print_tree_file( prg, sp, prg->stdout_val->impl, arg[i], false ); + colm_print_tree_file( prg, sp, prg->stdout_val->impl, arg[i], false ); for ( i = 0; i < n; i++ ) colm_tree_downref( prg, sp, arg[i] ); @@ -693,9 +693,9 @@ again: for ( i = 0; i < n; i++ ) { if ( si->file != 0 ) - print_tree_file( prg, sp, si, arg[i], false ); + colm_print_tree_file( prg, sp, si, arg[i], false ); else if ( si->collect != 0 ) - print_tree_collect( prg, sp, si->collect, arg[i], false ); + colm_print_tree_collect( prg, sp, si->collect, arg[i], false ); } for ( i = 0; i < n; i++ ) @@ -715,7 +715,7 @@ again: arg[i] = vm_pop_tree(); for ( i = 0; i < n; i++ ) - print_xml_stdout( prg, sp, prg->stdout_val->impl, arg[i], true, true ); + colm_print_xml_stdout( prg, sp, prg->stdout_val->impl, arg[i], true, true ); for ( i = 0; i < n; i++ ) colm_tree_downref( prg, sp, arg[i] ); @@ -733,7 +733,7 @@ again: arg[i] = vm_pop_tree(); for ( i = 0; i < n; i++ ) - print_xml_stdout( prg, sp, prg->stdout_val->impl, arg[i], false, true ); + colm_print_xml_stdout( prg, sp, prg->stdout_val->impl, arg[i], false, true ); for ( i = 0; i < n; i++ ) colm_tree_downref( prg, sp, arg[i] ); @@ -752,9 +752,9 @@ again: for ( i = 0; i < n; i++ ) { if ( si->file != 0 ) - dump_tree_file( prg, sp, si, arg[i], false ); + colm_postfix_tree_file( prg, sp, si, arg[i], false ); else if ( si->collect != 0 ) - dump_tree_collect( prg, sp, si->collect, arg[i], false ); + colm_postfix_tree_collect( prg, sp, si->collect, arg[i], false ); } for ( i = 0; i < n; i++ ) diff --git a/src/print.c b/src/print.c index b59a33a4..380a2160 100644 --- a/src/print.c +++ b/src/print.c @@ -434,6 +434,11 @@ void colm_print_tree_args( program_t *prg, tree_t **sp, } } +void colm_print_null( program_t *prg, tree_t **sp, + struct colm_print_args *args, kid_t *parent, kid_t *kid ) +{ +} + void colm_print_term_tree( program_t *prg, tree_t **sp, struct colm_print_args *print_args, kid_t *kid ) { @@ -479,13 +484,40 @@ void colm_print_term_tree( program_t *prg, tree_t **sp, impl->level -= 1; } +void colm_print_tree_collect( program_t *prg, tree_t **sp, + StrCollect *collect, tree_t *tree, int trim ) +{ + struct colm_print_args print_args = { + collect, true, false, trim, &append_collect, + &colm_print_null, &colm_print_term_tree, &colm_print_null + }; -void colm_print_null( program_t *prg, tree_t **sp, - struct colm_print_args *args, kid_t *parent, kid_t *kid ) + colm_print_tree_args( prg, sp, &print_args, tree ); +} + +void colm_print_tree_collect_a( program_t *prg, tree_t **sp, + StrCollect *collect, tree_t *tree, int trim ) { + struct colm_print_args print_args = { + collect, true, true, trim, &append_collect, + &colm_print_null, &colm_print_term_tree, &colm_print_null + }; + + colm_print_tree_args( prg, sp, &print_args, tree ); } -void open_tree_xml( program_t *prg, tree_t **sp, struct colm_print_args *args, +void colm_print_tree_file( program_t *prg, tree_t **sp, struct stream_impl *impl, + tree_t *tree, int trim ) +{ + struct colm_print_args print_args = { + impl, true, false, trim, &append_file, + &colm_print_null, &colm_print_term_tree, &colm_print_null + }; + + colm_print_tree_args( prg, sp, &print_args, tree ); +} + +static void xml_open( program_t *prg, tree_t **sp, struct colm_print_args *args, kid_t *parent, kid_t *kid ) { /* Skip the terminal that is for forcing trailing ignores out. */ @@ -508,7 +540,7 @@ void open_tree_xml( program_t *prg, tree_t **sp, struct colm_print_args *args, args->out( args, ">", 1 ); } -void print_term_xml( program_t *prg, tree_t **sp, +static void xml_term( program_t *prg, tree_t **sp, struct colm_print_args *print_args, kid_t *kid ) { //kid_t *child; @@ -534,8 +566,7 @@ void print_term_xml( program_t *prg, tree_t **sp, } } - -void close_tree_xml( program_t *prg, tree_t **sp, +static void xml_close( program_t *prg, tree_t **sp, struct colm_print_args *args, kid_t *parent, kid_t *kid ) { /* Skip the terminal that is for forcing trailing ignores out. */ @@ -558,56 +589,23 @@ void close_tree_xml( program_t *prg, tree_t **sp, args->out( args, ">", 1 ); } -void print_tree_collect( program_t *prg, tree_t **sp, - StrCollect *collect, tree_t *tree, int trim ) -{ - struct colm_print_args print_args = { - collect, true, false, trim, &append_collect, - &colm_print_null, &colm_print_term_tree, &colm_print_null - }; - - colm_print_tree_args( prg, sp, &print_args, tree ); -} - -void print_tree_collect_a( program_t *prg, tree_t **sp, - StrCollect *collect, tree_t *tree, int trim ) -{ - struct colm_print_args print_args = { - collect, true, true, trim, &append_collect, - &colm_print_null, &colm_print_term_tree, &colm_print_null - }; - - colm_print_tree_args( prg, sp, &print_args, tree ); -} - -void print_tree_file( program_t *prg, tree_t **sp, struct stream_impl *impl, - tree_t *tree, int trim ) -{ - struct colm_print_args print_args = { - impl, true, false, trim, &append_file, - &colm_print_null, &colm_print_term_tree, &colm_print_null - }; - - colm_print_tree_args( prg, sp, &print_args, tree ); -} - -void print_xml_stdout( program_t *prg, tree_t **sp, +void colm_print_xml_stdout( program_t *prg, tree_t **sp, struct stream_impl *impl, tree_t *tree, int comm_attr, int trim ) { struct colm_print_args print_args = { impl, comm_attr, comm_attr, trim, &append_file, - &open_tree_xml, &print_term_xml, &close_tree_xml }; + &xml_open, &xml_term, &xml_close }; colm_print_tree_args( prg, sp, &print_args, tree ); } -void open_tree_dump( program_t *prg, tree_t **sp, struct colm_print_args *args, +static void postfix_open( program_t *prg, tree_t **sp, struct colm_print_args *args, kid_t *parent, kid_t *kid ) { } -void print_term_dump( program_t *prg, tree_t **sp, - struct colm_print_args *print_args, kid_t *kid ) +static void postfix_term( program_t *prg, tree_t **sp, + struct colm_print_args *print_args, kid_t *kid ) { //kid_t *child; @@ -636,8 +634,7 @@ void print_term_dump( program_t *prg, tree_t **sp, } } - -void close_tree_dump( program_t *prg, tree_t **sp, +static void postfix_close( program_t *prg, tree_t **sp, struct colm_print_args *args, kid_t *parent, kid_t *kid ) { /* Skip the terminal that is for forcing trailing ignores out. */ @@ -655,24 +652,23 @@ void close_tree_dump( program_t *prg, tree_t **sp, } } - -void dump_tree_collect( program_t *prg, tree_t **sp, +void colm_postfix_tree_collect( program_t *prg, tree_t **sp, StrCollect *collect, tree_t *tree, int trim ) { struct colm_print_args print_args = { - collect, true, false, false, &append_collect, - &open_tree_dump, &print_term_dump, &close_tree_dump + collect, true, false, false, &append_collect, + &postfix_open, &postfix_term, &postfix_close }; colm_print_tree_args( prg, sp, &print_args, tree ); } -void dump_tree_file( program_t *prg, tree_t **sp, struct stream_impl *impl, +void colm_postfix_tree_file( program_t *prg, tree_t **sp, struct stream_impl *impl, tree_t *tree, int trim ) { struct colm_print_args print_args = { impl, true, false, false, &append_file, - &open_tree_dump, &print_term_dump, &close_tree_dump + &postfix_open, &postfix_term, &postfix_close }; colm_print_tree_args( prg, sp, &print_args, tree ); @@ -300,20 +300,20 @@ void str_collect_append( StrCollect *collect, const char *data, long len ); void str_collect_clear( StrCollect *collect ); tree_t *tree_trim( struct colm_program *prg, tree_t **sp, tree_t *tree ); -void print_tree_collect( struct colm_program *prg, tree_t **sp, +void colm_print_tree_collect( struct colm_program *prg, tree_t **sp, StrCollect *collect, tree_t *tree, int trim ); -void print_tree_collect_a( struct colm_program *prg, tree_t **sp, +void colm_print_tree_collect_a( struct colm_program *prg, tree_t **sp, StrCollect *collect, tree_t *tree, int trim ); -void print_tree_file( struct colm_program *prg, tree_t **sp, +void colm_print_tree_file( struct colm_program *prg, tree_t **sp, struct stream_impl *impl, tree_t *tree, int trim ); -void print_xml_stdout( struct colm_program *prg, tree_t **sp, +void colm_print_xml_stdout( struct colm_program *prg, tree_t **sp, struct stream_impl *impl, tree_t *tree, int comm_attr, int trim ); -void dump_tree_collect( struct colm_program *prg, tree_t **sp, +void colm_postfix_tree_collect( struct colm_program *prg, tree_t **sp, StrCollect *collect, tree_t *tree, int trim ); -void dump_tree_file( struct colm_program *prg, tree_t **sp, +void colm_postfix_tree_file( struct colm_program *prg, tree_t **sp, struct stream_impl *impl, tree_t *tree, int trim ); /* |