Exceptions may be raised in yyparse(); fix #3600

parent 918e7bb1
......@@ -5514,10 +5514,11 @@ void mrb_parser_dump(mrb_state *mrb, node *tree, int offset);
MRB_API void
mrb_parser_parse(parser_state *p, mrbc_context *c)
{
struct mrb_jmpbuf buf;
p->jmp = &buf;
struct mrb_jmpbuf buf1;
p->jmp = &buf1;
MRB_TRY(p->jmp) {
int n;
p->cmd_start = TRUE;
p->in_def = p->in_single = 0;
......@@ -5525,7 +5526,25 @@ mrb_parser_parse(parser_state *p, mrbc_context *c)
p->lex_strterm = NULL;
parser_init_cxt(p, c);
if (yyparse(p) != 0 || p->nerr > 0) {
if (p->mrb->jmp) {
n = yyparse(p);
}
else {
struct mrb_jmpbuf buf2;
p->mrb->jmp = &buf2;
MRB_TRY(p->mrb->jmp) {
n = yyparse(p);
}
MRB_CATCH(p->mrb->jmp) {
p->nerr++;
mrb_p(p->mrb, mrb_obj_value(p->mrb->exc));
}
MRB_END_EXC(p->mrb->jmp);
p->mrb->jmp = 0;
}
if (n != 0 || p->nerr > 0) {
p->tree = 0;
return;
}
......@@ -5536,7 +5555,6 @@ mrb_parser_parse(parser_state *p, mrbc_context *c)
if (c && c->dump_result) {
mrb_parser_dump(p->mrb, p->tree, 0);
}
}
MRB_CATCH(p->jmp) {
yyerror(p, "memory allocation error");
......
......@@ -369,6 +369,7 @@ mrb_funcall_with_block(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc
val = mrb_obj_value(mrb->exc);
}
MRB_END_EXC(&c_jmp);
mrb->jmp = 0;
}
else {
struct RProc *p;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment