accept empty lines in repl
This commit is contained in:
+1
-1
@@ -33,7 +33,7 @@ pic_load_stdlib(pic_state *pic)
|
||||
}
|
||||
|
||||
n = pic_parse_file(pic, file, &vs);
|
||||
if (n <= 0) {
|
||||
if (n < 0) {
|
||||
fputs("fatal error: built-in.scm broken", stderr);
|
||||
abort();
|
||||
}
|
||||
|
||||
+9
-5
@@ -67,6 +67,10 @@ program
|
||||
p->incomp = true;
|
||||
p->value = pic_undef_value();
|
||||
}
|
||||
| /* empty line */
|
||||
{
|
||||
p->value = pic_nil_value();
|
||||
}
|
||||
;
|
||||
|
||||
program_data
|
||||
@@ -249,17 +253,17 @@ pic_parse_file(pic_state *pic, FILE *file, pic_value *v)
|
||||
|
||||
if (p.yynerrs > 0) {
|
||||
p.value = pic_undef_value();
|
||||
return -1;
|
||||
return PIC_PARSER_ERROR;
|
||||
}
|
||||
if (p.incomp) {
|
||||
return 0;
|
||||
return PIC_PARSER_INCOMPLETE;
|
||||
}
|
||||
|
||||
*v = p.value;
|
||||
return pic_length(pic, p.value);
|
||||
}
|
||||
|
||||
int
|
||||
enum pic_parser_res
|
||||
pic_parse_cstr(pic_state *pic, const char *str, pic_value *v)
|
||||
{
|
||||
struct parser_control p;
|
||||
@@ -274,10 +278,10 @@ pic_parse_cstr(pic_state *pic, const char *str, pic_value *v)
|
||||
yylex_destroy(p.yyscanner);
|
||||
|
||||
if (p.yynerrs > 0) {
|
||||
return -1;
|
||||
return PIC_PARSER_ERROR;
|
||||
}
|
||||
if (p.incomp) {
|
||||
return 0;
|
||||
return PIC_PARSER_INCOMPLETE;
|
||||
}
|
||||
|
||||
*v = p.value;
|
||||
|
||||
Reference in New Issue
Block a user