diff --git a/tools/main.c b/tools/main.c index a50f2cf6..0d648d20 100644 --- a/tools/main.c +++ b/tools/main.c @@ -56,6 +56,7 @@ repl(pic_state *pic) char *prompt; struct pic_proc *proc; pic_value v, exprs; + jmp_buf jmp; int ai; #if PIC_ENABLE_READLINE @@ -102,6 +103,17 @@ repl(pic_state *pic) goto overflow; strcat(code, line); + if (setjmp(jmp) == 0) { + pic->jmp = &jmp; + } + else { + /* error occured */ + printf("%s\n", pic_errmsg(pic)); + code[0] = '\0'; + pic->err = NULL; + goto next; + } + /* read */ exprs = pic_read_cstr(pic, code); if (pic_undef_p(exprs)) { /* wait for more input */