error report is propagated through pic->err

This commit is contained in:
Yuichi Nishiwaki
2014-02-11 13:21:00 +09:00
parent 468e1b4d1f
commit 372fd3157b
9 changed files with 59 additions and 38 deletions
+6 -6
View File
@@ -124,14 +124,14 @@ repl(pic_state *pic)
/* eval */
proc = pic_compile(pic, v);
if (proc == NULL) {
printf("compilation error: %s\n", pic->errmsg);
pic->errmsg = NULL;
printf("compilation error: %s\n", pic_errmsg(pic));
pic->err = NULL;
goto next;
}
v = pic_apply(pic, proc, pic_nil_value());
if (pic_undef_p(v)) {
printf("runtime error: %s\n", pic->errmsg);
pic->errmsg = NULL;
printf("runtime error: %s\n", pic_errmsg(pic));
pic->err = NULL;
goto next;
}
@@ -185,14 +185,14 @@ exec_file(pic_state *pic, const char *fname)
proc = pic_compile(pic, v);
if (proc == NULL) {
fputs(pic->errmsg, stderr);
fputs(pic_errmsg(pic), stderr);
fprintf(stderr, "fatal error: %s compilation failure\n", fname);
goto abort;
}
v = pic_apply(pic, proc, pic_nil_value());
if (pic_undef_p(v)) {
fputs(pic->errmsg, stderr);
fputs(pic_errmsg(pic), stderr);
fprintf(stderr, "fatal error: %s evaluation failure\n", fname);
goto abort;
}