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.

This commit is contained in:
Yukihiro Matsumoto
2012-07-03 20:59:07 +09:00
parent ce49d90dc8
commit 65096c4c1b
5 changed files with 98 additions and 51 deletions
+7 -8
View File
@@ -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;