summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-12-09 14:05:59 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-12-09 14:05:59 +0000
commit38828fa8d1d0a072885da81f866e5f5146355a6f (patch)
treecfca7fe1036f90bb6229f6a07b477d9bb155eaf1 /ruby.c
parentc9c095fc7b56c40e4857c1554932a078eb7a316e (diff)
* node.c: node management added. Currently, only pretty-dumper is
implemented. [ruby-dev:39853] * ruby.c: --dump=parsetree and --dump=parsetree_with_comment options added. This is just for debug or research purpose. Note that the compatibility of these options are not supported at all. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/ruby.c b/ruby.c
index a9632e153b..c9cd10d687 100644
--- a/ruby.c
+++ b/ruby.c
@@ -71,6 +71,8 @@ enum dump_flag_bits {
dump_usage,
dump_yydebug,
dump_syntax,
+ dump_parsetree,
+ dump_parsetree_with_comment,
dump_insns,
dump_flag_count
};
@@ -645,9 +647,11 @@ dump_option(const char *str, int len, void *arg)
SET_WHEN_DUMP(usage);
SET_WHEN_DUMP(yydebug);
SET_WHEN_DUMP(syntax);
+ SET_WHEN_DUMP(parsetree);
+ SET_WHEN_DUMP(parsetree_with_comment);
SET_WHEN_DUMP(insns);
rb_warn("don't know how to dump `%.*s',", len, str);
- rb_warn("but only [version, copyright, usage, yydebug, syntax, insns].");
+ rb_warn("but only [version, copyright, usage, yydebug, syntax, parsetree, parsetree_with_comment, insns].");
}
static void
@@ -1433,6 +1437,12 @@ process_options(int argc, char **argv, struct cmdline_options *opt)
rb_define_global_function("chomp", rb_f_chomp, -1);
}
+ if (opt->dump & DUMP_BIT(parsetree) || opt->dump & DUMP_BIT(parsetree_with_comment)) {
+ rb_io_write(rb_stdout, rb_parser_dump_tree(tree, opt->dump & DUMP_BIT(parsetree_with_comment)));
+ rb_io_flush(rb_stdout);
+ return Qtrue;
+ }
+
PREPARE_PARSE_MAIN({
iseq = rb_iseq_new_main(tree, opt->script_name);
});