summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2018-07-10 12:42:33 +0800
committerAdrian Thurston <thurston@colm.net>2018-07-10 12:42:33 +0800
commitb2cd44558e9b780c791f1c48ef6946e6d04fab50 (patch)
tree07ac5b2472b93a96b319c5897faf56c91a31d822 /src
parent723b9790f920360fe7947e4c9bf87db1729d20bb (diff)
downloadcolm-b2cd44558e9b780c791f1c48ef6946e6d04fab50.tar.gz
replace eof_sent in input interface with bit in pda_run
Diffstat (limited to 'src')
-rw-r--r--src/ctinput.cc4
-rw-r--r--src/fsmcodegen.h2
-rw-r--r--src/fsmexec.cc2
-rw-r--r--src/input.c2
-rw-r--r--src/input.h2
-rw-r--r--src/pdarun.c27
-rw-r--r--src/pdarun.h4
7 files changed, 18 insertions, 25 deletions
diff --git a/src/ctinput.cc b/src/ctinput.cc
index cf4c0924..0625249d 100644
--- a/src/ctinput.cc
+++ b/src/ctinput.cc
@@ -271,8 +271,6 @@ input_funcs_ct pat_funcs =
0, 0, 0, 0, 0, 0, /* append funcs */
&ct_set_eof_mark,
- &ct_get_eof_sent,
- &ct_set_eof_sent,
&ct_transfer_loc_seq,
&ct_destructor,
@@ -490,8 +488,6 @@ input_funcs_ct repl_funcs =
0, 0, 0, 0, 0, 0, /* append. */
&ct_set_eof_mark,
- &ct_get_eof_sent,
- &ct_set_eof_sent,
&ct_transfer_loc_seq,
&ct_destructor,
diff --git a/src/fsmcodegen.h b/src/fsmcodegen.h
index 7d86da36..8f79186c 100644
--- a/src/fsmcodegen.h
+++ b/src/fsmcodegen.h
@@ -101,7 +101,7 @@ protected:
string P() { return ACCESS() + "p"; }
string PE() { return ACCESS() + "pe"; }
- string DATA_EOF() { return ACCESS() + "eof"; }
+ string DATA_EOF() { return ACCESS() + "scan_eof"; }
string CS();
string TOP() { return ACCESS() + "top"; }
diff --git a/src/fsmexec.cc b/src/fsmexec.cc
index ba72318c..41fe0e64 100644
--- a/src/fsmexec.cc
+++ b/src/fsmexec.cc
@@ -193,7 +193,7 @@ _again:
if ( ++pdaRun->p != pdaRun->pe )
goto _loop_head;
out:
- if ( pdaRun->eof ) {
+ if ( pdaRun->scan_eof ) {
pdaRun->return_result = false;
pdaRun->skip_toklen = false;
_acts = pdaRun->fsm_tables->actions + pdaRun->fsm_tables->eof_actions[pdaRun->fsm_cs];
diff --git a/src/input.c b/src/input.c
index 20f52f66..c9545fb2 100644
--- a/src/input.c
+++ b/src/input.c
@@ -1095,8 +1095,6 @@ struct input_funcs_seq input_funcs =
/* EOF */
&stream_set_eof_mark,
- &stream_get_eof_sent,
- &stream_set_eof_sent,
&stream_transfer_loc,
&stream_destructor,
diff --git a/src/input.h b/src/input.h
index 1c744d94..05f70883 100644
--- a/src/input.h
+++ b/src/input.h
@@ -104,8 +104,6 @@ struct input_funcs \
void (*append_stream)( struct colm_program *prg, struct input_impl *si, struct colm_stream *stream ); \
struct colm_tree *(*undo_append_stream)( struct colm_program *prg, struct input_impl *si ); \
void (*set_eof_mark)( struct colm_program *prg, struct input_impl *si, char eof_mark ); \
- char (*get_eof_sent)( struct colm_program *prg, struct input_impl *si ); \
- void (*set_eof_sent)( struct colm_program *prg, struct input_impl *si, char eof_sent ); \
void (*transfer_loc)( struct colm_program *prg, struct colm_location *loc, struct input_impl *si ); \
void (*destructor)( struct colm_program *prg, struct colm_tree **sp, struct input_impl *si ); \
}
diff --git a/src/pdarun.c b/src/pdarun.c
index 91de3b93..327f801a 100644
--- a/src/pdarun.c
+++ b/src/pdarun.c
@@ -70,7 +70,7 @@ static void init_fsm_run( program_t *prg, struct pda_run *pda_run )
pda_run->p = pda_run->pe = 0;
pda_run->toklen = 0;
- pda_run->eof = 0;
+ pda_run->scan_eof = 0;
pda_run->pre_region = -1;
}
@@ -234,7 +234,7 @@ static void reset_token( struct pda_run *pda_run )
if ( pda_run->tokstart != 0 ) {
pda_run->p = pda_run->pe = 0;
pda_run->toklen = 0;
- pda_run->eof = 0;
+ pda_run->scan_eof = 0;
}
}
@@ -283,7 +283,7 @@ static void send_back( program_t *prg, tree_t **sp, struct pda_run *pda_run,
/* If eof was just sent back remember that it needs to be sent again. */
if ( parse_tree->id == prg->rtd->eof_lel_ids[pda_run->parser_id] )
- is->funcs->set_eof_sent( prg, is, false );
+ pda_run->eof_term_recvd = false;
/* If the item is bound then store remove it from the bindings array. */
prg->rtd->pop_binding( pda_run, parse_tree );
@@ -1033,7 +1033,7 @@ static void new_token( program_t *prg, struct pda_run *pda_run )
{
pda_run->p = pda_run->pe = 0;
pda_run->toklen = 0;
- pda_run->eof = 0;
+ pda_run->scan_eof = 0;
/* Init the scanner vars. */
pda_run->act = 0;
@@ -1107,14 +1107,14 @@ static long scan_token( program_t *prg, struct pda_run *pda_run, struct input_im
case INPUT_EOS:
pda_run->p = pda_run->pe = 0;
if ( pda_run->tokstart != 0 )
- pda_run->eof = 1;
+ pda_run->scan_eof = 1;
debug( prg, REALM_SCAN, "EOS *******************\n" );
break;
case INPUT_EOF:
pda_run->p = pda_run->pe = 0;
if ( pda_run->tokstart != 0 )
- pda_run->eof = 1;
+ pda_run->scan_eof = 1;
else
return SCAN_EOF;
break;
@@ -1125,20 +1125,20 @@ static long scan_token( program_t *prg, struct pda_run *pda_run, struct input_im
case INPUT_LANG_EL:
if ( pda_run->tokstart != 0 )
- pda_run->eof = 1;
+ pda_run->scan_eof = 1;
else
return SCAN_LANG_EL;
break;
case INPUT_TREE:
if ( pda_run->tokstart != 0 )
- pda_run->eof = 1;
+ pda_run->scan_eof = 1;
else
return SCAN_TREE;
break;
case INPUT_IGNORE:
if ( pda_run->tokstart != 0 )
- pda_run->eof = 1;
+ pda_run->scan_eof = 1;
else
return SCAN_IGNORE;
break;
@@ -1175,7 +1175,7 @@ static long scan_token( program_t *prg, struct pda_run *pda_run, struct input_im
}
/* Check for no match on eof (trailing data that partially matches a token). */
- if ( pda_run->eof )
+ if ( pda_run->scan_eof )
return SCAN_ERROR;
/* Got here because the state machine didn't match a token or encounter
@@ -1357,6 +1357,7 @@ void colm_pda_init( program_t *prg, struct pda_run *pda_run, struct pda_tables *
pda_run->reject = false;
pda_run->rc_block_count = 0;
+ pda_run->eof_term_recvd = 0;
init_fsm_run( prg, pda_run );
new_token( prg, pda_run );
@@ -2003,7 +2004,7 @@ long colm_parse_loop( program_t *prg, tree_t **sp, struct pda_run *pda_run,
/* Check for EOF. */
if ( pda_run->token_id == SCAN_EOF ) {
- is->funcs->set_eof_sent( prg, is, true );
+ pda_run->eof_term_recvd = true;
send_eof( prg, sp, pda_run, is );
pda_run->frame_id = prg->rtd->region_info[pda_run->region].eof_frame_id;
@@ -2086,7 +2087,7 @@ long colm_parse_loop( program_t *prg, tree_t **sp, struct pda_run *pda_run,
pda_run->p = pda_run->pe = 0;
pda_run->toklen = 0;
- pda_run->eof = 0;
+ pda_run->scan_eof = 0;
pda_run->fi = &prg->rtd->frame_info[prg->rtd->lel_info[pda_run->token_id].frame_id];
pda_run->frame_id = prg->rtd->lel_info[pda_run->token_id].frame_id;
@@ -2160,7 +2161,7 @@ skip_send:
break;
}
- if ( is->funcs->get_eof_sent( prg, is ) ) {
+ if ( pda_run->eof_term_recvd ) {
debug( prg, REALM_PARSE, "parsing stopped by EOF\n" );
break;
}
diff --git a/src/pdarun.h b/src/pdarun.h
index 45b28e26..0174644d 100644
--- a/src/pdarun.h
+++ b/src/pdarun.h
@@ -273,11 +273,11 @@ struct pda_run
long tokend;
long toklen;
char *p, *pe;
+ char scan_eof;
- /* Bits. */
- char eof;
char return_result;
char skip_toklen;
+ char eof_term_recvd;
char *mark[MARK_SLOTS];
long matched_token;