[ruby/yarp] Add constant write node
https://github.com/ruby/yarp/commit/a62f2f0153
This commit is contained in:
parent
9c61e0c831
commit
7a1c497426
Notes:
git
2023-08-17 00:48:09 +00:00
@ -29,11 +29,7 @@ ProgramNode(0...709)(
|
|||||||
(26...27),
|
(26...27),
|
||||||
IntegerNode(28...29)()
|
IntegerNode(28...29)()
|
||||||
),
|
),
|
||||||
ConstantPathWriteNode(31...36)(
|
ConstantWriteNode(31...36)((31...32), IntegerNode(35...36)(), (33...34)),
|
||||||
ConstantReadNode(31...32)(),
|
|
||||||
(33...34),
|
|
||||||
IntegerNode(35...36)()
|
|
||||||
),
|
|
||||||
ConstantReadNode(38...41)(),
|
ConstantReadNode(38...41)(),
|
||||||
CallNode(43...48)(
|
CallNode(43...48)(
|
||||||
nil,
|
nil,
|
||||||
|
@ -967,10 +967,10 @@ ProgramNode(0...1194)(
|
|||||||
nil,
|
nil,
|
||||||
(872...875)
|
(872...875)
|
||||||
),
|
),
|
||||||
ConstantPathWriteNode(877...886)(
|
ConstantWriteNode(877...886)(
|
||||||
ConstantReadNode(877...882)(),
|
(877...882),
|
||||||
(883...884),
|
IntegerNode(885...886)(),
|
||||||
IntegerNode(885...886)()
|
(883...884)
|
||||||
),
|
),
|
||||||
DefNode(888...903)(
|
DefNode(888...903)(
|
||||||
(898...899),
|
(898...899),
|
||||||
|
@ -300,10 +300,10 @@ ProgramNode(0...719)(
|
|||||||
IntegerNode(315...316)(),
|
IntegerNode(315...316)(),
|
||||||
(313...314)
|
(313...314)
|
||||||
),
|
),
|
||||||
ConstantPathWriteNode(317...326)(
|
ConstantWriteNode(317...326)(
|
||||||
ConstantReadNode(317...322)(),
|
(317...322),
|
||||||
(323...324),
|
IntegerNode(325...326)(),
|
||||||
IntegerNode(325...326)()
|
(323...324)
|
||||||
),
|
),
|
||||||
ConstantPathWriteNode(327...350)(
|
ConstantPathWriteNode(327...350)(
|
||||||
ConstantPathNode(327...346)(
|
ConstantPathNode(327...346)(
|
||||||
|
@ -180,14 +180,14 @@ ProgramNode(0...293)(
|
|||||||
(260...263),
|
(260...263),
|
||||||
(264...265)
|
(264...265)
|
||||||
),
|
),
|
||||||
ConstantPathWriteNode(272...282)(
|
ConstantWriteNode(272...282)(
|
||||||
ConstantReadNode(272...275)(),
|
(272...275),
|
||||||
(276...277),
|
|
||||||
ArrayNode(278...282)(
|
ArrayNode(278...282)(
|
||||||
[IntegerNode(278...279)(), IntegerNode(281...282)()],
|
[IntegerNode(278...279)(), IntegerNode(281...282)()],
|
||||||
nil,
|
nil,
|
||||||
nil
|
nil
|
||||||
)
|
),
|
||||||
|
(276...277)
|
||||||
),
|
),
|
||||||
ParenthesesNode(284...293)(
|
ParenthesesNode(284...293)(
|
||||||
StatementsNode(285...292)(
|
StatementsNode(285...292)(
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
ProgramNode(0...8)(
|
ProgramNode(0...8)(
|
||||||
[],
|
[],
|
||||||
StatementsNode(0...8)(
|
StatementsNode(0...8)(
|
||||||
[ConstantPathWriteNode(0...8)(
|
[ConstantWriteNode(0...8)((0...3), IntegerNode(6...8)(), (4...5))]
|
||||||
ConstantReadNode(0...3)(),
|
|
||||||
(4...5),
|
|
||||||
IntegerNode(6...8)()
|
|
||||||
)]
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -12,10 +12,10 @@ ProgramNode(0...132)(
|
|||||||
(13...15),
|
(13...15),
|
||||||
SelfNode(16...20)(),
|
SelfNode(16...20)(),
|
||||||
StatementsNode(22...29)(
|
StatementsNode(22...29)(
|
||||||
[ConstantPathWriteNode(22...29)(
|
[ConstantWriteNode(22...29)(
|
||||||
ConstantReadNode(22...23)(),
|
(22...23),
|
||||||
(24...25),
|
NilNode(26...29)(),
|
||||||
NilNode(26...29)()
|
(24...25)
|
||||||
)]
|
)]
|
||||||
),
|
),
|
||||||
(31...34)
|
(31...34)
|
||||||
|
24
yarp/yarp.c
24
yarp/yarp.c
@ -1699,6 +1699,27 @@ yp_constant_read_node_create(yp_parser_t *parser, const yp_token_t *name) {
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allocate a new ConstantWriteNode node.
|
||||||
|
static yp_constant_write_node_t *
|
||||||
|
yp_constant_write_node_create(yp_parser_t *parser, yp_constant_read_node_t *target, const yp_token_t *operator, yp_node_t *value) {
|
||||||
|
yp_constant_write_node_t *node = YP_ALLOC_NODE(parser, yp_constant_write_node_t);
|
||||||
|
|
||||||
|
*node = (yp_constant_write_node_t) {
|
||||||
|
{
|
||||||
|
.type = YP_NODE_CONSTANT_WRITE_NODE,
|
||||||
|
.location = {
|
||||||
|
.start = target->base.location.start,
|
||||||
|
.end = value != NULL ? value->location.end : target->base.location.end
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.name_loc = YP_LOCATION_NODE_VALUE((yp_node_t *) target),
|
||||||
|
.operator_loc = YP_OPTIONAL_LOCATION_TOKEN_VALUE(operator),
|
||||||
|
.value = value
|
||||||
|
};
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
// Allocate and initialize a new DefNode node.
|
// Allocate and initialize a new DefNode node.
|
||||||
static yp_def_node_t *
|
static yp_def_node_t *
|
||||||
yp_def_node_create(
|
yp_def_node_create(
|
||||||
@ -7533,8 +7554,9 @@ parse_target(yp_parser_t *parser, yp_node_t *target, yp_token_t *operator, yp_no
|
|||||||
return (yp_node_t *) write_node;
|
return (yp_node_t *) write_node;
|
||||||
}
|
}
|
||||||
case YP_NODE_CONSTANT_PATH_NODE:
|
case YP_NODE_CONSTANT_PATH_NODE:
|
||||||
case YP_NODE_CONSTANT_READ_NODE:
|
|
||||||
return (yp_node_t *) yp_constant_path_write_node_create(parser, target, operator, value);
|
return (yp_node_t *) yp_constant_path_write_node_create(parser, target, operator, value);
|
||||||
|
case YP_NODE_CONSTANT_READ_NODE:
|
||||||
|
return (yp_node_t *) yp_constant_write_node_create(parser, (yp_constant_read_node_t *) target, operator, value);
|
||||||
case YP_NODE_BACK_REFERENCE_READ_NODE:
|
case YP_NODE_BACK_REFERENCE_READ_NODE:
|
||||||
case YP_NODE_NUMBERED_REFERENCE_READ_NODE:
|
case YP_NODE_NUMBERED_REFERENCE_READ_NODE:
|
||||||
yp_diagnostic_list_append(&parser->error_list, target->location.start, target->location.end, "Can't set variable");
|
yp_diagnostic_list_append(&parser->error_list, target->location.start, target->location.end, "Can't set variable");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user