diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bytecode.c | 12 | ||||
-rw-r--r-- | src/bytecode.h | 2 | ||||
-rw-r--r-- | src/pdarun.c | 21 | ||||
-rw-r--r-- | src/pdarun.h | 3 | ||||
-rw-r--r-- | src/synthesis.cc | 4 |
5 files changed, 28 insertions, 14 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index ed2a464b..124d8d61 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -2748,7 +2748,6 @@ again: break; } - case IN_PARSE_FINISH_W: { half_t stop_id; read_half( stop_id ); @@ -2817,6 +2816,17 @@ again: break; } + case IN_REDUCE_COMMIT: { + stream_t *stream = vm_pop_stream(); + vm_push_stream( stream ); + + debug( prg, REALM_BYTECODE, "IN_REDUCE_COMMIT\n" ); + + colm_parse_reduce_commit( prg, sp, stream->parser->pda_run ); + break; + } + + case IN_INPUT_PULL_WV: { debug( prg, REALM_BYTECODE, "IN_INPUT_PULL_WV\n" ); diff --git a/src/bytecode.h b/src/bytecode.h index fb866c1a..d8fb6fe0 100644 --- a/src/bytecode.h +++ b/src/bytecode.h @@ -287,6 +287,8 @@ typedef unsigned char uchar; #define IN_PARSE_FINISH_BKT 0xaf #define IN_PARSE_FINISH_EXIT_BKT 0xb0 +#define IN_REDUCE_COMMIT 0xa5 + #define IN_PCR_CALL 0xb1 #define IN_PCR_RET 0xb2 #define IN_PCR_END_DECK 0xb3 diff --git a/src/pdarun.c b/src/pdarun.c index 79b40528..227dd3bd 100644 --- a/src/pdarun.c +++ b/src/pdarun.c @@ -2214,8 +2214,6 @@ long colm_parse_frag( program_t *prg, tree_t **sp, struct pda_run *pda_run, case PCR_START: if ( ! pda_run->parse_error ) { - //pda_run->stop_target = stop_id; - long pcr = colm_parse_loop( prg, sp, pda_run, stream_to_impl( input ), entry ); @@ -2270,17 +2268,6 @@ long colm_parse_finish( program_t *prg, tree_t **sp, } } - /* Flush out anything not committed. */ - if ( pda_run->reducer ) - commit_reduce( prg, sp, pda_run ); - - /* What to do here. - * if ( pda_run->fail_parsing ) - * goto fail; */ - - //if ( !revert_on ) - // colm_rcode_downref_all( prg, sp, &pda_run->reverse_code ); - /* COROUTINE */ case PCR_DONE: break; } @@ -2288,6 +2275,14 @@ long colm_parse_finish( program_t *prg, tree_t **sp, return PCR_DONE; } +void colm_parse_reduce_commit( program_t *prg, tree_t **sp, + struct pda_run *pda_run ) +{ + /* Flush out anything not committed. */ + if ( pda_run->reducer ) + commit_reduce( prg, sp, pda_run ); +} + long colm_parse_undo_frag( program_t *prg, tree_t **sp, struct pda_run *pda_run, stream_t *input, long steps, long entry ) { diff --git a/src/pdarun.h b/src/pdarun.h index 49c95f00..fa73af2c 100644 --- a/src/pdarun.h +++ b/src/pdarun.h @@ -470,6 +470,9 @@ void commit_reduce( program_t *prg, tree_t **root, tree_t *get_parsed_root( struct pda_run *pda_run, int stop ); +void colm_parse_reduce_commit( program_t *prg, tree_t **sp, + struct pda_run *pda_run ); + #ifdef __cplusplus } #endif diff --git a/src/synthesis.cc b/src/synthesis.cc index 4df21af2..8a5fb218 100644 --- a/src/synthesis.cc +++ b/src/synthesis.cc @@ -1616,6 +1616,10 @@ UniqueType *LangTerm::evaluateParse( Compiler *pd, CodeVect &code, parseFinish( pd, code, stopId ); } + if ( parserText->reduce ) { + code.append( IN_REDUCE_COMMIT ); + } + /* Pull out the error and save it off. */ code.append( IN_DUP_VAL ); code.append( IN_GET_STREAM_MEM_R ); |