summaryrefslogtreecommitdiffstats
path: root/parser.l
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-01-07 19:01:33 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-01-07 19:01:33 -0800
commitd1ecfd527d7717921e013d35be3070e7f95265e5 (patch)
treec6de538e9b15b1a210d21223f311c9294f554c19 /parser.l
parent9578ad156a1b076905eb26dd746261a506a0edcf (diff)
downloadtxr-d1ecfd527d7717921e013d35be3070e7f95265e5.tar.gz
txr-d1ecfd527d7717921e013d35be3070e7f95265e5.tar.bz2
txr-d1ecfd527d7717921e013d35be3070e7f95265e5.zip
The lisp-parse function can now be called multiple times
on the same stream to extract multiple objects; the requirement that the stream must hold exactly one complete Lisp object with no following material is now lifted. * parser.l (YY_INPUT): Modified the macro so that it reads no more than one character. Though this probably makes the lexer less efficient, it gives us the important property that the lexer does not scan ahead into the input stream, hogging data into its buffer which is then destroyed. This is essential if the lisp-parse function is to support multiple calls to pull objects one by one out of a stream. * parser.y (spec): Use YYACCEPT in the SECRET_ESCAPE_E clause for pulling a single expression out of the token stream. YYACCEPT is a trick for not invoking the $accept : spec . $end production which is implicitly built into the grammar, and which causes a token of lookahead to occur. This allows us to read a full expression without stealing any further token: but only if the grammar is structured right. (exprs): This phrase structure now handles the DOTDOT syntax. There is no such thing as an expr DOTDOT expr expression any more; it is in the list syntax (and not supported in the dot position). (expr): Remove DOTDOT syntax. * txr.1: Updated description of .. syntax, and relaxed the description of lisp-parse since it now allows multiple calls to extract multiple objects.
Diffstat (limited to 'parser.l')
-rw-r--r--parser.l13
1 files changed, 4 insertions, 9 deletions
diff --git a/parser.l b/parser.l
index 2ab713ab..bdac7a6a 100644
--- a/parser.l
+++ b/parser.l
@@ -52,15 +52,10 @@
#define YY_INPUT(buf, result, max_size) \
do { \
- val c = nil; \
- size_t n; \
- int ch = '*'; \
- for (n = 0; n < max_size && \
- (c = get_byte(yyin_stream)) && \
- (ch = c_num(c)) != '\n'; ++n) \
- buf[n] = (char) ch; \
- if (ch == '\n') \
- buf[n++] = (char) ch; \
+ val c = get_byte(yyin_stream); \
+ int n = 0; \
+ if (c) \
+ buf[n++] = (char) c_num(c); \
result = n; \
} while (0)