summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--parser.l12
-rw-r--r--stream.c8
-rw-r--r--stream.h1
3 files changed, 14 insertions, 7 deletions
diff --git a/parser.l b/parser.l
index 87215221..52f30f2f 100644
--- a/parser.l
+++ b/parser.l
@@ -52,13 +52,11 @@
#include "parser.h"
#include "txr.h"
-#define YY_INPUT(buf, result, max_size) \
- do { \
- val c = get_byte(yyextra->stream); \
- int n = 0; \
- if (c) \
- buf[n++] = convert(char, c_num(c)); \
- result = n; \
+#define YY_INPUT(buf, result, max_size) \
+ do { \
+ val n = get_bytes(lit("parser"), yyextra->stream, \
+ convert(mem_t *, buf), max_size); \
+ result = c_num(n); \
} while (0)
#define YY_DECL \
diff --git a/stream.c b/stream.c
index 7120fd78..d264da16 100644
--- a/stream.c
+++ b/stream.c
@@ -2972,6 +2972,14 @@ val get_byte(val stream_in)
return ops->get_byte(stream);
}
+val get_bytes(val self, val stream_in, mem_t *ptr, ucnum len)
+{
+ val stream = default_arg(stream_in, std_input);
+ struct strm_ops *ops = coerce(struct strm_ops *,
+ cobj_ops(self, stream, stream_s));
+ return unum(ops->fill_buf(stream, ptr, len, 0));
+}
+
val unget_char(val ch, val stream_in)
{
val self = lit("unget-char");
diff --git a/stream.h b/stream.h
index ba905871..197be303 100644
--- a/stream.h
+++ b/stream.h
@@ -194,6 +194,7 @@ val clear_error(val stream);
val get_line(val);
val get_char(val);
val get_byte(val);
+val get_bytes(val self, val, mem_t *ptr, ucnum len);
val unget_char(val ch, val stream);
val unget_byte(val byte, val stream);
val put_buf(val buf, val pos, val stream);