From 6f6c270bb13ff6e68f39e863f11706ba0bf28500 Mon Sep 17 00:00:00 2001 From: Yukihiro Matsumoto Date: Sat, 19 May 2012 16:15:11 +0900 Subject: mirb should detect end of expression smarter --- src/parse.y | 5 +++++ tools/mirb/mirb.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/parse.y b/src/parse.y index 8acdf983a..2b2dd6851 100644 --- a/src/parse.y +++ b/src/parse.y @@ -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) { diff --git a/tools/mirb/mirb.c b/tools/mirb/mirb.c index df7c29df6..f09417ed0 100644 --- a/tools/mirb/mirb.c +++ b/tools/mirb/mirb.c @@ -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; -- cgit v1.2.3