do not abort when finding syntax error
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
#include "picrin.h"
|
||||
|
||||
#if PIC_ENABLE_READLINE
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
# include <readline/readline.h>
|
||||
# include <readline/history.h>
|
||||
#endif
|
||||
@@ -84,6 +86,11 @@ main()
|
||||
printf("]\n");
|
||||
#endif
|
||||
|
||||
if (pic_undef_p(v)) {
|
||||
pic_gc_arena_restore(pic, ai);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* eval */
|
||||
proc = pic_codegen(pic, v, pic->global_env);
|
||||
v = pic_run(pic, proc, pic_nil_value());
|
||||
|
||||
+7
-2
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "picrin.h"
|
||||
|
||||
#define YYERROR_VERBOSE 1
|
||||
|
||||
struct parser_control {
|
||||
pic_state *pic;
|
||||
pic_value value;
|
||||
@@ -29,7 +31,7 @@ struct parser_control {
|
||||
program
|
||||
:
|
||||
{
|
||||
p->value = pic_nil_value(p->pic);
|
||||
p->value = pic_undef_value(p->pic);
|
||||
}
|
||||
| datum
|
||||
{
|
||||
@@ -95,7 +97,6 @@ int
|
||||
yyerror(struct parser_control *p, const char *msg)
|
||||
{
|
||||
puts(msg);
|
||||
abort();
|
||||
}
|
||||
|
||||
pic_value
|
||||
@@ -109,5 +110,9 @@ pic_parse(pic_state *pic, const char *str)
|
||||
yyparse(&p);
|
||||
yylex_destroy();
|
||||
|
||||
if (yynerrs > 0) {
|
||||
p.value = pic_undef_value();
|
||||
}
|
||||
|
||||
return p.value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user