summaryrefslogtreecommitdiff
path: root/node_dump.c
diff options
context:
space:
mode:
authoryui-knk <[email protected]>2024-07-18 13:47:13 +0900
committerYuichiro Kaneko <[email protected]>2024-07-20 11:25:26 +0900
commit6be539aab5b8fd66685e6079afc6ca83c89fcbd6 ()
treefc3164f28dbb1f2a4ee752626521648937f15289 /node_dump.c
parent174c01b80e31236ca144dc510a662cd18b9a20ee (diff)
Change UNDEF Node structure
Change UNDEF Node to hold their items to keep the original grammar structure. For example: ``` undef a, b ``` Before: ``` @ NODE_BLOCK (id: 4, line: 1, location: (1,6)-(1,10))* +- nd_head (1): | @ NODE_UNDEF (id: 1, line: 1, location: (1,6)-(1,7)) | +- nd_undef: | @ NODE_SYM (id: 0, line: 1, location: (1,6)-(1,7)) | +- string: :a +- nd_head (2): @ NODE_UNDEF (id: 3, line: 1, location: (1,9)-(1,10)) +- nd_undef: @ NODE_SYM (id: 2, line: 1, location: (1,9)-(1,10)) +- string: :b ``` After: ``` @ NODE_UNDEF (id: 1, line: 1, location: (1,6)-(1,10))* +- nd_undefs: +- length: 2 +- element (0): | @ NODE_SYM (id: 0, line: 1, location: (1,6)-(1,7)) | +- string: :a +- element (1): @ NODE_SYM (id: 2, line: 1, location: (1,9)-(1,10)) +- string: :b ```
Notes: Merged: https://.com/ruby/ruby/pull/11213
-rw-r--r--node_dump.c29
1 files changed, 27 insertions, 2 deletions
@@ -92,6 +92,9 @@
#define F_NODE2(name, n, ann) \
COMPOUND_FIELD1(#name, ann) {dump_node(buf, indent, comment, n);}
#define ANN(ann) \
if (comment) { \
A_INDENT; A("| # " ann "\n"); \
@@ -165,6 +168,28 @@ dump_array(VALUE buf, VALUE indent, int comment, const NODE *node)
}
static void
dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
{
int field_flag;
@@ -896,10 +921,10 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
case NODE_UNDEF:
ANN("method undef statement");
- ANN("format: undef [nd_undef]");
ANN("example: undef foo");
LAST_NODE;
- F_NODE(nd_undef, RNODE_UNDEF, "old name");
return;
case NODE_CLASS: