diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-09-11 21:28:24 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-09-11 21:28:24 -0700 |
commit | a349b8cbb6ba961d04a57c477f601800b45950ef (patch) | |
tree | 677da97beb99dd9bc5cfc16bcc15fd8177bf7004 /parser.h | |
parent | ce61431bff702afcbd6a2ef52babd859203cccf8 (diff) | |
download | txr-a349b8cbb6ba961d04a57c477f601800b45950ef.tar.gz txr-a349b8cbb6ba961d04a57c477f601800b45950ef.tar.bz2 txr-a349b8cbb6ba961d04a57c477f601800b45950ef.zip |
Better EOF check in read-eval stream function.
This makes a difference if we read from a TTY.
Without this fix, two Ctrl-D's have to be issued
before the code registers EOF and returns.
The trick is that we know, after calling the
parser, whether it hit EOF, because we have
the recent token. If its value is zero, that's
the EOF token. We can bail out of the loop
instead of calling the parser again which will
require another EOF (because prime_parser
will not push an EOF token!)
* parser.h (parser_eof): Declared.
* parser.c (read_eval_stream): After lisp_parse
and eval, check for EOF with the parser_eof
function, and bail if so.
(parser_eof): New function.
Diffstat (limited to 'parser.h')
-rw-r--r-- | parser.h | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -104,4 +104,5 @@ void parser_cleanup(parser_t *); val parser(val stream, val lineno); val get_parser(val stream); val parser_errors(val parser); +val parser_eof(val parser); void parse_init(void); |