summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/commit.c1
-rw-r--r--src/compiler.cc15
-rw-r--r--src/pdarun.c10
3 files changed, 18 insertions, 8 deletions
diff --git a/src/commit.c b/src/commit.c
index ed92190e..2d1d84d5 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -82,7 +82,6 @@ static int been_committed( parse_tree_t *parse_tree )
return parse_tree->flags & PF_COMMITTED;
}
-
void commit_clear( program_t *prg, tree_t **root, struct pda_run *pda_run )
{
tree_t **sp = root;
diff --git a/src/compiler.cc b/src/compiler.cc
index cd95caf7..008788c5 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -1148,26 +1148,31 @@ void Compiler::writeCommit()
" tree_t **sp = root;\n"
"\n"
" parse_tree_t *lel = pt;\n"
+ " kid_t *kid = pt->shadow;\n"
"\n"
"recurse:\n"
"\n"
" if ( lel->child != 0 ) {\n"
" /* There are children. Must process all children first. */\n"
" vm_push_ptree( lel );\n"
+ " vm_push_kid( kid );\n"
"\n"
" lel = lel->child;\n"
+ " kid = kid->tree->child;\n"
" while ( lel != 0 ) {\n"
" goto recurse;\n"
" resume:\n"
" lel = lel->next;\n"
+ " kid = kid->next;\n"
" }\n"
"\n"
+ " kid = vm_pop_kid();\n"
" lel = vm_pop_ptree();\n"
" }\n"
"\n"
- " /* Now can execute the reduction action. */\n"
- " if ( lel->shadow != 0 ) {\n"
- " switch ( lel->shadow->tree->id ) {\n";
+ " if ( !( lel->flags & PF_COMMITTED ) ) {\n"
+ " /* Now can execute the reduction action. */\n"
+ " switch ( kid->tree->id ) {\n";
for ( ReductionVect::Iter r = rootNamespace->reductions; r.lte(); r++ ) {
for ( ReduceActionList::Iter rdi = (*r)->reduceActions; rdi.lte(); rdi++ ) {
@@ -1176,7 +1181,7 @@ void Compiler::writeCommit()
*outStream <<
" case " << lelId << ": \n"
- " if ( lel->shadow->tree->prod_num == " << prodNum << " ) {\n"
+ " if ( kid->tree->prod_num == " << prodNum << " ) {\n"
" " << rdi->txt << "\n"
" }\n"
" break;\n";
@@ -1189,10 +1194,10 @@ void Compiler::writeCommit()
"\n"
" commit_clear_parse_tree( prg, sp, pda_run, lel->child );\n"
" lel->child = 0;\n"
- " pt->flags |= PF_COMMITTED;\n"
"\n"
" if ( sp != root )\n"
" goto resume;\n"
+ " pt->flags |= PF_COMMITTED;\n"
"}\n"
"\n";
}
diff --git a/src/pdarun.c b/src/pdarun.c
index 68cbe280..d06659f3 100644
--- a/src/pdarun.c
+++ b/src/pdarun.c
@@ -1382,8 +1382,9 @@ again:
pda_run->commit_shift_count = pda_run->shift_count;
/* Not in a reverting context and the parser result is not used. */
- if ( ! pda_run->revert_on && pda_run->not_used )
+ if ( pda_run->not_used ) {
commit_reduce( prg, sp, pda_run );
+ }
}
/*
@@ -2132,7 +2133,12 @@ long colm_parse_finish( tree_t **result, program_t *prg, tree_t **sp,
/* FIXME: need something here to check that we are not stopped waiting for
* more data when we are actually expected to finish. This check doesn't
* work (at time of writing). */
- //assert( (pdaRun->stopTarget > 0 && pdaRun->stopParsing) || streamToImpl( input )->eofSent );
+ //assert( (pdaRun->stopTarget > 0 && pdaRun->stopParsing) ||
+ // streamToImpl( input )->eofSent );
+
+ /* Flush out anything not committed. */
+ if ( pda_run->not_used )
+ commit_reduce( prg, sp, pda_run );
if ( !revert_on )
colm_rcode_downref_all( prg, sp, &pda_run->reverse_code );