diff options
-rw-r--r-- | src/colm.h | 1 | ||||
-rw-r--r-- | src/program.c | 6 | ||||
-rw-r--r-- | src/program.h | 1 | ||||
-rw-r--r-- | src/reduce.cc | 10 |
4 files changed, 14 insertions, 4 deletions
@@ -131,6 +131,7 @@ int colm_delete_program( struct colm_program *prg ); /* Set the pointer to the reduce struct used. */ void *colm_get_reduce_ctx( struct colm_program *prg ); void colm_set_reduce_ctx( struct colm_program *prg, void *ctx ); +void colm_set_reduce_clean( struct colm_program *prg, unsigned char reduce_clean ); const char *colm_error( struct colm_program *prg, int *length ); diff --git a/src/program.c b/src/program.c index 5555207a..0675c239 100644 --- a/src/program.c +++ b/src/program.c @@ -170,6 +170,11 @@ void colm_set_debug( program_t *prg, long active_realm ) prg->active_realm = active_realm; } +void colm_set_reduce_clean( struct colm_program *prg, unsigned char reduce_clean ) +{ + prg->reduce_clean = reduce_clean; +} + program_t *colm_new_program( struct colm_sections *rtd ) { program_t *prg = malloc(sizeof(program_t)); @@ -180,6 +185,7 @@ program_t *colm_new_program( struct colm_sections *rtd ) prg->rtd = rtd; prg->ctx_dep_parsing = 1; + prg->reduce_clean = 1; init_pool_alloc( &prg->kid_pool, sizeof(kid_t) ); init_pool_alloc( &prg->tree_pool, sizeof(tree_t) ); diff --git a/src/program.h b/src/program.h index 21e21d36..8ba716d4 100644 --- a/src/program.h +++ b/src/program.h @@ -136,6 +136,7 @@ struct colm_program const int *argl; unsigned char ctx_dep_parsing; + unsigned char reduce_clean; struct colm_sections *rtd; struct colm_struct *global; int induce_exit; diff --git a/src/reduce.cc b/src/reduce.cc index 98622326..a2db97f0 100644 --- a/src/reduce.cc +++ b/src/reduce.cc @@ -435,7 +435,7 @@ void Compiler::writeNeeds() "extern \"C\" int " << objectName << "_reducer_need_tok( program_t *prg, " "struct pda_run *pda_run, int id )\n" "{\n" - " if ( pda_run->reducer > 0 ) {\n" + " if ( prg->reduce_clean && pda_run->reducer > 0 ) {\n" /* Note we are forcing the reducer need for data. Enabling requires finding * a solution for backtracking push. */ " return COLM_RN_DATA | ri[pda_run->reducer].need_data[id] | \n" @@ -700,9 +700,11 @@ void Compiler::writeParseReduce( Reduction *reduction ) " }\n" "\n" " commit_clear_parse_tree( prg, sp, pda_run, lel->child );\n" - " commit_clear_kid_list( prg, sp, kid->tree->child );\n" - " kid->tree->child = 0;\n" - " kid->tree->flags &= ~( AF_LEFT_IGNORE | AF_RIGHT_IGNORE );\n" + " if ( prg->reduce_clean ) {\n" + " commit_clear_kid_list( prg, sp, kid->tree->child );\n" + " kid->tree->child = 0;\n" + " kid->tree->flags &= ~( AF_LEFT_IGNORE | AF_RIGHT_IGNORE );\n" + " }\n" " lel->child = 0;\n" "\n" " if ( sp != root )\n" |