diff options
| -rw-r--r-- | src/parse.y | 6 | ||||
| -rw-r--r-- | tools/mirb/mirb.c | 9 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/parse.y b/src/parse.y index ec04ae8a6..35eff1b33 100644 --- a/src/parse.y +++ b/src/parse.y @@ -967,12 +967,11 @@ var_reference(parser_state *p, node *lhs) %% program : { p->lstate = EXPR_BEG; - local_nest(p); + if (!p->locals) p->locals = cons(0,0); } top_compstmt { p->tree = new_scope(p, $2); - local_unnest(p); } ; @@ -4631,6 +4630,9 @@ mrb_parser_parse(parser_state *p) } yyparse(p); tree = p->tree; + if ((int)tree->car == NODE_SCOPE) { + p->locals = cons(tree->cdr->car, 0); + } if (!tree) { if (p->begin_tree) { tree = p->begin_tree; diff --git a/tools/mirb/mirb.c b/tools/mirb/mirb.c index 11bdcfcf8..8c1978059 100644 --- a/tools/mirb/mirb.c +++ b/tools/mirb/mirb.c @@ -161,8 +161,10 @@ main(void) print_hint(); - /* new interpreter instance */ + /* new interpreter instance */ mrb_interpreter = mrb_open(); + /* new parser instance */ + parser = mrb_parser_new(mrb_interpreter); memset(ruby_code, 0, sizeof(*ruby_code)); memset(last_code_line, 0, sizeof(*last_code_line)); @@ -205,7 +207,10 @@ main(void) } /* parse code */ - parser = mrb_parse_nstring_ext(mrb_interpreter, ruby_code, strlen(ruby_code)); + parser->s = ruby_code; + parser->send = ruby_code + strlen(ruby_code); + parser->capture_errors = 1; + mrb_parser_parse(parser); code_block_open = is_code_block_open(parser); if (code_block_open) { |
