catch read error in repl

This commit is contained in:
Yuichi Nishiwaki 2014-03-02 21:44:54 +09:00
parent 3302721c65
commit d168e7e1c8
1 changed files with 12 additions and 0 deletions

View File

@ -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 */