diff options
Diffstat (limited to 'node_dump.c')
| -rw-r--r-- | node_dump.c | 80 |
1 files changed, 62 insertions, 18 deletions
diff --git a/node_dump.c b/node_dump.c index d346ba9a7e..82a7d78c28 100644 --- a/node_dump.c +++ b/node_dump.c @@ -239,8 +239,11 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) ANN("example: if x == 1 then foo else bar end"); F_NODE(nd_cond, RNODE_IF, "condition expr"); F_NODE(nd_body, RNODE_IF, "then clause"); - LAST_NODE; F_NODE(nd_else, RNODE_IF, "else clause"); + F_LOC(if_keyword_loc, RNODE_IF); + F_LOC(then_keyword_loc, RNODE_IF); + LAST_NODE; + F_LOC(end_keyword_loc, RNODE_IF); return; case NODE_UNLESS: @@ -306,8 +309,11 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) ANN("example: case x; in 1; foo; in 2; bar; else baz; end"); F_NODE(nd_head, RNODE_IN, "in pattern"); F_NODE(nd_body, RNODE_IN, "in body"); - LAST_NODE; F_NODE(nd_next, RNODE_IN, "next in clause"); + F_LOC(in_keyword_loc, RNODE_IN); + F_LOC(then_keyword_loc, RNODE_IN); + LAST_NODE; + F_LOC(operator_loc, RNODE_IN); return; case NODE_WHILE: @@ -335,15 +341,22 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) ANN("method call with block"); ANN("format: [nd_iter] { [nd_body] }"); ANN("example: 3.times { foo }"); - goto iter; + F_NODE(nd_iter, RNODE_ITER, "iteration receiver"); + LAST_NODE; + F_NODE(nd_body, RNODE_ITER, "body"); + return; + case NODE_FOR: ANN("for statement"); ANN("format: for * in [nd_iter] do [nd_body] end"); ANN("example: for i in 1..3 do foo end"); - iter: - F_NODE(nd_iter, RNODE_ITER, "iteration receiver"); + F_NODE(nd_iter, RNODE_FOR, "iteration receiver"); + F_NODE(nd_body, RNODE_FOR, "body"); + F_LOC(for_keyword_loc, RNODE_FOR); + F_LOC(in_keyword_loc, RNODE_FOR); + F_LOC(do_keyword_loc, RNODE_FOR); LAST_NODE; - F_NODE(nd_body, RNODE_ITER, "body"); + F_LOC(end_keyword_loc, RNODE_FOR); return; case NODE_FOR_MASGN: @@ -643,8 +656,11 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) ANN("super invocation"); ANN("format: super [nd_args]"); ANN("example: super 1"); - LAST_NODE; F_NODE(nd_args, RNODE_SUPER, "arguments"); + F_LOC(keyword_loc, RNODE_SUPER); + F_LOC(lparen_loc, RNODE_SUPER); + LAST_NODE; + F_LOC(rparen_loc, RNODE_SUPER); return; case NODE_ZSUPER: @@ -691,8 +707,11 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) ANN("yield invocation"); ANN("format: yield [nd_head]"); ANN("example: yield 1"); - LAST_NODE; F_NODE(nd_head, RNODE_YIELD, "arguments"); + F_LOC(keyword_loc, RNODE_YIELD); + F_LOC(lparen_loc, RNODE_YIELD); + LAST_NODE; + F_LOC(rparen_loc, RNODE_YIELD); return; case NODE_LVAR: @@ -826,8 +845,11 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) ANN("regexp literal"); ANN("format: [string]"); ANN("example: /foo/"); - LAST_NODE; F_VALUE(string, rb_node_regx_string_val(node), "string"); + F_LOC(opening_loc, RNODE_REGX); + F_LOC(content_loc, RNODE_REGX); + LAST_NODE; + F_LOC(closing_loc, RNODE_REGX); return; case NODE_ONCE: @@ -876,8 +898,10 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) ANN("interpolation expression"); ANN("format: \"..#{ [nd_body] }..\""); ANN("example: \"foo#{ bar }baz\""); - LAST_NODE; F_NODE(nd_body, RNODE_EVSTR, "body"); + F_LOC(opening_loc, RNODE_EVSTR); + LAST_NODE; + F_LOC(closing_loc, RNODE_EVSTR); return; case NODE_ARGSCAT: @@ -976,8 +1000,11 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) ANN("example: class C2 < C; ..; end"); F_NODE(nd_cpath, RNODE_CLASS, "class path"); F_NODE(nd_super, RNODE_CLASS, "superclass"); - LAST_NODE; F_NODE(nd_body, RNODE_CLASS, "class definition"); + F_LOC(class_keyword_loc, RNODE_CLASS); + F_LOC(inheritance_operator_loc, RNODE_CLASS); + LAST_NODE; + F_LOC(end_keyword_loc, RNODE_CLASS); return; case NODE_MODULE: @@ -985,8 +1012,10 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) ANN("format: module [nd_cpath]; [nd_body]; end"); ANN("example: module M; ..; end"); F_NODE(nd_cpath, RNODE_MODULE, "module path"); - LAST_NODE; F_NODE(nd_body, RNODE_MODULE, "module definition"); + F_LOC(module_keyword_loc, RNODE_MODULE); + LAST_NODE; + F_LOC(end_keyword_loc, RNODE_MODULE); return; case NODE_SCLASS: @@ -994,8 +1023,11 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) ANN("format: class << [nd_recv]; [nd_body]; end"); ANN("example: class << obj; ..; end"); F_NODE(nd_recv, RNODE_SCLASS, "receiver"); - LAST_NODE; F_NODE(nd_body, RNODE_SCLASS, "singleton class definition"); + F_LOC(class_keyword_loc, RNODE_SCLASS); + F_LOC(operator_loc, RNODE_SCLASS); + LAST_NODE; + F_LOC(end_keyword_loc, RNODE_SCLASS); return; case NODE_COLON2: @@ -1003,8 +1035,10 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) ANN("format: [nd_head]::[nd_mid]"); ANN("example: M::C"); F_ID(nd_mid, RNODE_COLON2, "constant name"); - LAST_NODE; F_NODE(nd_head, RNODE_COLON2, "receiver"); + F_LOC(delimiter_loc, RNODE_COLON2); + LAST_NODE; + F_LOC(name_loc, RNODE_COLON2); return; case NODE_COLON3: @@ -1012,6 +1046,8 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) ANN("format: ::[nd_mid]"); ANN("example: ::Object"); F_ID(nd_mid, RNODE_COLON3, "constant name"); + F_LOC(delimiter_loc, RNODE_COLON3); + F_LOC(name_loc, RNODE_COLON3); return; case NODE_DOT2: @@ -1035,8 +1071,9 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) ANN("example: if (x==1)...(x==5); foo; end"); dot: F_NODE(nd_beg, RNODE_DOT2, "begin"); - LAST_NODE; F_NODE(nd_end, RNODE_DOT2, "end"); + LAST_NODE; + F_LOC(operator_loc, RNODE_DOT2); return; case NODE_SELF: @@ -1076,16 +1113,20 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) ANN("defined? expression"); ANN("format: defined?([nd_head])"); ANN("example: defined?(foo)"); - LAST_NODE; F_NODE(nd_head, RNODE_DEFINED, "expr"); + LAST_NODE; + F_LOC(keyword_loc, RNODE_DEFINED); return; case NODE_POSTEXE: ANN("post-execution"); ANN("format: END { [nd_body] }"); ANN("example: END { foo }"); - LAST_NODE; F_NODE(nd_body, RNODE_POSTEXE, "END clause"); + F_LOC(keyword_loc, RNODE_POSTEXE); + F_LOC(opening_loc, RNODE_POSTEXE); + LAST_NODE; + F_LOC(closing_loc, RNODE_POSTEXE); return; case NODE_ATTRASGN: @@ -1102,8 +1143,11 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) ANN("lambda expression"); ANN("format: -> [nd_body]"); ANN("example: -> { foo }"); - LAST_NODE; F_NODE(nd_body, RNODE_LAMBDA, "lambda clause"); + F_LOC(operator_loc, RNODE_LAMBDA); + F_LOC(opening_loc, RNODE_LAMBDA); + LAST_NODE; + F_LOC(closing_loc, RNODE_LAMBDA); return; case NODE_OPT_ARG: |
