summaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorYukihiro Matsumoto <[email protected]>2012-07-03 20:59:07 +0900
committerYukihiro Matsumoto <[email protected]>2012-07-03 20:59:07 +0900
commit65096c4c1bd1bfb6f547808fc01ab6ea223d9dc6 (patch)
tree5ed7ff2d2ddd0da12e0bcf9b7e09d48e15f1b2c8 /tools
parentce49d90dc82bc165880a800ae95dc327b729143f (diff)
downloadmruby-65096c4c1bd1bfb6f547808fc01ab6ea223d9dc6.tar.gz
mruby-65096c4c1bd1bfb6f547808fc01ab6ea223d9dc6.zip
add context to parser, that would hold local variable info, filename, and line number. mrbc_context argument has been added to mrb_parse_xxx() functions. Normally, you just to need to add NULL (or 0) to the last argument of the above functions.
Diffstat (limited to 'tools')
-rw-r--r--tools/mrbc/mrbc.c2
-rw-r--r--tools/mruby/mruby.c15
2 files changed, 8 insertions, 9 deletions
diff --git a/tools/mrbc/mrbc.c b/tools/mrbc/mrbc.c
index 99fea76d8..9b69244e5 100644
--- a/tools/mrbc/mrbc.c
+++ b/tools/mrbc/mrbc.c
@@ -172,7 +172,7 @@ main(int argc, char **argv)
return n;
}
- p = mrb_parse_file(mrb, args.rfp);
+ p = mrb_parse_file(mrb, args.rfp, NULL);
if (!p || !p->tree || p->nerr) {
cleanup(&args);
mrb_close(mrb);
diff --git a/tools/mruby/mruby.c b/tools/mruby/mruby.c
index 5cf3d8a37..b4b37516b 100644
--- a/tools/mruby/mruby.c
+++ b/tools/mruby/mruby.c
@@ -165,17 +165,16 @@ main(int argc, char **argv)
n = mrb_load_irep(mrb, args.rfp);
}
else {
+ mrbc_context *c = mrbc_context_new(mrb);
if (args.cmdline) {
- p = mrb_parse_string(mrb, (char*)args.cmdline);
- }
+ mrbc_filename(mrb, c, "-e");
+ p = mrb_parse_string(mrb, (char*)args.cmdline, c);
+ }
else {
- p = mrb_parser_new(mrb);
- if (p) {
- mrb_parser_filename(p, argv[1]);
- p->f = args.rfp;
- mrb_parser_parse(p);
- }
+ mrbc_filename(mrb, c, argv[1]);
+ p = mrb_parse_file(mrb, args.rfp, c);
}
+ mrbc_context_free(mrb, c);
if (!p || !p->tree || p->nerr) {
cleanup(mrb, &args);
return -1;