Skip to content

Commit 0aa7d9d

Browse files
committed
Rename statements to body where appropriate
1 parent 19d37bb commit 0aa7d9d

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

config.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ nodes:
540540
- name: parameters
541541
type: node?
542542
kind: BlockParametersNode
543-
- name: statements
543+
- name: body
544544
type: node?
545545
- name: opening_loc
546546
type: location
@@ -727,7 +727,7 @@ nodes:
727727
type: location?
728728
- name: superclass
729729
type: node?
730-
- name: statements
730+
- name: body
731731
type: node?
732732
- name: end_keyword_loc
733733
type: location
@@ -816,7 +816,7 @@ nodes:
816816
- name: parameters
817817
type: node?
818818
kind: ParametersNode
819-
- name: statements
819+
- name: body
820820
type: node?
821821
- name: locals
822822
type: constant[]
@@ -1239,7 +1239,7 @@ nodes:
12391239
- name: parameters
12401240
type: node?
12411241
kind: BlockParametersNode
1242-
- name: statements
1242+
- name: body
12431243
type: node?
12441244
comment: |
12451245
Represents using a lambda literal (not the lambda method call).
@@ -1314,7 +1314,7 @@ nodes:
13141314
type: location
13151315
- name: constant_path
13161316
type: node
1317-
- name: statements
1317+
- name: body
13181318
type: node?
13191319
- name: end_keyword_loc
13201320
type: location
@@ -1459,7 +1459,7 @@ nodes:
14591459
end
14601460
- name: ParenthesesNode
14611461
child_nodes:
1462-
- name: statements
1462+
- name: body
14631463
type: node?
14641464
- name: opening_loc
14651465
type: location
@@ -1702,7 +1702,7 @@ nodes:
17021702
type: location
17031703
- name: expression
17041704
type: node
1705-
- name: statements
1705+
- name: body
17061706
type: node?
17071707
- name: end_keyword_loc
17081708
type: location

src/yarp.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,8 @@ yp_flip_flop(yp_node_t *node) {
450450
case YP_NODE_PARENTHESES_NODE: {
451451
yp_parentheses_node_t *cast = (yp_parentheses_node_t *) node;
452452

453-
if ((cast->statements != NULL) && YP_NODE_TYPE_P(cast->statements, YP_NODE_STATEMENTS_NODE)) {
454-
yp_statements_node_t *statements = (yp_statements_node_t *) cast->statements;
453+
if ((cast->body != NULL) && YP_NODE_TYPE_P(cast->body, YP_NODE_STATEMENTS_NODE)) {
454+
yp_statements_node_t *statements = (yp_statements_node_t *) cast->body;
455455
if (statements->body.size == 1) yp_flip_flop(statements->body.nodes[0]);
456456
}
457457

@@ -1018,7 +1018,7 @@ yp_block_argument_node_create(yp_parser_t *parser, const yp_token_t *operator, y
10181018

10191019
// Allocate and initialize a new BlockNode node.
10201020
static yp_block_node_t *
1021-
yp_block_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const yp_token_t *opening, yp_block_parameters_node_t *parameters, yp_node_t *statements, const yp_token_t *closing) {
1021+
yp_block_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const yp_token_t *opening, yp_block_parameters_node_t *parameters, yp_node_t *body, const yp_token_t *closing) {
10221022
yp_block_node_t *node = YP_ALLOC_NODE(parser, yp_block_node_t);
10231023

10241024
*node = (yp_block_node_t) {
@@ -1028,7 +1028,7 @@ yp_block_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const y
10281028
},
10291029
.locals = *locals,
10301030
.parameters = parameters,
1031-
.statements = statements,
1031+
.body = body,
10321032
.opening_loc = YP_LOCATION_TOKEN_VALUE(opening),
10331033
.closing_loc = YP_LOCATION_TOKEN_VALUE(closing)
10341034
};
@@ -1486,7 +1486,7 @@ yp_case_node_end_keyword_loc_set(yp_case_node_t *node, const yp_token_t *end_key
14861486

14871487
// Allocate a new ClassNode node.
14881488
static yp_class_node_t *
1489-
yp_class_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const yp_token_t *class_keyword, yp_node_t *constant_path, const yp_token_t *inheritance_operator, yp_node_t *superclass, yp_node_t *statements, const yp_token_t *end_keyword) {
1489+
yp_class_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const yp_token_t *class_keyword, yp_node_t *constant_path, const yp_token_t *inheritance_operator, yp_node_t *superclass, yp_node_t *body, const yp_token_t *end_keyword) {
14901490
yp_class_node_t *node = YP_ALLOC_NODE(parser, yp_class_node_t);
14911491

14921492
*node = (yp_class_node_t) {
@@ -1499,7 +1499,7 @@ yp_class_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const y
14991499
.constant_path = constant_path,
15001500
.inheritance_operator_loc = YP_OPTIONAL_LOCATION_TOKEN_VALUE(inheritance_operator),
15011501
.superclass = superclass,
1502-
.statements = statements,
1502+
.body = body,
15031503
.end_keyword_loc = YP_LOCATION_TOKEN_VALUE(end_keyword)
15041504
};
15051505

@@ -1616,7 +1616,7 @@ yp_def_node_create(
16161616
const yp_token_t *name,
16171617
yp_node_t *receiver,
16181618
yp_parameters_node_t *parameters,
1619-
yp_node_t *statements,
1619+
yp_node_t *body,
16201620
yp_constant_id_list_t *locals,
16211621
const yp_token_t *def_keyword,
16221622
const yp_token_t *operator,
@@ -1629,7 +1629,7 @@ yp_def_node_create(
16291629
const char *end;
16301630

16311631
if (end_keyword->type == YP_TOKEN_NOT_PROVIDED) {
1632-
end = statements->location.end;
1632+
end = body->location.end;
16331633
} else {
16341634
end = end_keyword->end;
16351635
}
@@ -1642,7 +1642,7 @@ yp_def_node_create(
16421642
.name_loc = YP_LOCATION_TOKEN_VALUE(name),
16431643
.receiver = receiver,
16441644
.parameters = parameters,
1645-
.statements = statements,
1645+
.body = body,
16461646
.locals = *locals,
16471647
.def_keyword_loc = YP_LOCATION_TOKEN_VALUE(def_keyword),
16481648
.operator_loc = YP_OPTIONAL_LOCATION_TOKEN_VALUE(operator),
@@ -2553,7 +2553,7 @@ yp_lambda_node_create(
25532553
yp_constant_id_list_t *locals,
25542554
const yp_token_t *opening,
25552555
yp_block_parameters_node_t *parameters,
2556-
yp_node_t *statements,
2556+
yp_node_t *body,
25572557
const yp_token_t *closing
25582558
) {
25592559
yp_lambda_node_t *node = YP_ALLOC_NODE(parser, yp_lambda_node_t);
@@ -2569,7 +2569,7 @@ yp_lambda_node_create(
25692569
.locals = *locals,
25702570
.opening_loc = YP_LOCATION_TOKEN_VALUE(opening),
25712571
.parameters = parameters,
2572-
.statements = statements
2572+
.body = body
25732573
};
25742574

25752575
return node;
@@ -2679,7 +2679,7 @@ yp_match_required_node_create(yp_parser_t *parser, yp_node_t *value, yp_node_t *
26792679

26802680
// Allocate a new ModuleNode node.
26812681
static yp_module_node_t *
2682-
yp_module_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const yp_token_t *module_keyword, yp_node_t *constant_path, yp_node_t *statements, const yp_token_t *end_keyword) {
2682+
yp_module_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const yp_token_t *module_keyword, yp_node_t *constant_path, yp_node_t *body, const yp_token_t *end_keyword) {
26832683
yp_module_node_t *node = YP_ALLOC_NODE(parser, yp_module_node_t);
26842684

26852685
*node = (yp_module_node_t) {
@@ -2693,7 +2693,7 @@ yp_module_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const
26932693
.locals = (locals == NULL ? ((yp_constant_id_list_t) { .ids = NULL, .size = 0, .capacity = 0 }) : *locals),
26942694
.module_keyword_loc = YP_LOCATION_TOKEN_VALUE(module_keyword),
26952695
.constant_path = constant_path,
2696-
.statements = statements,
2696+
.body = body,
26972697
.end_keyword_loc = YP_LOCATION_TOKEN_VALUE(end_keyword)
26982698
};
26992699

@@ -3006,7 +3006,7 @@ yp_program_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, yp_st
30063006

30073007
// Allocate and initialize new ParenthesesNode node.
30083008
static yp_parentheses_node_t *
3009-
yp_parentheses_node_create(yp_parser_t *parser, const yp_token_t *opening, yp_node_t *statements, const yp_token_t *closing) {
3009+
yp_parentheses_node_create(yp_parser_t *parser, const yp_token_t *opening, yp_node_t *body, const yp_token_t *closing) {
30103010
yp_parentheses_node_t *node = YP_ALLOC_NODE(parser, yp_parentheses_node_t);
30113011

30123012
*node = (yp_parentheses_node_t) {
@@ -3017,7 +3017,7 @@ yp_parentheses_node_create(yp_parser_t *parser, const yp_token_t *opening, yp_no
30173017
.end = closing->end
30183018
}
30193019
},
3020-
.statements = statements,
3020+
.body = body,
30213021
.opening_loc = YP_LOCATION_TOKEN_VALUE(opening),
30223022
.closing_loc = YP_LOCATION_TOKEN_VALUE(closing)
30233023
};
@@ -3363,7 +3363,7 @@ yp_self_node_create(yp_parser_t *parser, const yp_token_t *token) {
33633363

33643364
// Allocate a new SingletonClassNode node.
33653365
static yp_singleton_class_node_t *
3366-
yp_singleton_class_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const yp_token_t *class_keyword, const yp_token_t *operator, yp_node_t *expression, yp_node_t *statements, const yp_token_t *end_keyword) {
3366+
yp_singleton_class_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const yp_token_t *class_keyword, const yp_token_t *operator, yp_node_t *expression, yp_node_t *body, const yp_token_t *end_keyword) {
33673367
yp_singleton_class_node_t *node = YP_ALLOC_NODE(parser, yp_singleton_class_node_t);
33683368

33693369
*node = (yp_singleton_class_node_t) {
@@ -3378,7 +3378,7 @@ yp_singleton_class_node_create(yp_parser_t *parser, yp_constant_id_list_t *local
33783378
.class_keyword_loc = YP_LOCATION_TOKEN_VALUE(class_keyword),
33793379
.operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
33803380
.expression = expression,
3381-
.statements = statements,
3381+
.body = body,
33823382
.end_keyword_loc = YP_LOCATION_TOKEN_VALUE(end_keyword)
33833383
};
33843384

test/location_test.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ def test_BeginNode
6969
assert_location(BeginNode, "begin foo; rescue bar\nelse baz end")
7070
assert_location(BeginNode, "begin foo; rescue bar\nelse baz\nensure qux end")
7171

72-
assert_location(BeginNode, "class Foo\nrescue then end", 10..25, &:statements)
73-
assert_location(BeginNode, "module Foo\nrescue then end", 11..26, &:statements)
72+
assert_location(BeginNode, "class Foo\nrescue then end", 10..25, &:body)
73+
assert_location(BeginNode, "module Foo\nrescue then end", 11..26, &:body)
7474
end
7575

7676
def test_BlockArgumentNode
@@ -287,7 +287,7 @@ def test_ForNode
287287

288288
def test_ForwardingArgumentsNode
289289
assert_location(ForwardingArgumentsNode, "def foo(...); bar(...); end", 18...21) do |node|
290-
node.statements.body.first.arguments.arguments.first
290+
node.body.body.first.arguments.arguments.first
291291
end
292292
end
293293

@@ -599,13 +599,13 @@ def test_SplatNode
599599
end
600600

601601
def test_StatementsNode
602-
assert_location(StatementsNode, "foo { 1 }", 6...7) { |node| node.block.statements }
602+
assert_location(StatementsNode, "foo { 1 }", 6...7) { |node| node.block.body }
603603

604-
assert_location(StatementsNode, "(1)", 1...2, &:statements)
604+
assert_location(StatementsNode, "(1)", 1...2, &:body)
605605

606-
assert_location(StatementsNode, "def foo; 1; end", 9...10, &:statements)
607-
assert_location(StatementsNode, "def foo = 1", 10...11, &:statements)
608-
assert_location(StatementsNode, "def foo; 1\n2; end", 9...12, &:statements)
606+
assert_location(StatementsNode, "def foo; 1; end", 9...10, &:body)
607+
assert_location(StatementsNode, "def foo = 1", 10...11, &:body)
608+
assert_location(StatementsNode, "def foo; 1\n2; end", 9...12, &:body)
609609

610610
assert_location(StatementsNode, "if foo; bar; end", 8...11, &:statements)
611611
assert_location(StatementsNode, "foo if bar", 0...3, &:statements)
@@ -631,11 +631,11 @@ def test_StatementsNode
631631
assert_location(StatementsNode, "begin; ensure; foo; end", 15...18) { |node| node.ensure_clause.statements }
632632
assert_location(StatementsNode, "begin; rescue; else; foo; end", 21...24) { |node| node.else_clause.statements }
633633

634-
assert_location(StatementsNode, "class Foo; foo; end", 11...14, &:statements)
635-
assert_location(StatementsNode, "module Foo; foo; end", 12...15, &:statements)
636-
assert_location(StatementsNode, "class << self; foo; end", 15...18, &:statements)
634+
assert_location(StatementsNode, "class Foo; foo; end", 11...14, &:body)
635+
assert_location(StatementsNode, "module Foo; foo; end", 12...15, &:body)
636+
assert_location(StatementsNode, "class << self; foo; end", 15...18, &:body)
637637

638-
assert_location(StatementsNode, "-> { foo }", 5...8, &:statements)
638+
assert_location(StatementsNode, "-> { foo }", 5...8, &:body)
639639
assert_location(StatementsNode, "BEGIN { foo }", 8...11, &:statements)
640640
assert_location(StatementsNode, "END { foo }", 6...9, &:statements)
641641

0 commit comments

Comments
 (0)