summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2018-05-15 16:01:16 -0400
committerAdrian Thurston <thurston@colm.net>2018-05-15 16:01:16 -0400
commit945e87df38c52c1ff2dd32f256050388080d7669 (patch)
tree5f32e73ee3b087f92017f4f267523eeb83e77843
parent2d8d299939bbdabad5cc06d4a55c826540f073f3 (diff)
downloadcolm-945e87df38c52c1ff2dd32f256050388080d7669.tar.gz
removed stopId from parse frag instruction
-rw-r--r--src/bytecode.c29
-rw-r--r--src/parsetree.h1
-rw-r--r--src/pdarun.c50
-rw-r--r--src/pdarun.h2
-rw-r--r--src/synthesis.cc3
5 files changed, 19 insertions, 66 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index 7957c6c4..4744ce83 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -2298,7 +2298,7 @@ again:
vm_push_stream( stream );
- instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_HALF + SIZEOF_CODE + SIZEOF_CODE;
+ instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE;
}
else {
stream_append_text( prg, sp, stream, input );
@@ -2325,7 +2325,7 @@ again:
vm_push_stream( stream );
- instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_HALF + SIZEOF_CODE + SIZEOF_CODE;
+ instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE;
}
else {
parser_t *parser = stream->parser;
@@ -2377,7 +2377,7 @@ again:
vm_push_stream( stream );
- instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_HALF + SIZEOF_CODE + SIZEOF_CODE;
+ instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE;
}
else {
parser_t *parser = stream->parser;
@@ -2406,7 +2406,7 @@ again:
vm_push_stream( stream );
- instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_HALF + SIZEOF_CODE + SIZEOF_CODE;
+ instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE;
}
else {
parser_t *parser = stream->parser;
@@ -2506,7 +2506,7 @@ again:
}
if ( stream->parser == 0 )
- instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_HALF + SIZEOF_CODE + SIZEOF_CODE;
+ instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE;
break;
}
@@ -2621,7 +2621,7 @@ again:
/* Return location one instruction back. Depends on the size of of
* the frag/finish. */
- code_t *return_to = instr - ( SIZEOF_CODE + SIZEOF_CODE + SIZEOF_HALF );
+ code_t *return_to = instr - ( SIZEOF_CODE + SIZEOF_CODE );
vm_push_type( code_t*, return_to );
exec->frame_ptr = 0;
@@ -2683,13 +2683,10 @@ again:
}
case IN_PARSE_FRAG_W: {
- half_t stop_id;
- read_half( stop_id );
-
stream_t *stream = vm_pop_stream();
vm_push_stream( stream );
- debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_W %hd\n", stop_id );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_W\n" );
exec->pcr = colm_parse_frag( prg, sp, stream->parser->pda_run,
stream->parser->input, exec->pcr );
@@ -2713,10 +2710,7 @@ again:
rcode_code( exec, IN_PARSE_INIT_BKT );
rcode_word( exec, (word_t)stream );
rcode_word( exec, (word_t)exec->steps );
-
rcode_code( exec, IN_PARSE_FRAG_BKT );
- rcode_half( exec, 0 );
-
rcode_code( exec, IN_PCR_CALL );
rcode_code( exec, IN_PARSE_FRAG_EXIT_BKT );
rcode_unit_term( exec );
@@ -2729,16 +2723,13 @@ again:
}
case IN_PARSE_FRAG_BKT: {
- half_t stop_id;
- read_half( stop_id );
-
stream_t *stream = vm_pop_stream();
vm_push_stream( stream );
- debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_BKT %hd\n", stop_id );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_BKT\n" );
exec->pcr = colm_parse_undo_frag( prg, sp, stream->parser->pda_run,
- stream->parser->input, exec->steps, exec->pcr );
+ stream->parser->input, exec->pcr, exec->steps );
if ( exec->pcr == PCR_DONE )
instr += SIZEOF_CODE;
@@ -4723,8 +4714,6 @@ again:
}
case IN_PARSE_FRAG_BKT: {
- half_t stop_id;
- read_half( stop_id );
debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_BKT\n" );
break;
}
diff --git a/src/parsetree.h b/src/parsetree.h
index 38ed154e..7fc2e164 100644
--- a/src/parsetree.h
+++ b/src/parsetree.h
@@ -3145,7 +3145,6 @@ struct LangTerm
UniqueType *evaluateConstruct( Compiler *pd, CodeVect &code ) const;
static void parseFrag( Compiler *pd, CodeVect &code, int stopId );
- static void parseFinish( Compiler *pd, CodeVect &code, int stopId );
UniqueType *evaluateParse( Compiler *pd, CodeVect &code, bool tree, bool stop ) const;
UniqueType *evaluateReadReduce( Compiler *pd, CodeVect &code ) const;
diff --git a/src/pdarun.c b/src/pdarun.c
index 6d88fff6..ab0de7eb 100644
--- a/src/pdarun.c
+++ b/src/pdarun.c
@@ -2238,48 +2238,8 @@ long colm_parse_frag( program_t *prg, tree_t **sp,
return PCR_DONE;
}
-long colm_parse_finish( program_t *prg, tree_t **sp,
- struct pda_run *pda_run, stream_t *input, long entry )
-{
- /* COROUTINE */
- switch ( entry ) {
- case PCR_START:
-
- if ( ! pda_run->parse_error ) {
- long pcr = colm_parse_loop( prg, sp, pda_run,
- stream_to_impl( input ), entry );
-
- while ( pcr != PCR_DONE ) {
-
- /* COROUTINE */
- return pcr;
- case PCR_REDUCTION:
- case PCR_GENERATION:
- case PCR_PRE_EOF:
- case PCR_REVERSE:
-
- pcr = colm_parse_loop( prg, sp, pda_run,
- stream_to_impl( input ), entry );
- }
- }
-
- /* COROUTINE */
- case PCR_DONE:
- break; }
-
- 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 )
+ stream_t *input, long entry, long steps )
{
debug( prg, REALM_PARSE,
"undo parse frag, target steps: %ld, pdarun steps: %ld\n",
@@ -2325,3 +2285,11 @@ long colm_parse_undo_frag( program_t *prg, tree_t **sp, struct pda_run *pda_run,
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 );
+}
+
diff --git a/src/pdarun.h b/src/pdarun.h
index 094e2d26..b6ebb1ba 100644
--- a/src/pdarun.h
+++ b/src/pdarun.h
@@ -460,7 +460,7 @@ long colm_parse_frag( struct colm_program *prg, tree_t **sp,
long colm_parse_finish( struct colm_program *prg, tree_t **sp,
struct pda_run *pda_run, stream_t *input, long entry );
long colm_parse_undo_frag( struct colm_program *prg, tree_t **sp, struct pda_run *pda_run,
- stream_t *input, long steps, long entry );
+ stream_t *input, long entry, long steps );
void commit_clear_kid_list( program_t *prg, tree_t **sp, kid_t *kid );
void commit_clear_parse_tree( program_t *prg, tree_t **sp,
diff --git a/src/synthesis.cc b/src/synthesis.cc
index 7abfe500..eabb1abf 100644
--- a/src/synthesis.cc
+++ b/src/synthesis.cc
@@ -1418,17 +1418,14 @@ UniqueType *LangTerm::evaluateConstruct( Compiler *pd, CodeVect &code ) const
return replUT;
}
-
void LangTerm::parseFrag( Compiler *pd, CodeVect &code, int stopId )
{
code.append( IN_PARSE_LOAD );
code.append( IN_PARSE_FRAG_W );
- code.appendHalf( stopId );
code.append( IN_PCR_CALL );
code.append( IN_PARSE_FRAG_EXIT_W );
}
-
UniqueType *LangTerm::evaluateReadReduce( Compiler *pd, CodeVect &code ) const
{
UniqueType *parserUT = typeRef->uniqueType;