diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-06-10 06:31:00 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-06-10 06:31:00 -0700 |
commit | 421b7c3aec0b60d126cdec79f2647c901323389f (patch) | |
tree | 42821cc8e857c2dc0bfb978f4f06aaf98a9b0a1d /parser.c | |
parent | b6057e0f7e7ef3f40b0877f8da48ec98d89045c7 (diff) | |
download | txr-421b7c3aec0b60d126cdec79f2647c901323389f.tar.gz txr-421b7c3aec0b60d126cdec79f2647c901323389f.tar.bz2 txr-421b7c3aec0b60d126cdec79f2647c901323389f.zip |
Error handling improvement in read.
* parser.y (spec): New grammar production to handle the cases
that SECRET_ESCAPE_E is not followed by anything (the input
ends before any object is scanned, or there is no input
token which starts an object).
* parser.c (lisp_parse): Deal with EOF indication from parser
(the syntax_tree member of parser_t set to nao).
Diffstat (limited to 'parser.c')
-rw-r--r-- | parser.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -181,17 +181,19 @@ val lisp_parse(val source_in, val error_stream, val error_return_val, val name_i { int gc = gc_state(0); - name = if3(std_error != std_null, name, lit("")); - set(mkloc(pi->name, parser), name); + set(mkloc(pi->name, parser), if3(std_error != std_null, name, lit(""))); parse(pi); gc_state(gc); } dyn_env = saved_dyn; - if (pi->errors) { + if (pi->errors || pi->syntax_tree == nao) { if (missingp(error_return_val)) - uw_throwf(syntax_error_s, lit("read: syntax error"), nao); + uw_throwf(syntax_error_s, lit("read: ~a: ~a"), name, + if3(pi->syntax_tree == nao, + lit("end of input reached without seeing object"), + lit("errors encountered")), nao); return error_return_val; } |