summaryrefslogtreecommitdiffstats
path: root/parser.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-10-14 06:49:33 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-10-14 06:49:33 -0700
commit9cef0547ba0ec81ce6051bb1cba9db5671e08e64 (patch)
treec7f9cf081f07026c01d8aba741c78e67d3b376eb /parser.c
parentd34d09ef504ba2728821ce5b806bb59f22f378d7 (diff)
downloadtxr-9cef0547ba0ec81ce6051bb1cba9db5671e08e64.tar.gz
txr-9cef0547ba0ec81ce6051bb1cba9db5671e08e64.tar.bz2
txr-9cef0547ba0ec81ce6051bb1cba9db5671e08e64.zip
New way of handling exceptions without unwinding.
* eval.c (handler_bind_s): New symbol variable. (op_handler_bind): New static function. (do_expand): Traverse handler-bind forms. (eval_init): Initialize handler_bind_s variable and register handler-bind operator. * lisplib.c (except_set_entries, except_instantiate): New functions. (lisplib_init): Register new functions in dl_table. * parser.c (intr_s): New symbol variable. (repl_intr): Throw exception of type intr, rather than error. This way we can interrupt accidental exception handling loops involving exceptions derived from error. (parse_init): Initialize intr_s. * share/txr/stdlib/except.tl: New file, defines handle macro. * unwind.c (uw_push_handler): New function. (invoke_handler): New static function. (uw_throw): Search loop looks for and processes handlers in addition to catches. * unwind.h (uw_frtype_t): New enum member, UW_HANDLE. (struct uw_catch): Move member visible so it is in the same position as in struct uw_handler. (struct uw_handler): New struct type. (union uw_frame): New member ha of type struct uw_handler. (uw_push_handler): Function declared. * txr.1: Added introductory paragraphs to Exception Handling section. Documented handler-bind and handle. Some minor errors corrected.
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/parser.c b/parser.c
index ccff6a3f..9cdb0a85 100644
--- a/parser.c
+++ b/parser.c
@@ -57,6 +57,7 @@
val parser_s, unique_s;
val listener_hist_len_s, listener_multi_line_p_s;
+val intr_s;
static val stream_parser_hash;
@@ -587,7 +588,7 @@ static char *provide_atom(lino_t *l, const char *str, int n, void *ctx)
static val repl_intr(val signo, val async_p)
{
- uw_throw(error_s, lit("intr"));
+ uw_throw(intr_s, lit("intr"));
}
static val read_eval_ret_last(val env, val in_stream, val out_stream)
@@ -793,6 +794,7 @@ val parser_eof(val parser)
void parse_init(void)
{
parser_s = intern(lit("parser"), user_package);
+ intr_s = intern(lit("intr"), user_package);
listener_hist_len_s = intern(lit("*listener-hist-len*"), user_package);
listener_multi_line_p_s = intern(lit("*listener-multi-line-p*"), user_package);
unique_s = gensym(nil);