Skip to content

Commit 1988615

Browse files
committed
Remove PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE macro
1 parent 7ab6d9d commit 1988615

1 file changed

Lines changed: 32 additions & 33 deletions

File tree

src/prism.c

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,8 +1576,7 @@ not_provided(pm_parser_t *parser) {
15761576
#define PM_LOCATION_TOKEN_VALUE(token) ((pm_location_t) { .start = (token)->start, .end = (token)->end })
15771577
#define PM_LOCATION_NODE_VALUE(node) ((pm_location_t) { .start = (node)->location.start, .end = (node)->location.end })
15781578
#define PM_LOCATION_NODE_BASE_VALUE(node) ((pm_location_t) { .start = (node)->base.location.start, .end = (node)->base.location.end })
1579-
#define PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE ((pm_location_t) { .start = NULL, .end = NULL })
1580-
#define PM_OPTIONAL_LOCATION_TOKEN_VALUE(token) ((token)->type == PM_TOKEN_NOT_PROVIDED ? PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE : PM_LOCATION_TOKEN_VALUE(token))
1579+
#define PM_OPTIONAL_LOCATION_TOKEN_VALUE(token) ((token)->type == PM_TOKEN_NOT_PROVIDED ? ((pm_location_t) { 0 }) : PM_LOCATION_TOKEN_VALUE(token))
15811580

15821581
/**
15831582
* This is a special out parameter to the parse_arguments_list function that
@@ -2153,8 +2152,8 @@ pm_array_pattern_node_node_list_create(pm_parser_t *parser, pm_node_list_t *node
21532152
.rest = NULL,
21542153
.requireds = { 0 },
21552154
.posts = { 0 },
2156-
.opening_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
2157-
.closing_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE
2155+
.opening_loc = { 0 },
2156+
.closing_loc = { 0 }
21582157
};
21592158

21602159
// For now we're going to just copy over each pointer manually. This could be
@@ -2189,8 +2188,8 @@ pm_array_pattern_node_rest_create(pm_parser_t *parser, pm_node_t *rest) {
21892188
.rest = rest,
21902189
.requireds = { 0 },
21912190
.posts = { 0 },
2192-
.opening_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
2193-
.closing_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE
2191+
.opening_loc = { 0 },
2192+
.closing_loc = { 0 }
21942193
};
21952194

21962195
return node;
@@ -2338,7 +2337,7 @@ pm_begin_node_create(pm_parser_t *parser, const pm_token_t *begin_keyword, pm_st
23382337
),
23392338
.begin_keyword_loc = PM_OPTIONAL_LOCATION_TOKEN_VALUE(begin_keyword),
23402339
.statements = statements,
2341-
.end_keyword_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE
2340+
.end_keyword_loc = { 0 }
23422341
};
23432342

23442343
return node;
@@ -2476,7 +2475,7 @@ pm_block_parameters_node_create(pm_parser_t *parser, pm_parameters_node_t *param
24762475
.base = PM_NODE_INIT(parser, PM_BLOCK_PARAMETERS_NODE, 0, start, end),
24772476
.parameters = parameters,
24782477
.opening_loc = PM_OPTIONAL_LOCATION_TOKEN_VALUE(opening),
2479-
.closing_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
2478+
.closing_loc = { 0 },
24802479
.locals = { 0 }
24812480
};
24822481

@@ -2562,12 +2561,12 @@ pm_call_node_create(pm_parser_t *parser, pm_node_flags_t flags) {
25622561
*node = (pm_call_node_t) {
25632562
.base = PM_NODE_INIT_BASE(parser, PM_CALL_NODE, flags),
25642563
.receiver = NULL,
2565-
.call_operator_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
2566-
.message_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
2567-
.opening_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
2564+
.call_operator_loc = { 0 },
2565+
.message_loc = { 0 },
2566+
.opening_loc = { 0 },
25682567
.arguments = NULL,
2569-
.closing_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
2570-
.equal_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
2568+
.closing_loc = { 0 },
2569+
.equal_loc = { 0 },
25712570
.block = NULL,
25722571
.name = 0
25732572
};
@@ -3788,8 +3787,8 @@ pm_find_pattern_node_create(pm_parser_t *parser, pm_node_list_t *nodes) {
37883787
.left = left_splat_node,
37893788
.right = right_splat_node,
37903789
.requireds = { 0 },
3791-
.opening_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
3792-
.closing_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE
3790+
.opening_loc = { 0 },
3791+
.closing_loc = { 0 }
37933792
};
37943793

37953794
// For now we're going to just copy over each pointer manually. This could be
@@ -4115,8 +4114,8 @@ pm_hash_pattern_node_node_list_create(pm_parser_t *parser, pm_node_list_t *eleme
41154114
.constant = NULL,
41164115
.elements = { 0 },
41174116
.rest = rest,
4118-
.opening_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
4119-
.closing_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE
4117+
.opening_loc = { 0 },
4118+
.closing_loc = { 0 }
41204119
};
41214120

41224121
pm_node_t *element;
@@ -4369,10 +4368,10 @@ pm_if_node_modifier_create(pm_parser_t *parser, pm_node_t *statement, const pm_t
43694368
.base = PM_NODE_INIT_NODES(parser, PM_IF_NODE, PM_NODE_FLAG_NEWLINE, statement, predicate),
43704369
.if_keyword_loc = PM_LOCATION_TOKEN_VALUE(if_keyword),
43714370
.predicate = predicate,
4372-
.then_keyword_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
4371+
.then_keyword_loc = { 0 },
43734372
.statements = statements,
43744373
.subsequent = NULL,
4375-
.end_keyword_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE
4374+
.end_keyword_loc = { 0 }
43764375
};
43774376

43784377
return node;
@@ -4399,12 +4398,12 @@ pm_if_node_ternary_create(pm_parser_t *parser, pm_node_t *predicate, const pm_to
43994398

44004399
*node = (pm_if_node_t) {
44014400
.base = PM_NODE_INIT_NODES(parser, PM_IF_NODE, PM_NODE_FLAG_NEWLINE, predicate, false_expression),
4402-
.if_keyword_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
4401+
.if_keyword_loc = { 0 },
44034402
.predicate = predicate,
44044403
.then_keyword_loc = PM_LOCATION_TOKEN_VALUE(qmark),
44054404
.statements = if_statements,
44064405
.subsequent = UP(else_node),
4407-
.end_keyword_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE
4406+
.end_keyword_loc = { 0 }
44084407
};
44094408

44104409
return node;
@@ -5370,8 +5369,8 @@ pm_multi_target_node_create(pm_parser_t *parser) {
53705369
.lefts = { 0 },
53715370
.rest = NULL,
53725371
.rights = { 0 },
5373-
.lparen_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
5374-
.rparen_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE
5372+
.lparen_loc = { 0 },
5373+
.rparen_loc = { 0 }
53755374
};
53765375

53775376
return node;
@@ -5954,8 +5953,8 @@ pm_rescue_node_create(pm_parser_t *parser, const pm_token_t *keyword) {
59545953
*node = (pm_rescue_node_t) {
59555954
.base = PM_NODE_INIT_TOKEN(parser, PM_RESCUE_NODE, 0, keyword),
59565955
.keyword_loc = PM_LOCATION_TOKEN_VALUE(keyword),
5957-
.operator_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
5958-
.then_keyword_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
5956+
.operator_loc = { 0 },
5957+
.then_keyword_loc = { 0 },
59595958
.reference = NULL,
59605959
.statements = NULL,
59615960
.subsequent = NULL,
@@ -6806,7 +6805,7 @@ pm_unless_node_create(pm_parser_t *parser, const pm_token_t *keyword, pm_node_t
68066805
.then_keyword_loc = PM_OPTIONAL_LOCATION_TOKEN_VALUE(then_keyword),
68076806
.statements = statements,
68086807
.else_clause = NULL,
6809-
.end_keyword_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE
6808+
.end_keyword_loc = { 0 }
68106809
};
68116810

68126811
return node;
@@ -6827,10 +6826,10 @@ pm_unless_node_modifier_create(pm_parser_t *parser, pm_node_t *statement, const
68276826
.base = PM_NODE_INIT_NODES(parser, PM_UNLESS_NODE, PM_NODE_FLAG_NEWLINE, statement, predicate),
68286827
.keyword_loc = PM_LOCATION_TOKEN_VALUE(unless_keyword),
68296828
.predicate = predicate,
6830-
.then_keyword_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
6829+
.then_keyword_loc = { 0 },
68316830
.statements = statements,
68326831
.else_clause = NULL,
6833-
.end_keyword_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE
6832+
.end_keyword_loc = { 0 }
68346833
};
68356834

68366835
return node;
@@ -6897,8 +6896,8 @@ pm_until_node_modifier_create(pm_parser_t *parser, const pm_token_t *keyword, pm
68976896
*node = (pm_until_node_t) {
68986897
.base = PM_NODE_INIT_NODES(parser, PM_UNTIL_NODE, flags, statements, predicate),
68996898
.keyword_loc = PM_LOCATION_TOKEN_VALUE(keyword),
6900-
.do_keyword_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
6901-
.closing_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
6899+
.do_keyword_loc = { 0 },
6900+
.closing_loc = { 0 },
69026901
.predicate = predicate,
69036902
.statements = statements
69046903
};
@@ -6917,7 +6916,7 @@ pm_when_node_create(pm_parser_t *parser, const pm_token_t *keyword) {
69176916
.base = PM_NODE_INIT_TOKEN(parser, PM_WHEN_NODE, 0, keyword),
69186917
.keyword_loc = PM_LOCATION_TOKEN_VALUE(keyword),
69196918
.statements = NULL,
6920-
.then_keyword_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
6919+
.then_keyword_loc = { 0 },
69216920
.conditions = { 0 }
69226921
};
69236922

@@ -6986,8 +6985,8 @@ pm_while_node_modifier_create(pm_parser_t *parser, const pm_token_t *keyword, pm
69866985
*node = (pm_while_node_t) {
69876986
.base = PM_NODE_INIT_NODES(parser, PM_WHILE_NODE, flags, statements, predicate),
69886987
.keyword_loc = PM_LOCATION_TOKEN_VALUE(keyword),
6989-
.do_keyword_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
6990-
.closing_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
6988+
.do_keyword_loc = { 0 },
6989+
.closing_loc = { 0 },
69916990
.predicate = predicate,
69926991
.statements = statements
69936992
};

0 commit comments

Comments
 (0)