summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2018-07-10 11:21:05 +0800
committerAdrian Thurston <thurston@colm.net>2018-07-10 11:21:05 +0800
commit723b9790f920360fe7947e4c9bf87db1729d20bb (patch)
tree8c4a9035900ba0fb50acb2684fe9ee4b41a39ad2
parenta1202027828211d6f4c58709b8059c958b4dc83b (diff)
downloadcolm-723b9790f920360fe7947e4c9bf87db1729d20bb.tar.gz
some cleanup of eof interface
Still have two bools concerning eof. Can't unify these yet ... need break down the two concepts to try to unify.
-rw-r--r--src/bytecode.c4
-rw-r--r--src/ctinput.cc17
-rw-r--r--src/input.c14
-rw-r--r--src/input.h5
4 files changed, 13 insertions, 27 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index 5a1df5bf..a0cfdfac 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -2493,7 +2493,7 @@ again:
vm_push_parser( parser );
si = input_to_impl( parser->input );
- si->funcs->set_eof( prg, si );
+ si->funcs->set_eof_mark( prg, si, true );
if ( exec->WV ) {
rcode_unit_start( exec );
@@ -2514,7 +2514,7 @@ again:
debug( prg, REALM_BYTECODE, "IN_SEND_EOF_BKT\n" );
struct input_impl *si = input_to_impl( parser->input );
- si->funcs->unset_eof( prg, si );
+ si->funcs->set_eof_mark( prg, si, false );
break;
}
diff --git a/src/ctinput.cc b/src/ctinput.cc
index b89b030c..cf4c0924 100644
--- a/src/ctinput.cc
+++ b/src/ctinput.cc
@@ -53,8 +53,8 @@ struct input_impl_ct
struct Constructor *constructor;
struct ConsItem *cons_item;
+ char eof_mark;
char eof_sent;
- char eof;
int offset;
};
@@ -240,14 +240,9 @@ void pat_undo_consume_lang_el( struct colm_program *prg, struct input_impl_ct *s
ss->offset = ss->pat_item->data.length();
}
-void ct_set_eof( struct colm_program *prg, struct input_impl_ct *si )
+void ct_set_eof_mark( struct colm_program *prg, struct input_impl_ct *si, char eof_mark )
{
- si->eof = true;
-}
-
-void ct_unset_eof( struct colm_program *prg, struct input_impl_ct *si )
-{
- si->eof = false;
+ si->eof_mark = eof_mark;
}
void ct_transfer_loc_seq( struct colm_program *prg, location_t *loc, struct input_impl_ct *ss )
@@ -275,8 +270,7 @@ input_funcs_ct pat_funcs =
0, 0, 0, 0, 0, 0, /* prepend funcs. */
0, 0, 0, 0, 0, 0, /* append funcs */
- &ct_set_eof,
- &ct_unset_eof,
+ &ct_set_eof_mark,
&ct_get_eof_sent,
&ct_set_eof_sent,
@@ -495,8 +489,7 @@ input_funcs_ct repl_funcs =
0, 0, 0, 0, 0, 0, /* prepend. */
0, 0, 0, 0, 0, 0, /* append. */
- &ct_set_eof,
- &ct_unset_eof,
+ &ct_set_eof_mark,
&ct_get_eof_sent,
&ct_set_eof_sent,
diff --git a/src/input.c b/src/input.c
index d7d69345..20f52f66 100644
--- a/src/input.c
+++ b/src/input.c
@@ -634,14 +634,9 @@ static void input_stream_seq_prepend( struct input_impl_seq *is, struct seq_buf
}
}
-void stream_set_eof( struct colm_program *prg, struct input_impl_seq *si )
+void stream_set_eof_mark( struct colm_program *prg, struct input_impl_seq *si, char eof_mark )
{
- si->eof = true;
-}
-
-void stream_unset_eof( struct colm_program *prg, struct input_impl_seq *si )
-{
- si->eof = false;
+ si->eof_mark = eof_mark;
}
static void stream_destructor( program_t *prg, tree_t **sp, struct input_impl_seq *si )
@@ -678,7 +673,7 @@ static int stream_get_parse_block( struct colm_program *prg, struct input_impl_s
while ( true ) {
if ( buf == 0 ) {
/* Got through the in-mem buffers without copying anything. */
- ret = is->eof ? INPUT_EOF : INPUT_EOD;
+ ret = is->eof_mark ? INPUT_EOF : INPUT_EOD;
break;
}
@@ -1099,8 +1094,7 @@ struct input_funcs_seq input_funcs =
&stream_undo_append_stream,
/* EOF */
- &stream_set_eof,
- &stream_unset_eof,
+ &stream_set_eof_mark,
&stream_get_eof_sent,
&stream_set_eof_sent,
diff --git a/src/input.h b/src/input.h
index ac701cf8..1c744d94 100644
--- a/src/input.h
+++ b/src/input.h
@@ -103,8 +103,7 @@ struct input_funcs \
struct colm_tree *(*undo_append_tree)( struct colm_program *prg, struct input_impl *si ); \
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)( struct colm_program *prg, struct input_impl *si ); \
- void (*unset_eof)( 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 ); \
@@ -149,8 +148,8 @@ struct input_impl_seq
struct input_funcs *funcs;
char type;
+ char eof_mark;
char eof_sent;
- char eof;
struct seq_buf *queue;
struct seq_buf *queue_tail;