diff options
author | Adrian Thurston <thurston@complang.org> | 2016-03-01 17:19:13 +0100 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2016-03-01 17:20:41 +0100 |
commit | f2299e2e4d15a33e9863040220fe14088dcc7320 (patch) | |
tree | 8119f4e7128308a2924a42a3ac8f86de7418233c | |
parent | 6dd6b970b79e89b165cfc86e30e127fecfe1212f (diff) | |
download | colm-f2299e2e4d15a33e9863040220fe14088dcc7320.tar.gz |
added a fail-parsing flag that allows immediate abort from reduction actions
This flag causes all alternate parsing paths to be aborted and pda_run to
immedately fail. Tested with reduction actions.
-rw-r--r-- | src/pdarun.c | 14 | ||||
-rw-r--r-- | src/pdarun.h | 3 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/pdarun.c b/src/pdarun.c index 682a0ed3..dcbab4cb 100644 --- a/src/pdarun.c +++ b/src/pdarun.c @@ -1513,6 +1513,10 @@ again: /* Not in a reverting context and the parser result is not used. */ if ( pda_run->reducer ) commit_reduce( prg, sp, pda_run ); + + if ( pda_run->fail_parsing ) + goto fail; + } /* @@ -2182,6 +2186,12 @@ skip_send: debug( prg, REALM_PARSE, "parsing stopped by a parse error\n" ); break; } + + /* Disregard any alternate parse paths, just go right to failure. */ + if ( pda_run->fail_parsing ) { + debug( prg, REALM_PARSE, "parsing failed by explicit request\n" ); + break; + } } /* COROUTINE */ @@ -2267,6 +2277,10 @@ long colm_parse_finish( tree_t **result, 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 ); diff --git a/src/pdarun.h b/src/pdarun.h index 9ea7a0ac..dfabfea5 100644 --- a/src/pdarun.h +++ b/src/pdarun.h @@ -363,6 +363,9 @@ struct pda_run struct pool_alloc *parse_tree_pool; struct pool_alloc local_pool; + + /* Disregard any alternate parse paths, just go right to failure. */ + int fail_parsing; }; void colm_pda_init( struct colm_program *prg, struct pda_run *pda_run, |