aboutsummaryrefslogtreecommitdiffstats
path: root/yarp/yarp.c
diff options
context:
space:
mode:
Diffstat (limited to 'yarp/yarp.c')
-rw-r--r--yarp/yarp.c681
1 files changed, 571 insertions, 110 deletions
diff --git a/yarp/yarp.c b/yarp/yarp.c
index 012f8136e5..20d5628819 100644
--- a/yarp/yarp.c
+++ b/yarp/yarp.c
@@ -725,27 +725,6 @@ yp_and_node_create(yp_parser_t *parser, yp_node_t *left, const yp_token_t *opera
return node;
}
-// Allocate and initialize a new AndWriteNode.
-static yp_and_write_node_t *
-yp_and_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
- yp_and_write_node_t *node = YP_ALLOC_NODE(parser, yp_and_write_node_t);
-
- *node = (yp_and_write_node_t) {
- {
- .type = YP_NODE_AND_WRITE_NODE,
- .location = {
- .start = target->location.start,
- .end = value->location.end
- },
- },
- .target = target,
- .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
- .value = value
- };
-
- return node;
-}
-
// Allocate an initialize a new arguments node.
static yp_arguments_node_t *
yp_arguments_node_create(yp_parser_t *parser) {
@@ -1575,6 +1554,74 @@ yp_class_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const y
return node;
}
+// Allocate and initialize a new ClassVariableAndWriteNode node.
+static yp_class_variable_and_write_node_t *
+yp_class_variable_and_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+ assert(YP_NODE_TYPE_P(target, YP_NODE_CLASS_VARIABLE_READ_NODE));
+ assert(operator->type == YP_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
+ yp_class_variable_and_write_node_t *node = YP_ALLOC_NODE(parser, yp_class_variable_and_write_node_t);
+
+ *node = (yp_class_variable_and_write_node_t) {
+ {
+ .type = YP_NODE_CLASS_VARIABLE_AND_WRITE_NODE,
+ .location = {
+ .start = target->location.start,
+ .end = value->location.end
+ }
+ },
+ .name_loc = target->location,
+ .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
+ .value = value
+ };
+
+ return node;
+}
+
+// Allocate and initialize a new ClassVariableOperatorWriteNode node.
+static yp_class_variable_operator_write_node_t *
+yp_class_variable_operator_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+ yp_class_variable_operator_write_node_t *node = YP_ALLOC_NODE(parser, yp_class_variable_operator_write_node_t);
+
+ *node = (yp_class_variable_operator_write_node_t) {
+ {
+ .type = YP_NODE_CLASS_VARIABLE_OPERATOR_WRITE_NODE,
+ .location = {
+ .start = target->location.start,
+ .end = value->location.end
+ }
+ },
+ .name_loc = target->location,
+ .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
+ .value = value,
+ .operator = yp_parser_constant_id_location(parser, operator->start, operator->end - 1)
+ };
+
+ return node;
+}
+
+// Allocate and initialize a new ClassVariableOrWriteNode node.
+static yp_class_variable_or_write_node_t *
+yp_class_variable_or_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+ assert(YP_NODE_TYPE_P(target, YP_NODE_CLASS_VARIABLE_READ_NODE));
+ assert(operator->type == YP_TOKEN_PIPE_PIPE_EQUAL);
+ yp_class_variable_or_write_node_t *node = YP_ALLOC_NODE(parser, yp_class_variable_or_write_node_t);
+
+ *node = (yp_class_variable_or_write_node_t) {
+ {
+ .type = YP_NODE_CLASS_VARIABLE_OR_WRITE_NODE,
+ .location = {
+ .start = target->location.start,
+ .end = value->location.end
+ }
+ },
+ .name_loc = target->location,
+ .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
+ .value = value
+ };
+
+ return node;
+}
+
// Allocate and initialize a new ClassVariableReadNode node.
static yp_class_variable_read_node_t *
yp_class_variable_read_node_create(yp_parser_t *parser, const yp_token_t *token) {
@@ -1605,6 +1652,72 @@ yp_class_variable_read_node_to_class_variable_write_node(yp_parser_t *parser, yp
return node;
}
+// Allocate and initialize a new ConstantPathAndWriteNode node.
+static yp_constant_path_and_write_node_t *
+yp_constant_path_and_write_node_create(yp_parser_t *parser, yp_constant_path_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+ assert(operator->type == YP_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
+ yp_constant_path_and_write_node_t *node = YP_ALLOC_NODE(parser, yp_constant_path_and_write_node_t);
+
+ *node = (yp_constant_path_and_write_node_t) {
+ {
+ .type = YP_NODE_CONSTANT_PATH_AND_WRITE_NODE,
+ .location = {
+ .start = target->base.location.start,
+ .end = value->location.end
+ }
+ },
+ .target = target,
+ .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
+ .value = value
+ };
+
+ return node;
+}
+
+// Allocate and initialize a new ConstantPathOperatorWriteNode node.
+static yp_constant_path_operator_write_node_t *
+yp_constant_path_operator_write_node_create(yp_parser_t *parser, yp_constant_path_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+ yp_constant_path_operator_write_node_t *node = YP_ALLOC_NODE(parser, yp_constant_path_operator_write_node_t);
+
+ *node = (yp_constant_path_operator_write_node_t) {
+ {
+ .type = YP_NODE_CONSTANT_PATH_OPERATOR_WRITE_NODE,
+ .location = {
+ .start = target->base.location.start,
+ .end = value->location.end
+ }
+ },
+ .target = target,
+ .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
+ .value = value,
+ .operator = yp_parser_constant_id_location(parser, operator->start, operator->end - 1)
+ };
+
+ return node;
+}
+
+// Allocate and initialize a new ConstantPathOrWriteNode node.
+static yp_constant_path_or_write_node_t *
+yp_constant_path_or_write_node_create(yp_parser_t *parser, yp_constant_path_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+ assert(operator->type == YP_TOKEN_PIPE_PIPE_EQUAL);
+ yp_constant_path_or_write_node_t *node = YP_ALLOC_NODE(parser, yp_constant_path_or_write_node_t);
+
+ *node = (yp_constant_path_or_write_node_t) {
+ {
+ .type = YP_NODE_CONSTANT_PATH_OR_WRITE_NODE,
+ .location = {
+ .start = target->base.location.start,
+ .end = value->location.end
+ }
+ },
+ .target = target,
+ .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
+ .value = value
+ };
+
+ return node;
+}
+
// Allocate and initialize a new ConstantPathNode node.
static yp_constant_path_node_t *
yp_constant_path_node_create(yp_parser_t *parser, yp_node_t *parent, const yp_token_t *delimiter, yp_node_t *child) {
@@ -1647,6 +1760,74 @@ yp_constant_path_write_node_create(yp_parser_t *parser, yp_constant_path_node_t
return node;
}
+// Allocate and initialize a new ConstantAndWriteNode node.
+static yp_constant_and_write_node_t *
+yp_constant_and_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+ assert(YP_NODE_TYPE_P(target, YP_NODE_CONSTANT_READ_NODE));
+ assert(operator->type == YP_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
+ yp_constant_and_write_node_t *node = YP_ALLOC_NODE(parser, yp_constant_and_write_node_t);
+
+ *node = (yp_constant_and_write_node_t) {
+ {
+ .type = YP_NODE_CONSTANT_AND_WRITE_NODE,
+ .location = {
+ .start = target->location.start,
+ .end = value->location.end
+ }
+ },
+ .name_loc = target->location,
+ .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
+ .value = value
+ };
+
+ return node;
+}
+
+// Allocate and initialize a new ConstantOperatorWriteNode node.
+static yp_constant_operator_write_node_t *
+yp_constant_operator_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+ yp_constant_operator_write_node_t *node = YP_ALLOC_NODE(parser, yp_constant_operator_write_node_t);
+
+ *node = (yp_constant_operator_write_node_t) {
+ {
+ .type = YP_NODE_CONSTANT_OPERATOR_WRITE_NODE,
+ .location = {
+ .start = target->location.start,
+ .end = value->location.end
+ }
+ },
+ .name_loc = target->location,
+ .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
+ .value = value,
+ .operator = yp_parser_constant_id_location(parser, operator->start, operator->end - 1)
+ };
+
+ return node;
+}
+
+// Allocate and initialize a new ConstantOrWriteNode node.
+static yp_constant_or_write_node_t *
+yp_constant_or_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+ assert(YP_NODE_TYPE_P(target, YP_NODE_CONSTANT_READ_NODE));
+ assert(operator->type == YP_TOKEN_PIPE_PIPE_EQUAL);
+ yp_constant_or_write_node_t *node = YP_ALLOC_NODE(parser, yp_constant_or_write_node_t);
+
+ *node = (yp_constant_or_write_node_t) {
+ {
+ .type = YP_NODE_CONSTANT_OR_WRITE_NODE,
+ .location = {
+ .start = target->location.start,
+ .end = value->location.end
+ }
+ },
+ .name_loc = target->location,
+ .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
+ .value = value
+ };
+
+ return node;
+}
+
// Allocate and initialize a new ConstantReadNode node.
static yp_constant_read_node_t *
yp_constant_read_node_create(yp_parser_t *parser, const yp_token_t *name) {
@@ -2081,6 +2262,74 @@ yp_hash_pattern_node_node_list_create(yp_parser_t *parser, yp_node_list_t *assoc
return node;
}
+// Allocate and initialize a new GlobalVariableAndWriteNode node.
+static yp_global_variable_and_write_node_t *
+yp_global_variable_and_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+ assert(YP_NODE_TYPE_P(target, YP_NODE_GLOBAL_VARIABLE_READ_NODE) || YP_NODE_TYPE_P(target, YP_NODE_BACK_REFERENCE_READ_NODE) || YP_NODE_TYPE_P(target, YP_NODE_NUMBERED_REFERENCE_READ_NODE));
+ assert(operator->type == YP_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
+ yp_global_variable_and_write_node_t *node = YP_ALLOC_NODE(parser, yp_global_variable_and_write_node_t);
+
+ *node = (yp_global_variable_and_write_node_t) {
+ {
+ .type = YP_NODE_GLOBAL_VARIABLE_AND_WRITE_NODE,
+ .location = {
+ .start = target->location.start,
+ .end = value->location.end
+ }
+ },
+ .name_loc = target->location,
+ .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
+ .value = value
+ };
+
+ return node;
+}
+
+// Allocate and initialize a new GlobalVariableOperatorWriteNode node.
+static yp_global_variable_operator_write_node_t *
+yp_global_variable_operator_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+ yp_global_variable_operator_write_node_t *node = YP_ALLOC_NODE(parser, yp_global_variable_operator_write_node_t);
+
+ *node = (yp_global_variable_operator_write_node_t) {
+ {
+ .type = YP_NODE_GLOBAL_VARIABLE_OPERATOR_WRITE_NODE,
+ .location = {
+ .start = target->location.start,
+ .end = value->location.end
+ }
+ },
+ .name_loc = target->location,
+ .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
+ .value = value,
+ .operator = yp_parser_constant_id_location(parser, operator->start, operator->end - 1)
+ };
+
+ return node;
+}
+
+// Allocate and initialize a new GlobalVariableOrWriteNode node.
+static yp_global_variable_or_write_node_t *
+yp_global_variable_or_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+ assert(YP_NODE_TYPE_P(target, YP_NODE_GLOBAL_VARIABLE_READ_NODE) || YP_NODE_TYPE_P(target, YP_NODE_BACK_REFERENCE_READ_NODE) || YP_NODE_TYPE_P(target, YP_NODE_NUMBERED_REFERENCE_READ_NODE));
+ assert(operator->type == YP_TOKEN_PIPE_PIPE_EQUAL);
+ yp_global_variable_or_write_node_t *node = YP_ALLOC_NODE(parser, yp_global_variable_or_write_node_t);
+
+ *node = (yp_global_variable_or_write_node_t) {
+ {
+ .type = YP_NODE_GLOBAL_VARIABLE_OR_WRITE_NODE,
+ .location = {
+ .start = target->location.start,
+ .end = value->location.end
+ }
+ },
+ .name_loc = target->location,
+ .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
+ .value = value
+ };
+
+ return node;
+}
+
// Allocate a new GlobalVariableReadNode node.
static yp_global_variable_read_node_t *
yp_global_variable_read_node_create(yp_parser_t *parser, const yp_token_t *name) {
@@ -2371,6 +2620,74 @@ yp_in_node_create(yp_parser_t *parser, yp_node_t *pattern, yp_statements_node_t
return node;
}
+// Allocate and initialize a new InstanceVariableAndWriteNode node.
+static yp_instance_variable_and_write_node_t *
+yp_instance_variable_and_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+ assert(YP_NODE_TYPE_P(target, YP_NODE_INSTANCE_VARIABLE_READ_NODE));
+ assert(operator->type == YP_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
+ yp_instance_variable_and_write_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_and_write_node_t);
+
+ *node = (yp_instance_variable_and_write_node_t) {
+ {
+ .type = YP_NODE_INSTANCE_VARIABLE_AND_WRITE_NODE,
+ .location = {
+ .start = target->location.start,
+ .end = value->location.end
+ }
+ },
+ .name_loc = target->location,
+ .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
+ .value = value
+ };
+
+ return node;
+}
+
+// Allocate and initialize a new InstanceVariableOperatorWriteNode node.
+static yp_instance_variable_operator_write_node_t *
+yp_instance_variable_operator_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+ yp_instance_variable_operator_write_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_operator_write_node_t);
+
+ *node = (yp_instance_variable_operator_write_node_t) {
+ {
+ .type = YP_NODE_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE,
+ .location = {
+ .start = target->location.start,
+ .end = value->location.end
+ }
+ },
+ .name_loc = target->location,
+ .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
+ .value = value,
+ .operator = yp_parser_constant_id_location(parser, operator->start, operator->end - 1)
+ };
+
+ return node;
+}
+
+// Allocate and initialize a new InstanceVariableOrWriteNode node.
+static yp_instance_variable_or_write_node_t *
+yp_instance_variable_or_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+ assert(YP_NODE_TYPE_P(target, YP_NODE_INSTANCE_VARIABLE_READ_NODE));
+ assert(operator->type == YP_TOKEN_PIPE_PIPE_EQUAL);
+ yp_instance_variable_or_write_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_or_write_node_t);
+
+ *node = (yp_instance_variable_or_write_node_t) {
+ {
+ .type = YP_NODE_INSTANCE_VARIABLE_OR_WRITE_NODE,
+ .location = {
+ .start = target->location.start,
+ .end = value->location.end
+ }
+ },
+ .name_loc = target->location,
+ .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
+ .value = value
+ };
+
+ return node;
+}
+
// Allocate and initialize a new InstanceVariableReadNode node.
static yp_instance_variable_read_node_t *
yp_instance_variable_read_node_create(yp_parser_t *parser, const yp_token_t *token) {
@@ -2644,6 +2961,80 @@ yp_lambda_node_create(
return node;
}
+// Allocate and initialize a new LocalVariableAndWriteNode node.
+static yp_local_variable_and_write_node_t *
+yp_local_variable_and_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value, yp_constant_id_t constant_id, uint32_t depth) {
+ assert(YP_NODE_TYPE_P(target, YP_NODE_LOCAL_VARIABLE_READ_NODE) || YP_NODE_TYPE_P(target, YP_NODE_CALL_NODE));
+ assert(operator->type == YP_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
+ yp_local_variable_and_write_node_t *node = YP_ALLOC_NODE(parser, yp_local_variable_and_write_node_t);
+
+ *node = (yp_local_variable_and_write_node_t) {
+ {
+ .type = YP_NODE_LOCAL_VARIABLE_AND_WRITE_NODE,
+ .location = {
+ .start = target->location.start,
+ .end = value->location.end
+ }
+ },
+ .name_loc = target->location,
+ .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
+ .value = value,
+ .constant_id = constant_id,
+ .depth = depth
+ };
+
+ return node;
+}
+
+// Allocate and initialize a new LocalVariableOperatorWriteNode node.
+static yp_local_variable_operator_write_node_t *
+yp_local_variable_operator_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value, yp_constant_id_t constant_id, uint32_t depth) {
+ yp_local_variable_operator_write_node_t *node = YP_ALLOC_NODE(parser, yp_local_variable_operator_write_node_t);
+
+ *node = (yp_local_variable_operator_write_node_t) {
+ {
+ .type = YP_NODE_LOCAL_VARIABLE_OPERATOR_WRITE_NODE,
+ .location = {
+ .start = target->location.start,
+ .end = value->location.end
+ }
+ },
+ .name_loc = target->location,
+ .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
+ .value = value,
+ .constant_id = constant_id,
+ .operator_id = yp_parser_constant_id_location(parser, operator->start, operator->end - 1),
+ .depth = depth
+ };
+
+ return node;
+}
+
+// Allocate and initialize a new LocalVariableOrWriteNode node.
+static yp_local_variable_or_write_node_t *
+yp_local_variable_or_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value, yp_constant_id_t constant_id, uint32_t depth) {
+ assert(YP_NODE_TYPE_P(target, YP_NODE_LOCAL_VARIABLE_READ_NODE) || YP_NODE_TYPE_P(target, YP_NODE_CALL_NODE));
+ assert(operator->type == YP_TOKEN_PIPE_PIPE_EQUAL);
+ yp_local_variable_or_write_node_t *node = YP_ALLOC_NODE(parser, yp_local_variable_or_write_node_t);
+
+ *node = (yp_local_variable_or_write_node_t) {
+ {
+ .type = YP_NODE_LOCAL_VARIABLE_OR_WRITE_NODE,
+ .location = {
+ .start = target->location.start,
+ .end = value->location.end
+ }
+ },
+ .name_loc = target->location,
+ .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
+ .value = value,
+ .constant_id = constant_id,
+ .depth = depth
+ };
+
+ return node;
+}
+
// Allocate a new LocalVariableReadNode node.
static yp_local_variable_read_node_t *
yp_local_variable_read_node_create(yp_parser_t *parser, const yp_token_t *name, uint32_t depth) {
@@ -2879,28 +3270,6 @@ yp_numbered_reference_read_node_create(yp_parser_t *parser, const yp_token_t *na
return node;
}
-// Allocate and initialize a new OperatorWriteNode.
-static yp_operator_write_node_t *
-yp_operator_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
- yp_operator_write_node_t *node = YP_ALLOC_NODE(parser, yp_operator_write_node_t);
-
- *node = (yp_operator_write_node_t) {
- {
- .type = YP_NODE_OPERATOR_WRITE_NODE,
- .location = {
- .start = target->location.start,
- .end = value->location.end
- },
- },
- .target = target,
- .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
- .operator = yp_parser_constant_id_location(parser, operator->start, operator->end - 1),
- .value = value
- };
-
- return node;
-}
-
// Allocate a new OptionalParameterNode node.
static yp_optional_parameter_node_t *
yp_optional_parameter_node_create(yp_parser_t *parser, const yp_token_t *name, const yp_token_t *operator, yp_node_t *value) {
@@ -2944,27 +3313,6 @@ yp_or_node_create(yp_parser_t *parser, yp_node_t *left, const yp_token_t *operat
return node;
}
-// Allocate and initialize a new OrWriteNode.
-static yp_or_write_node_t *
-yp_or_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
- yp_or_write_node_t *node = YP_ALLOC_NODE(parser, yp_or_write_node_t);
-
- *node = (yp_or_write_node_t) {
- {
- .type = YP_NODE_OR_WRITE_NODE,
- .location = {
- .start = target->location.start,
- .end = value->location.end
- },
- },
- .target = target,
- .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
- .value = value
- };
-
- return node;
-}
-
// Allocate and initialize a new ParametersNode node.
static yp_parameters_node_t *
yp_parameters_node_create(yp_parser_t *parser) {
@@ -4074,13 +4422,15 @@ yp_parser_local_depth(yp_parser_t *parser, yp_token_t *token) {
}
// Add a local variable from a location to the current scope.
-static void
+static yp_constant_id_t
yp_parser_local_add_location(yp_parser_t *parser, const char *start, const char *end) {
yp_constant_id_t constant_id = yp_parser_constant_id_location(parser, start, end);
if (!yp_constant_id_list_includes(&parser->current_scope->locals, constant_id)) {
yp_constant_id_list_append(&parser->current_scope->locals, constant_id);
}
+
+ return constant_id;
}
// Add a local variable from a token to the current scope.
@@ -12259,19 +12609,57 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
case YP_NODE_NUMBERED_REFERENCE_READ_NODE:
yp_diagnostic_list_append(&parser->error_list, node->location.start, node->location.end, "Can't set variable");
/* fallthrough */
- case YP_NODE_CLASS_VARIABLE_READ_NODE:
- case YP_NODE_CONSTANT_PATH_NODE:
- case YP_NODE_CONSTANT_READ_NODE:
- case YP_NODE_GLOBAL_VARIABLE_READ_NODE:
- case YP_NODE_INSTANCE_VARIABLE_READ_NODE:
- case YP_NODE_LOCAL_VARIABLE_READ_NODE: {
+ case YP_NODE_GLOBAL_VARIABLE_READ_NODE: {
parser_lex(parser);
- yp_token_t operator = not_provided(parser);
- node = parse_target(parser, node, &operator, NULL);
+ yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after &&=");
+ yp_node_t *result = (yp_node_t *) yp_global_variable_and_write_node_create(parser, node, &token, value);
+
+ yp_node_destroy(parser, node);
+ return result;
+ }
+ case YP_NODE_CLASS_VARIABLE_READ_NODE: {
+ parser_lex(parser);
+
+ yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after &&=");
+ yp_node_t *result = (yp_node_t *) yp_class_variable_and_write_node_create(parser, node, &token, value);
+
+ yp_node_destroy(parser, node);
+ return result;
+ }
+ case YP_NODE_CONSTANT_PATH_NODE: {
+ parser_lex(parser);
+
+ yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after &&=");
+ return (yp_node_t *) yp_constant_path_and_write_node_create(parser, (yp_constant_path_node_t *) node, &token, value);
+ }
+ case YP_NODE_CONSTANT_READ_NODE: {
+ parser_lex(parser);
+
+ yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after &&=");
+ yp_node_t *result = (yp_node_t *) yp_constant_and_write_node_create(parser, node, &token, value);
+
+ yp_node_destroy(parser, node);
+ return result;
+ }
+ case YP_NODE_INSTANCE_VARIABLE_READ_NODE: {
+ parser_lex(parser);
+
+ yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after &&=");
+ yp_node_t *result = (yp_node_t *) yp_instance_variable_and_write_node_create(parser, node, &token, value);
+
+ yp_node_destroy(parser, node);
+ return result;
+ }
+ case YP_NODE_LOCAL_VARIABLE_READ_NODE: {
+ yp_local_variable_read_node_t *cast = (yp_local_variable_read_node_t *) node;
+ parser_lex(parser);
yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after &&=");
- return (yp_node_t *) yp_and_write_node_create(parser, node, &token, value);
+ yp_node_t *result = (yp_node_t *) yp_local_variable_and_write_node_create(parser, node, &token, value, cast->constant_id, cast->depth);
+
+ yp_node_destroy(parser, node);
+ return result;
}
case YP_NODE_CALL_NODE: {
yp_call_node_t *call_node = (yp_call_node_t *) node;
@@ -12281,19 +12669,18 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
// will transform it into a local variable write.
if (yp_call_node_variable_call_p(call_node)) {
yp_location_t message_loc = call_node->message_loc;
- yp_parser_local_add_location(parser, message_loc.start, message_loc.end);
+ yp_constant_id_t constant_id = yp_parser_local_add_location(parser, message_loc.start, message_loc.end);
if (token_is_numbered_parameter(message_loc.start, message_loc.end)) {
yp_diagnostic_list_append(&parser->error_list, message_loc.start, message_loc.end, "reserved for numbered parameter");
}
parser_lex(parser);
-
- yp_token_t operator = not_provided(parser);
- node = parse_target(parser, node, &operator, NULL);
-
yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after &&=");
- return (yp_node_t *) yp_and_write_node_create(parser, node, &token, value);
+ yp_node_t *result = (yp_node_t *) yp_local_variable_and_write_node_create(parser, node, &token, value, constant_id, 0);
+
+ yp_node_destroy(parser, node);
+ return result;
}
parser_lex(parser);
@@ -12325,19 +12712,57 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
case YP_NODE_NUMBERED_REFERENCE_READ_NODE:
yp_diagnostic_list_append(&parser->error_list, node->location.start, node->location.end, "Can't set variable");
/* fallthrough */
- case YP_NODE_CLASS_VARIABLE_READ_NODE:
- case YP_NODE_CONSTANT_PATH_NODE:
- case YP_NODE_CONSTANT_READ_NODE:
- case YP_NODE_GLOBAL_VARIABLE_READ_NODE:
- case YP_NODE_INSTANCE_VARIABLE_READ_NODE:
- case YP_NODE_LOCAL_VARIABLE_READ_NODE: {
+ case YP_NODE_GLOBAL_VARIABLE_READ_NODE: {
parser_lex(parser);
- yp_token_t operator = not_provided(parser);
- node = parse_target(parser, node, &operator, NULL);
+ yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after ||=");
+ yp_node_t *result = (yp_node_t *) yp_global_variable_or_write_node_create(parser, node, &token, value);
+
+ yp_node_destroy(parser, node);
+ return result;
+ }
+ case YP_NODE_CLASS_VARIABLE_READ_NODE: {
+ parser_lex(parser);
+
+ yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after ||=");
+ yp_node_t *result = (yp_node_t *) yp_class_variable_or_write_node_create(parser, node, &token, value);
+
+ yp_node_destroy(parser, node);
+ return result;
+ }
+ case YP_NODE_CONSTANT_PATH_NODE: {
+ parser_lex(parser);
+
+ yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after ||=");
+ return (yp_node_t *) yp_constant_path_or_write_node_create(parser, (yp_constant_path_node_t *) node, &token, value);
+ }
+ case YP_NODE_CONSTANT_READ_NODE: {
+ parser_lex(parser);
+
+ yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after ||=");
+ yp_node_t *result = (yp_node_t *) yp_constant_or_write_node_create(parser, node, &token, value);
+
+ yp_node_destroy(parser, node);
+ return result;
+ }
+ case YP_NODE_INSTANCE_VARIABLE_READ_NODE: {
+ parser_lex(parser);
+
+ yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after ||=");
+ yp_node_t *result = (yp_node_t *) yp_instance_variable_or_write_node_create(parser, node, &token, value);
+
+ yp_node_destroy(parser, node);
+ return result;
+ }
+ case YP_NODE_LOCAL_VARIABLE_READ_NODE: {
+ yp_local_variable_read_node_t *cast = (yp_local_variable_read_node_t *) node;
+ parser_lex(parser);
yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after ||=");
- return (yp_node_t *) yp_or_write_node_create(parser, node, &token, value);
+ yp_node_t *result = (yp_node_t *) yp_local_variable_or_write_node_create(parser, node, &token, value, cast->constant_id, cast->depth);
+
+ yp_node_destroy(parser, node);
+ return result;
}
case YP_NODE_CALL_NODE: {
yp_call_node_t *call_node = (yp_call_node_t *) node;
@@ -12347,19 +12772,18 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
// will transform it into a local variable write.
if (yp_call_node_variable_call_p(call_node)) {
yp_location_t message_loc = call_node->message_loc;
- yp_parser_local_add_location(parser, message_loc.start, message_loc.end);
+ yp_constant_id_t constant_id = yp_parser_local_add_location(parser, message_loc.start, message_loc.end);
if (token_is_numbered_parameter(message_loc.start, message_loc.end)) {
yp_diagnostic_list_append(&parser->error_list, message_loc.start, message_loc.end, "reserved for numbered parameter");
}
parser_lex(parser);
-
- yp_token_t operator = not_provided(parser);
- node = parse_target(parser, node, &operator, NULL);
-
yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after ||=");
- return (yp_node_t *) yp_or_write_node_create(parser, node, &token, value);
+ yp_node_t *result = (yp_node_t *) yp_local_variable_or_write_node_create(parser, node, &token, value, constant_id, 0);
+
+ yp_node_destroy(parser, node);
+ return result;
}
parser_lex(parser);
@@ -12401,19 +12825,57 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
case YP_NODE_NUMBERED_REFERENCE_READ_NODE:
yp_diagnostic_list_append(&parser->error_list, node->location.start, node->location.end, "Can't set variable");
/* fallthrough */
- case YP_NODE_CLASS_VARIABLE_READ_NODE:
- case YP_NODE_CONSTANT_PATH_NODE:
- case YP_NODE_CONSTANT_READ_NODE:
- case YP_NODE_GLOBAL_VARIABLE_READ_NODE:
- case YP_NODE_INSTANCE_VARIABLE_READ_NODE:
+ case YP_NODE_GLOBAL_VARIABLE_READ_NODE: {
+ parser_lex(parser);
+
+ yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after the operator.");
+ yp_node_t *result = (yp_node_t *) yp_global_variable_operator_write_node_create(parser, node, &token, value);
+
+ yp_node_destroy(parser, node);
+ return result;
+ }
+ case YP_NODE_CLASS_VARIABLE_READ_NODE: {
+ parser_lex(parser);
+
+ yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after the operator.");
+ yp_node_t *result = (yp_node_t *) yp_class_variable_operator_write_node_create(parser, node, &token, value);
+
+ yp_node_destroy(parser, node);
+ return result;
+ }
+ case YP_NODE_CONSTANT_PATH_NODE: {
+ parser_lex(parser);
+
+ yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after the operator.");
+ return (yp_node_t *) yp_constant_path_operator_write_node_create(parser, (yp_constant_path_node_t *) node, &token, value);
+ }
+ case YP_NODE_CONSTANT_READ_NODE: {
+ parser_lex(parser);
+
+ yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after the operator.");
+ yp_node_t *result = (yp_node_t *) yp_constant_operator_write_node_create(parser, node, &token, value);
+
+ yp_node_destroy(parser, node);
+ return result;
+ }
+ case YP_NODE_INSTANCE_VARIABLE_READ_NODE: {
+ parser_lex(parser);
+
+ yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after the operator.");
+ yp_node_t *result = (yp_node_t *) yp_instance_variable_operator_write_node_create(parser, node, &token, value);
+
+ yp_node_destroy(parser, node);
+ return result;
+ }
case YP_NODE_LOCAL_VARIABLE_READ_NODE: {
+ yp_local_variable_read_node_t *cast = (yp_local_variable_read_node_t *) node;
parser_lex(parser);
- yp_token_t operator = not_provided(parser);
- node = parse_target(parser, node, &operator, NULL);
+ yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after the operator.");
+ yp_node_t *result = (yp_node_t *) yp_local_variable_operator_write_node_create(parser, node, &token, value, cast->constant_id, cast->depth);
- yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after the operator");
- return (yp_node_t *) yp_operator_write_node_create(parser, node, &token, value);
+ yp_node_destroy(parser, node);
+ return result;
}
case YP_NODE_CALL_NODE: {
yp_call_node_t *call_node = (yp_call_node_t *) node;
@@ -12423,19 +12885,18 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
// will transform it into a local variable write.
if (yp_call_node_variable_call_p(call_node)) {
yp_location_t message_loc = call_node->message_loc;
- yp_parser_local_add_location(parser, message_loc.start, message_loc.end);
+ yp_constant_id_t constant_id = yp_parser_local_add_location(parser, message_loc.start, message_loc.end);
if (token_is_numbered_parameter(message_loc.start, message_loc.end)) {
yp_diagnostic_list_append(&parser->error_list, message_loc.start, message_loc.end, "reserved for numbered parameter");
}
parser_lex(parser);
+ yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after the operator.");
+ yp_node_t *result = (yp_node_t *) yp_local_variable_operator_write_node_create(parser, node, &token, value, constant_id, 0);
- yp_token_t operator = not_provided(parser);
- node = parse_target(parser, node, &operator, NULL);
-
- yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after &&=");
- return (yp_node_t *) yp_operator_write_node_create(parser, node, &token, value);
+ yp_node_destroy(parser, node);
+ return result;
}
yp_token_t operator = not_provided(parser);