summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2016-03-23 15:23:07 +0100
committerAdrian Thurston <thurston@complang.org>2016-03-23 15:23:07 +0100
commit2afdfef96c9de759a24ba4cb56928c48e1d86bd3 (patch)
treeb00080639d90458badc067b1d37a6c3936070ca0 /src
parentb9d35edf909d3b68461e27a8985acb0df25d19b2 (diff)
downloadcolm-2afdfef96c9de759a24ba4cb56928c48e1d86bd3.tar.gz
commit shift count needs to be initialized to -1
An initial value of zero for commit shift count means we can erroneously fail a parse when we back up to zero shifts.
Diffstat (limited to 'src')
-rw-r--r--src/pdarun.c6
-rw-r--r--src/pdarun.h6
2 files changed, 12 insertions, 0 deletions
diff --git a/src/pdarun.c b/src/pdarun.c
index dcbab4cb..52b203f5 100644
--- a/src/pdarun.c
+++ b/src/pdarun.c
@@ -1312,6 +1312,11 @@ void colm_pda_init( program_t *prg, struct pda_run *pda_run, struct pda_tables *
pda_run->target_steps = -1;
pda_run->reducer = reducer;
+ /* An initial commit shift count of -1 means we won't ever back up to zero
+ * shifts and think parsing cannot continue. */
+ pda_run->shift_count = 0;
+ pda_run->commit_shift_count = -1;
+
if ( reducer ) {
init_pool_alloc( &pda_run->local_pool, sizeof(parse_tree_t) +
prg->rtd->commit_union_sz(reducer) );
@@ -1508,6 +1513,7 @@ again:
*/
if ( pda_run->pda_tables->commit_len[pos] != 0 ) {
+ debug( prg, REALM_PARSE, "commit point\n" );
pda_run->commit_shift_count = pda_run->shift_count;
/* Not in a reverting context and the parser result is not used. */
diff --git a/src/pdarun.h b/src/pdarun.h
index dfabfea5..a5427576 100644
--- a/src/pdarun.h
+++ b/src/pdarun.h
@@ -317,6 +317,12 @@ struct pda_run
long steps;
long target_steps;
+
+
+ /* The shift count simply tracks the number of shifts that have happend.
+ * The commit shift count is the shift count when the last commit occurred.
+ * If we back up to this number of shifts then we decide we cannot proceed.
+ * The commit shift count is initialized to -1. */
long shift_count;
long commit_shift_count;