mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mirb should detect end of expression smarter
This commit is contained in:
@@ -4630,6 +4630,11 @@ mrb_parser_parse(parser_state *p)
|
||||
p->tree = p->begin_tree = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
p->cmd_start = TRUE;
|
||||
p->in_def = p->in_single = FALSE;
|
||||
p->nerr = p->nwarn = 0;
|
||||
|
||||
yyparse(p);
|
||||
tree = p->tree;
|
||||
if (!tree) {
|
||||
|
||||
+2
-1
@@ -27,6 +27,7 @@ is_code_block_open(struct mrb_parser_state *parser)
|
||||
case EXPR_BEG:
|
||||
/* an expression was just started, */
|
||||
/* we can't end it like this */
|
||||
if (parser->nerr == 0) return FALSE;
|
||||
code_block_open = TRUE;
|
||||
break;
|
||||
case EXPR_DOT:
|
||||
@@ -198,13 +199,13 @@ main(void)
|
||||
}
|
||||
else {
|
||||
if (code_block_open) {
|
||||
strcat(ruby_code, "\n");
|
||||
strcat(ruby_code, last_code_line);
|
||||
}
|
||||
else {
|
||||
memset(ruby_code, 0, sizeof(*ruby_code));
|
||||
strcat(ruby_code, last_code_line);
|
||||
}
|
||||
strcat(ruby_code, "\n");
|
||||
|
||||
/* parse code */
|
||||
parser->s = ruby_code;
|
||||
|
||||
Reference in New Issue
Block a user