ruby/yarp/prettyprint.c

1699 строки
108 KiB
C

/******************************************************************************/
/* This file is generated by the bin/template script and should not be */
/* modified manually. See */
/* templates/src/prettyprint.c.erb */
/* if you are looking to modify the */
/* template */
/******************************************************************************/
#include "yarp/defines.h"
#include <stdio.h>
#include "yarp/ast.h"
#include "yarp/parser.h"
#include "yarp/util/yp_buffer.h"
static void
prettyprint_location(yp_buffer_t *buffer, yp_parser_t *parser, yp_location_t *location) {
char printed[] = "[0000-0000]";
yp_snprintf(printed, sizeof(printed), "[%04ld-%04ld]", (long int)(location->start - parser->start), (long int)(location->end - parser->start));
yp_buffer_append_str(buffer, printed, strlen(printed));
}
static void
prettyprint_node(yp_buffer_t *buffer, yp_parser_t *parser, yp_node_t *node) {
switch (node->type) {
case YP_NODE_ALIAS_NODE: {
yp_buffer_append_str(buffer, "AliasNode(", 10);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_alias_node_t *)node)->new_name);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_alias_node_t *)node)->old_name);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_alias_node_t *)node)->keyword_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_ALTERNATION_PATTERN_NODE: {
yp_buffer_append_str(buffer, "AlternationPatternNode(", 23);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_alternation_pattern_node_t *)node)->left);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_alternation_pattern_node_t *)node)->right);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_alternation_pattern_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_AND_NODE: {
yp_buffer_append_str(buffer, "AndNode(", 8);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_and_node_t *)node)->left);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_and_node_t *)node)->right);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_and_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_ARGUMENTS_NODE: {
yp_buffer_append_str(buffer, "ArgumentsNode(", 14);
for (uint32_t index = 0; index < ((yp_arguments_node_t *)node)->arguments.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_arguments_node_t *) node)->arguments.nodes[index]);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_ARRAY_NODE: {
yp_buffer_append_str(buffer, "ArrayNode(", 10);
for (uint32_t index = 0; index < ((yp_array_node_t *)node)->elements.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_array_node_t *) node)->elements.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_array_node_t *)node)->opening_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_array_node_t *)node)->opening_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_array_node_t *)node)->closing_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_array_node_t *)node)->closing_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_ARRAY_PATTERN_NODE: {
yp_buffer_append_str(buffer, "ArrayPatternNode(", 17);
if (((yp_array_pattern_node_t *)node)->constant == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_array_pattern_node_t *)node)->constant);
}
yp_buffer_append_str(buffer, ", ", 2); for (uint32_t index = 0; index < ((yp_array_pattern_node_t *)node)->requireds.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_array_pattern_node_t *) node)->requireds.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_array_pattern_node_t *)node)->rest == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_array_pattern_node_t *)node)->rest);
}
yp_buffer_append_str(buffer, ", ", 2); for (uint32_t index = 0; index < ((yp_array_pattern_node_t *)node)->posts.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_array_pattern_node_t *) node)->posts.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_array_pattern_node_t *)node)->opening_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_array_pattern_node_t *)node)->opening_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_array_pattern_node_t *)node)->closing_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_array_pattern_node_t *)node)->closing_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_ASSOC_NODE: {
yp_buffer_append_str(buffer, "AssocNode(", 10);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_assoc_node_t *)node)->key);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_assoc_node_t *)node)->value == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_assoc_node_t *)node)->value);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_assoc_node_t *)node)->operator_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_assoc_node_t *)node)->operator_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_ASSOC_SPLAT_NODE: {
yp_buffer_append_str(buffer, "AssocSplatNode(", 15);
if (((yp_assoc_splat_node_t *)node)->value == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_assoc_splat_node_t *)node)->value);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_assoc_splat_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_BACK_REFERENCE_READ_NODE: {
yp_buffer_append_str(buffer, "BackReferenceReadNode(", 22);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_BEGIN_NODE: {
yp_buffer_append_str(buffer, "BeginNode(", 10);
if (((yp_begin_node_t *)node)->begin_keyword_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_begin_node_t *)node)->begin_keyword_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_begin_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_begin_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_begin_node_t *)node)->rescue_clause == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_begin_node_t *)node)->rescue_clause);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_begin_node_t *)node)->else_clause == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_begin_node_t *)node)->else_clause);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_begin_node_t *)node)->ensure_clause == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_begin_node_t *)node)->ensure_clause);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_begin_node_t *)node)->end_keyword_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_begin_node_t *)node)->end_keyword_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_BLOCK_ARGUMENT_NODE: {
yp_buffer_append_str(buffer, "BlockArgumentNode(", 18);
if (((yp_block_argument_node_t *)node)->expression == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_block_argument_node_t *)node)->expression);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_block_argument_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_BLOCK_NODE: {
yp_buffer_append_str(buffer, "BlockNode(", 10);
for (uint32_t index = 0; index < ((yp_block_node_t *)node)->locals.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
char locals_buffer[12];
yp_snprintf(locals_buffer, sizeof(locals_buffer), "%u", ((yp_block_node_t *)node)->locals.ids[index]);
yp_buffer_append_str(buffer, locals_buffer, strlen(locals_buffer));
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_block_node_t *)node)->parameters == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_block_node_t *)node)->parameters);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_block_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_block_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_block_node_t *)node)->opening_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_block_node_t *)node)->closing_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_BLOCK_PARAMETER_NODE: {
yp_buffer_append_str(buffer, "BlockParameterNode(", 19);
if (((yp_block_parameter_node_t *)node)->name_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_block_parameter_node_t *)node)->name_loc);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_block_parameter_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_BLOCK_PARAMETERS_NODE: {
yp_buffer_append_str(buffer, "BlockParametersNode(", 20);
if (((yp_block_parameters_node_t *)node)->parameters == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_block_parameters_node_t *)node)->parameters);
}
yp_buffer_append_str(buffer, ", ", 2); for (uint32_t index = 0; index < ((yp_block_parameters_node_t *)node)->locals.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_location(buffer, parser, &((yp_block_parameters_node_t *)node)->locals.locations[index]);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_block_parameters_node_t *)node)->opening_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_block_parameters_node_t *)node)->opening_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_block_parameters_node_t *)node)->closing_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_block_parameters_node_t *)node)->closing_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_BREAK_NODE: {
yp_buffer_append_str(buffer, "BreakNode(", 10);
if (((yp_break_node_t *)node)->arguments == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_break_node_t *)node)->arguments);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_break_node_t *)node)->keyword_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CALL_NODE: {
yp_buffer_append_str(buffer, "CallNode(", 9);
if (((yp_call_node_t *)node)->receiver == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_call_node_t *)node)->receiver);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_call_node_t *)node)->operator_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_call_node_t *)node)->operator_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_call_node_t *)node)->message_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_call_node_t *)node)->message_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_call_node_t *)node)->opening_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_call_node_t *)node)->opening_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_call_node_t *)node)->arguments == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_call_node_t *)node)->arguments);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_call_node_t *)node)->closing_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_call_node_t *)node)->closing_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_call_node_t *)node)->block == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_call_node_t *)node)->block);
}
yp_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
yp_snprintf(flags_buffer, sizeof(flags_buffer), "+%d", ((yp_call_node_t *)node)->flags);
yp_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
yp_buffer_append_str(buffer, ", ", 2); yp_buffer_append_str(buffer, "\"", 1);
yp_buffer_append_str(buffer, yp_string_source(&((yp_call_node_t *)node)->name), yp_string_length(&((yp_call_node_t *)node)->name));
yp_buffer_append_str(buffer, "\"", 1);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CALL_OPERATOR_AND_WRITE_NODE: {
yp_buffer_append_str(buffer, "CallOperatorAndWriteNode(", 25);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_call_operator_and_write_node_t *)node)->target);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_call_operator_and_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_call_operator_and_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CALL_OPERATOR_OR_WRITE_NODE: {
yp_buffer_append_str(buffer, "CallOperatorOrWriteNode(", 24);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_call_operator_or_write_node_t *)node)->target);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_call_operator_or_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_call_operator_or_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CALL_OPERATOR_WRITE_NODE: {
yp_buffer_append_str(buffer, "CallOperatorWriteNode(", 22);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_call_operator_write_node_t *)node)->target);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_call_operator_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_call_operator_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ", ", 2); char operator_id_buffer[12];
yp_snprintf(operator_id_buffer, sizeof(operator_id_buffer), "%u", ((yp_call_operator_write_node_t *)node)->operator_id);
yp_buffer_append_str(buffer, operator_id_buffer, strlen(operator_id_buffer));
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CAPTURE_PATTERN_NODE: {
yp_buffer_append_str(buffer, "CapturePatternNode(", 19);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_capture_pattern_node_t *)node)->value);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_capture_pattern_node_t *)node)->target);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_capture_pattern_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CASE_NODE: {
yp_buffer_append_str(buffer, "CaseNode(", 9);
if (((yp_case_node_t *)node)->predicate == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_case_node_t *)node)->predicate);
}
yp_buffer_append_str(buffer, ", ", 2); for (uint32_t index = 0; index < ((yp_case_node_t *)node)->conditions.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_case_node_t *) node)->conditions.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_case_node_t *)node)->consequent == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_case_node_t *)node)->consequent);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_case_node_t *)node)->case_keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_case_node_t *)node)->end_keyword_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CLASS_NODE: {
yp_buffer_append_str(buffer, "ClassNode(", 10);
for (uint32_t index = 0; index < ((yp_class_node_t *)node)->locals.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
char locals_buffer[12];
yp_snprintf(locals_buffer, sizeof(locals_buffer), "%u", ((yp_class_node_t *)node)->locals.ids[index]);
yp_buffer_append_str(buffer, locals_buffer, strlen(locals_buffer));
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_class_node_t *)node)->class_keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_class_node_t *)node)->constant_path);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_class_node_t *)node)->inheritance_operator_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_class_node_t *)node)->inheritance_operator_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_class_node_t *)node)->superclass == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_class_node_t *)node)->superclass);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_class_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_class_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_class_node_t *)node)->end_keyword_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CLASS_VARIABLE_OPERATOR_AND_WRITE_NODE: {
yp_buffer_append_str(buffer, "ClassVariableOperatorAndWriteNode(", 34);
prettyprint_location(buffer, parser, &((yp_class_variable_operator_and_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_class_variable_operator_and_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_class_variable_operator_and_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CLASS_VARIABLE_OPERATOR_OR_WRITE_NODE: {
yp_buffer_append_str(buffer, "ClassVariableOperatorOrWriteNode(", 33);
prettyprint_location(buffer, parser, &((yp_class_variable_operator_or_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_class_variable_operator_or_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_class_variable_operator_or_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CLASS_VARIABLE_OPERATOR_WRITE_NODE: {
yp_buffer_append_str(buffer, "ClassVariableOperatorWriteNode(", 31);
prettyprint_location(buffer, parser, &((yp_class_variable_operator_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_class_variable_operator_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_class_variable_operator_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ", ", 2); char operator_buffer[12];
yp_snprintf(operator_buffer, sizeof(operator_buffer), "%u", ((yp_class_variable_operator_write_node_t *)node)->operator);
yp_buffer_append_str(buffer, operator_buffer, strlen(operator_buffer));
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CLASS_VARIABLE_READ_NODE: {
yp_buffer_append_str(buffer, "ClassVariableReadNode(", 22);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CLASS_VARIABLE_WRITE_NODE: {
yp_buffer_append_str(buffer, "ClassVariableWriteNode(", 23);
prettyprint_location(buffer, parser, &((yp_class_variable_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_class_variable_write_node_t *)node)->value == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_class_variable_write_node_t *)node)->value);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_class_variable_write_node_t *)node)->operator_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_class_variable_write_node_t *)node)->operator_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CONSTANT_OPERATOR_AND_WRITE_NODE: {
yp_buffer_append_str(buffer, "ConstantOperatorAndWriteNode(", 29);
prettyprint_location(buffer, parser, &((yp_constant_operator_and_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_constant_operator_and_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_constant_operator_and_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CONSTANT_OPERATOR_OR_WRITE_NODE: {
yp_buffer_append_str(buffer, "ConstantOperatorOrWriteNode(", 28);
prettyprint_location(buffer, parser, &((yp_constant_operator_or_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_constant_operator_or_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_constant_operator_or_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CONSTANT_OPERATOR_WRITE_NODE: {
yp_buffer_append_str(buffer, "ConstantOperatorWriteNode(", 26);
prettyprint_location(buffer, parser, &((yp_constant_operator_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_constant_operator_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_constant_operator_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ", ", 2); char operator_buffer[12];
yp_snprintf(operator_buffer, sizeof(operator_buffer), "%u", ((yp_constant_operator_write_node_t *)node)->operator);
yp_buffer_append_str(buffer, operator_buffer, strlen(operator_buffer));
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CONSTANT_PATH_NODE: {
yp_buffer_append_str(buffer, "ConstantPathNode(", 17);
if (((yp_constant_path_node_t *)node)->parent == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_constant_path_node_t *)node)->parent);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_constant_path_node_t *)node)->child);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_constant_path_node_t *)node)->delimiter_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CONSTANT_PATH_OPERATOR_AND_WRITE_NODE: {
yp_buffer_append_str(buffer, "ConstantPathOperatorAndWriteNode(", 33);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_constant_path_operator_and_write_node_t *)node)->target);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_constant_path_operator_and_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_constant_path_operator_and_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CONSTANT_PATH_OPERATOR_OR_WRITE_NODE: {
yp_buffer_append_str(buffer, "ConstantPathOperatorOrWriteNode(", 32);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_constant_path_operator_or_write_node_t *)node)->target);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_constant_path_operator_or_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_constant_path_operator_or_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CONSTANT_PATH_OPERATOR_WRITE_NODE: {
yp_buffer_append_str(buffer, "ConstantPathOperatorWriteNode(", 30);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_constant_path_operator_write_node_t *)node)->target);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_constant_path_operator_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_constant_path_operator_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ", ", 2); char operator_buffer[12];
yp_snprintf(operator_buffer, sizeof(operator_buffer), "%u", ((yp_constant_path_operator_write_node_t *)node)->operator);
yp_buffer_append_str(buffer, operator_buffer, strlen(operator_buffer));
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CONSTANT_PATH_WRITE_NODE: {
yp_buffer_append_str(buffer, "ConstantPathWriteNode(", 22);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_constant_path_write_node_t *)node)->target);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_constant_path_write_node_t *)node)->operator_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_constant_path_write_node_t *)node)->operator_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_constant_path_write_node_t *)node)->value == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_constant_path_write_node_t *)node)->value);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_CONSTANT_READ_NODE: {
yp_buffer_append_str(buffer, "ConstantReadNode(", 17);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_DEF_NODE: {
yp_buffer_append_str(buffer, "DefNode(", 8);
prettyprint_location(buffer, parser, &((yp_def_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_def_node_t *)node)->receiver == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_def_node_t *)node)->receiver);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_def_node_t *)node)->parameters == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_def_node_t *)node)->parameters);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_def_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_def_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ", ", 2); for (uint32_t index = 0; index < ((yp_def_node_t *)node)->locals.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
char locals_buffer[12];
yp_snprintf(locals_buffer, sizeof(locals_buffer), "%u", ((yp_def_node_t *)node)->locals.ids[index]);
yp_buffer_append_str(buffer, locals_buffer, strlen(locals_buffer));
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_def_node_t *)node)->def_keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_def_node_t *)node)->operator_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_def_node_t *)node)->operator_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_def_node_t *)node)->lparen_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_def_node_t *)node)->lparen_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_def_node_t *)node)->rparen_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_def_node_t *)node)->rparen_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_def_node_t *)node)->equal_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_def_node_t *)node)->equal_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_def_node_t *)node)->end_keyword_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_def_node_t *)node)->end_keyword_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_DEFINED_NODE: {
yp_buffer_append_str(buffer, "DefinedNode(", 12);
if (((yp_defined_node_t *)node)->lparen_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_defined_node_t *)node)->lparen_loc);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_defined_node_t *)node)->value);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_defined_node_t *)node)->rparen_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_defined_node_t *)node)->rparen_loc);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_defined_node_t *)node)->keyword_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_ELSE_NODE: {
yp_buffer_append_str(buffer, "ElseNode(", 9);
prettyprint_location(buffer, parser, &((yp_else_node_t *)node)->else_keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_else_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_else_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_else_node_t *)node)->end_keyword_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_else_node_t *)node)->end_keyword_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_EMBEDDED_STATEMENTS_NODE: {
yp_buffer_append_str(buffer, "EmbeddedStatementsNode(", 23);
prettyprint_location(buffer, parser, &((yp_embedded_statements_node_t *)node)->opening_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_embedded_statements_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_embedded_statements_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_embedded_statements_node_t *)node)->closing_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_EMBEDDED_VARIABLE_NODE: {
yp_buffer_append_str(buffer, "EmbeddedVariableNode(", 21);
prettyprint_location(buffer, parser, &((yp_embedded_variable_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_embedded_variable_node_t *)node)->variable);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_ENSURE_NODE: {
yp_buffer_append_str(buffer, "EnsureNode(", 11);
prettyprint_location(buffer, parser, &((yp_ensure_node_t *)node)->ensure_keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_ensure_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_ensure_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_ensure_node_t *)node)->end_keyword_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_FALSE_NODE: {
yp_buffer_append_str(buffer, "FalseNode(", 10);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_FIND_PATTERN_NODE: {
yp_buffer_append_str(buffer, "FindPatternNode(", 16);
if (((yp_find_pattern_node_t *)node)->constant == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_find_pattern_node_t *)node)->constant);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_find_pattern_node_t *)node)->left);
yp_buffer_append_str(buffer, ", ", 2); for (uint32_t index = 0; index < ((yp_find_pattern_node_t *)node)->requireds.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_find_pattern_node_t *) node)->requireds.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_find_pattern_node_t *)node)->right);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_find_pattern_node_t *)node)->opening_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_find_pattern_node_t *)node)->opening_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_find_pattern_node_t *)node)->closing_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_find_pattern_node_t *)node)->closing_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_FLOAT_NODE: {
yp_buffer_append_str(buffer, "FloatNode(", 10);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_FOR_NODE: {
yp_buffer_append_str(buffer, "ForNode(", 8);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_for_node_t *)node)->index);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_for_node_t *)node)->collection);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_for_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_for_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_for_node_t *)node)->for_keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_for_node_t *)node)->in_keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_for_node_t *)node)->do_keyword_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_for_node_t *)node)->do_keyword_loc);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_for_node_t *)node)->end_keyword_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_FORWARDING_ARGUMENTS_NODE: {
yp_buffer_append_str(buffer, "ForwardingArgumentsNode(", 24);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_FORWARDING_PARAMETER_NODE: {
yp_buffer_append_str(buffer, "ForwardingParameterNode(", 24);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_FORWARDING_SUPER_NODE: {
yp_buffer_append_str(buffer, "ForwardingSuperNode(", 20);
if (((yp_forwarding_super_node_t *)node)->block == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_forwarding_super_node_t *)node)->block);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_GLOBAL_VARIABLE_OPERATOR_AND_WRITE_NODE: {
yp_buffer_append_str(buffer, "GlobalVariableOperatorAndWriteNode(", 35);
prettyprint_location(buffer, parser, &((yp_global_variable_operator_and_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_global_variable_operator_and_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_global_variable_operator_and_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_GLOBAL_VARIABLE_OPERATOR_OR_WRITE_NODE: {
yp_buffer_append_str(buffer, "GlobalVariableOperatorOrWriteNode(", 34);
prettyprint_location(buffer, parser, &((yp_global_variable_operator_or_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_global_variable_operator_or_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_global_variable_operator_or_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_GLOBAL_VARIABLE_OPERATOR_WRITE_NODE: {
yp_buffer_append_str(buffer, "GlobalVariableOperatorWriteNode(", 32);
prettyprint_location(buffer, parser, &((yp_global_variable_operator_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_global_variable_operator_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_global_variable_operator_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ", ", 2); char operator_buffer[12];
yp_snprintf(operator_buffer, sizeof(operator_buffer), "%u", ((yp_global_variable_operator_write_node_t *)node)->operator);
yp_buffer_append_str(buffer, operator_buffer, strlen(operator_buffer));
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_GLOBAL_VARIABLE_READ_NODE: {
yp_buffer_append_str(buffer, "GlobalVariableReadNode(", 23);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_GLOBAL_VARIABLE_WRITE_NODE: {
yp_buffer_append_str(buffer, "GlobalVariableWriteNode(", 24);
prettyprint_location(buffer, parser, &((yp_global_variable_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_global_variable_write_node_t *)node)->operator_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_global_variable_write_node_t *)node)->operator_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_global_variable_write_node_t *)node)->value == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_global_variable_write_node_t *)node)->value);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_HASH_NODE: {
yp_buffer_append_str(buffer, "HashNode(", 9);
prettyprint_location(buffer, parser, &((yp_hash_node_t *)node)->opening_loc);
yp_buffer_append_str(buffer, ", ", 2); for (uint32_t index = 0; index < ((yp_hash_node_t *)node)->elements.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_hash_node_t *) node)->elements.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_hash_node_t *)node)->closing_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_HASH_PATTERN_NODE: {
yp_buffer_append_str(buffer, "HashPatternNode(", 16);
if (((yp_hash_pattern_node_t *)node)->constant == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_hash_pattern_node_t *)node)->constant);
}
yp_buffer_append_str(buffer, ", ", 2); for (uint32_t index = 0; index < ((yp_hash_pattern_node_t *)node)->assocs.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_hash_pattern_node_t *) node)->assocs.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_hash_pattern_node_t *)node)->kwrest == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_hash_pattern_node_t *)node)->kwrest);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_hash_pattern_node_t *)node)->opening_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_hash_pattern_node_t *)node)->opening_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_hash_pattern_node_t *)node)->closing_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_hash_pattern_node_t *)node)->closing_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_IF_NODE: {
yp_buffer_append_str(buffer, "IfNode(", 7);
if (((yp_if_node_t *)node)->if_keyword_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_if_node_t *)node)->if_keyword_loc);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_if_node_t *)node)->predicate);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_if_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_if_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_if_node_t *)node)->consequent == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_if_node_t *)node)->consequent);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_if_node_t *)node)->end_keyword_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_if_node_t *)node)->end_keyword_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_IMAGINARY_NODE: {
yp_buffer_append_str(buffer, "ImaginaryNode(", 14);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_imaginary_node_t *)node)->numeric);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_IN_NODE: {
yp_buffer_append_str(buffer, "InNode(", 7);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_in_node_t *)node)->pattern);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_in_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_in_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_in_node_t *)node)->in_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_in_node_t *)node)->then_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_in_node_t *)node)->then_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_INSTANCE_VARIABLE_OPERATOR_AND_WRITE_NODE: {
yp_buffer_append_str(buffer, "InstanceVariableOperatorAndWriteNode(", 37);
prettyprint_location(buffer, parser, &((yp_instance_variable_operator_and_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_instance_variable_operator_and_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_instance_variable_operator_and_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_INSTANCE_VARIABLE_OPERATOR_OR_WRITE_NODE: {
yp_buffer_append_str(buffer, "InstanceVariableOperatorOrWriteNode(", 36);
prettyprint_location(buffer, parser, &((yp_instance_variable_operator_or_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_instance_variable_operator_or_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_instance_variable_operator_or_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE: {
yp_buffer_append_str(buffer, "InstanceVariableOperatorWriteNode(", 34);
prettyprint_location(buffer, parser, &((yp_instance_variable_operator_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_instance_variable_operator_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_instance_variable_operator_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ", ", 2); char operator_buffer[12];
yp_snprintf(operator_buffer, sizeof(operator_buffer), "%u", ((yp_instance_variable_operator_write_node_t *)node)->operator);
yp_buffer_append_str(buffer, operator_buffer, strlen(operator_buffer));
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_INSTANCE_VARIABLE_READ_NODE: {
yp_buffer_append_str(buffer, "InstanceVariableReadNode(", 25);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_INSTANCE_VARIABLE_WRITE_NODE: {
yp_buffer_append_str(buffer, "InstanceVariableWriteNode(", 26);
prettyprint_location(buffer, parser, &((yp_instance_variable_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_instance_variable_write_node_t *)node)->value == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_instance_variable_write_node_t *)node)->value);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_instance_variable_write_node_t *)node)->operator_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_instance_variable_write_node_t *)node)->operator_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_INTEGER_NODE: {
yp_buffer_append_str(buffer, "IntegerNode(", 12);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_INTERPOLATED_REGULAR_EXPRESSION_NODE: {
yp_buffer_append_str(buffer, "InterpolatedRegularExpressionNode(", 34);
prettyprint_location(buffer, parser, &((yp_interpolated_regular_expression_node_t *)node)->opening_loc);
yp_buffer_append_str(buffer, ", ", 2); for (uint32_t index = 0; index < ((yp_interpolated_regular_expression_node_t *)node)->parts.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_interpolated_regular_expression_node_t *) node)->parts.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_interpolated_regular_expression_node_t *)node)->closing_loc);
yp_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
yp_snprintf(flags_buffer, sizeof(flags_buffer), "+%d", ((yp_interpolated_regular_expression_node_t *)node)->flags);
yp_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_INTERPOLATED_STRING_NODE: {
yp_buffer_append_str(buffer, "InterpolatedStringNode(", 23);
if (((yp_interpolated_string_node_t *)node)->opening_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_interpolated_string_node_t *)node)->opening_loc);
}
yp_buffer_append_str(buffer, ", ", 2); for (uint32_t index = 0; index < ((yp_interpolated_string_node_t *)node)->parts.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_interpolated_string_node_t *) node)->parts.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_interpolated_string_node_t *)node)->closing_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_interpolated_string_node_t *)node)->closing_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_INTERPOLATED_SYMBOL_NODE: {
yp_buffer_append_str(buffer, "InterpolatedSymbolNode(", 23);
if (((yp_interpolated_symbol_node_t *)node)->opening_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_interpolated_symbol_node_t *)node)->opening_loc);
}
yp_buffer_append_str(buffer, ", ", 2); for (uint32_t index = 0; index < ((yp_interpolated_symbol_node_t *)node)->parts.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_interpolated_symbol_node_t *) node)->parts.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_interpolated_symbol_node_t *)node)->closing_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_interpolated_symbol_node_t *)node)->closing_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_INTERPOLATED_X_STRING_NODE: {
yp_buffer_append_str(buffer, "InterpolatedXStringNode(", 24);
prettyprint_location(buffer, parser, &((yp_interpolated_x_string_node_t *)node)->opening_loc);
yp_buffer_append_str(buffer, ", ", 2); for (uint32_t index = 0; index < ((yp_interpolated_x_string_node_t *)node)->parts.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_interpolated_x_string_node_t *) node)->parts.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_interpolated_x_string_node_t *)node)->closing_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_KEYWORD_HASH_NODE: {
yp_buffer_append_str(buffer, "KeywordHashNode(", 16);
for (uint32_t index = 0; index < ((yp_keyword_hash_node_t *)node)->elements.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_keyword_hash_node_t *) node)->elements.nodes[index]);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_KEYWORD_PARAMETER_NODE: {
yp_buffer_append_str(buffer, "KeywordParameterNode(", 21);
prettyprint_location(buffer, parser, &((yp_keyword_parameter_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_keyword_parameter_node_t *)node)->value == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_keyword_parameter_node_t *)node)->value);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_KEYWORD_REST_PARAMETER_NODE: {
yp_buffer_append_str(buffer, "KeywordRestParameterNode(", 25);
prettyprint_location(buffer, parser, &((yp_keyword_rest_parameter_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_keyword_rest_parameter_node_t *)node)->name_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_keyword_rest_parameter_node_t *)node)->name_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_LAMBDA_NODE: {
yp_buffer_append_str(buffer, "LambdaNode(", 11);
for (uint32_t index = 0; index < ((yp_lambda_node_t *)node)->locals.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
char locals_buffer[12];
yp_snprintf(locals_buffer, sizeof(locals_buffer), "%u", ((yp_lambda_node_t *)node)->locals.ids[index]);
yp_buffer_append_str(buffer, locals_buffer, strlen(locals_buffer));
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_lambda_node_t *)node)->opening_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_lambda_node_t *)node)->parameters == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_lambda_node_t *)node)->parameters);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_lambda_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_lambda_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_LOCAL_VARIABLE_OPERATOR_AND_WRITE_NODE: {
yp_buffer_append_str(buffer, "LocalVariableOperatorAndWriteNode(", 34);
prettyprint_location(buffer, parser, &((yp_local_variable_operator_and_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_local_variable_operator_and_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_local_variable_operator_and_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ", ", 2); char constant_id_buffer[12];
yp_snprintf(constant_id_buffer, sizeof(constant_id_buffer), "%u", ((yp_local_variable_operator_and_write_node_t *)node)->constant_id);
yp_buffer_append_str(buffer, constant_id_buffer, strlen(constant_id_buffer));
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_LOCAL_VARIABLE_OPERATOR_OR_WRITE_NODE: {
yp_buffer_append_str(buffer, "LocalVariableOperatorOrWriteNode(", 33);
prettyprint_location(buffer, parser, &((yp_local_variable_operator_or_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_local_variable_operator_or_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_local_variable_operator_or_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ", ", 2); char constant_id_buffer[12];
yp_snprintf(constant_id_buffer, sizeof(constant_id_buffer), "%u", ((yp_local_variable_operator_or_write_node_t *)node)->constant_id);
yp_buffer_append_str(buffer, constant_id_buffer, strlen(constant_id_buffer));
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_LOCAL_VARIABLE_OPERATOR_WRITE_NODE: {
yp_buffer_append_str(buffer, "LocalVariableOperatorWriteNode(", 31);
prettyprint_location(buffer, parser, &((yp_local_variable_operator_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_local_variable_operator_write_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_local_variable_operator_write_node_t *)node)->value);
yp_buffer_append_str(buffer, ", ", 2); char constant_id_buffer[12];
yp_snprintf(constant_id_buffer, sizeof(constant_id_buffer), "%u", ((yp_local_variable_operator_write_node_t *)node)->constant_id);
yp_buffer_append_str(buffer, constant_id_buffer, strlen(constant_id_buffer));
yp_buffer_append_str(buffer, ", ", 2); char operator_id_buffer[12];
yp_snprintf(operator_id_buffer, sizeof(operator_id_buffer), "%u", ((yp_local_variable_operator_write_node_t *)node)->operator_id);
yp_buffer_append_str(buffer, operator_id_buffer, strlen(operator_id_buffer));
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_LOCAL_VARIABLE_READ_NODE: {
yp_buffer_append_str(buffer, "LocalVariableReadNode(", 22);
char constant_id_buffer[12];
yp_snprintf(constant_id_buffer, sizeof(constant_id_buffer), "%u", ((yp_local_variable_read_node_t *)node)->constant_id);
yp_buffer_append_str(buffer, constant_id_buffer, strlen(constant_id_buffer));
yp_buffer_append_str(buffer, ", ", 2); char depth_buffer[12];
yp_snprintf(depth_buffer, sizeof(depth_buffer), "+%d", ((yp_local_variable_read_node_t *)node)->depth);
yp_buffer_append_str(buffer, depth_buffer, strlen(depth_buffer));
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_LOCAL_VARIABLE_WRITE_NODE: {
yp_buffer_append_str(buffer, "LocalVariableWriteNode(", 23);
char constant_id_buffer[12];
yp_snprintf(constant_id_buffer, sizeof(constant_id_buffer), "%u", ((yp_local_variable_write_node_t *)node)->constant_id);
yp_buffer_append_str(buffer, constant_id_buffer, strlen(constant_id_buffer));
yp_buffer_append_str(buffer, ", ", 2); char depth_buffer[12];
yp_snprintf(depth_buffer, sizeof(depth_buffer), "+%d", ((yp_local_variable_write_node_t *)node)->depth);
yp_buffer_append_str(buffer, depth_buffer, strlen(depth_buffer));
yp_buffer_append_str(buffer, ", ", 2); if (((yp_local_variable_write_node_t *)node)->value == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_local_variable_write_node_t *)node)->value);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_local_variable_write_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_local_variable_write_node_t *)node)->operator_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_local_variable_write_node_t *)node)->operator_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_MATCH_PREDICATE_NODE: {
yp_buffer_append_str(buffer, "MatchPredicateNode(", 19);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_match_predicate_node_t *)node)->value);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_match_predicate_node_t *)node)->pattern);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_match_predicate_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_MATCH_REQUIRED_NODE: {
yp_buffer_append_str(buffer, "MatchRequiredNode(", 18);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_match_required_node_t *)node)->value);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_match_required_node_t *)node)->pattern);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_match_required_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_MISSING_NODE: {
yp_buffer_append_str(buffer, "MissingNode(", 12);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_MODULE_NODE: {
yp_buffer_append_str(buffer, "ModuleNode(", 11);
for (uint32_t index = 0; index < ((yp_module_node_t *)node)->locals.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
char locals_buffer[12];
yp_snprintf(locals_buffer, sizeof(locals_buffer), "%u", ((yp_module_node_t *)node)->locals.ids[index]);
yp_buffer_append_str(buffer, locals_buffer, strlen(locals_buffer));
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_module_node_t *)node)->module_keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_module_node_t *)node)->constant_path);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_module_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_module_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_module_node_t *)node)->end_keyword_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_MULTI_WRITE_NODE: {
yp_buffer_append_str(buffer, "MultiWriteNode(", 15);
for (uint32_t index = 0; index < ((yp_multi_write_node_t *)node)->targets.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_multi_write_node_t *) node)->targets.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_multi_write_node_t *)node)->operator_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_multi_write_node_t *)node)->operator_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_multi_write_node_t *)node)->value == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_multi_write_node_t *)node)->value);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_multi_write_node_t *)node)->lparen_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_multi_write_node_t *)node)->lparen_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_multi_write_node_t *)node)->rparen_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_multi_write_node_t *)node)->rparen_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_NEXT_NODE: {
yp_buffer_append_str(buffer, "NextNode(", 9);
if (((yp_next_node_t *)node)->arguments == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_next_node_t *)node)->arguments);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_next_node_t *)node)->keyword_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_NIL_NODE: {
yp_buffer_append_str(buffer, "NilNode(", 8);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_NO_KEYWORDS_PARAMETER_NODE: {
yp_buffer_append_str(buffer, "NoKeywordsParameterNode(", 24);
prettyprint_location(buffer, parser, &((yp_no_keywords_parameter_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_no_keywords_parameter_node_t *)node)->keyword_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_NUMBERED_REFERENCE_READ_NODE: {
yp_buffer_append_str(buffer, "NumberedReferenceReadNode(", 26);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_OPTIONAL_PARAMETER_NODE: {
yp_buffer_append_str(buffer, "OptionalParameterNode(", 22);
char constant_id_buffer[12];
yp_snprintf(constant_id_buffer, sizeof(constant_id_buffer), "%u", ((yp_optional_parameter_node_t *)node)->constant_id);
yp_buffer_append_str(buffer, constant_id_buffer, strlen(constant_id_buffer));
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_optional_parameter_node_t *)node)->name_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_optional_parameter_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_optional_parameter_node_t *)node)->value);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_OR_NODE: {
yp_buffer_append_str(buffer, "OrNode(", 7);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_or_node_t *)node)->left);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_or_node_t *)node)->right);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_or_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_PARAMETERS_NODE: {
yp_buffer_append_str(buffer, "ParametersNode(", 15);
for (uint32_t index = 0; index < ((yp_parameters_node_t *)node)->requireds.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_parameters_node_t *) node)->requireds.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); for (uint32_t index = 0; index < ((yp_parameters_node_t *)node)->optionals.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_parameters_node_t *) node)->optionals.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); for (uint32_t index = 0; index < ((yp_parameters_node_t *)node)->posts.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_parameters_node_t *) node)->posts.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_parameters_node_t *)node)->rest == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_parameters_node_t *)node)->rest);
}
yp_buffer_append_str(buffer, ", ", 2); for (uint32_t index = 0; index < ((yp_parameters_node_t *)node)->keywords.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_parameters_node_t *) node)->keywords.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_parameters_node_t *)node)->keyword_rest == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_parameters_node_t *)node)->keyword_rest);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_parameters_node_t *)node)->block == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_parameters_node_t *)node)->block);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_PARENTHESES_NODE: {
yp_buffer_append_str(buffer, "ParenthesesNode(", 16);
if (((yp_parentheses_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_parentheses_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_parentheses_node_t *)node)->opening_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_parentheses_node_t *)node)->closing_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_PINNED_EXPRESSION_NODE: {
yp_buffer_append_str(buffer, "PinnedExpressionNode(", 21);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_pinned_expression_node_t *)node)->expression);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_pinned_expression_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_pinned_expression_node_t *)node)->lparen_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_pinned_expression_node_t *)node)->rparen_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_PINNED_VARIABLE_NODE: {
yp_buffer_append_str(buffer, "PinnedVariableNode(", 19);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_pinned_variable_node_t *)node)->variable);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_pinned_variable_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_POST_EXECUTION_NODE: {
yp_buffer_append_str(buffer, "PostExecutionNode(", 18);
if (((yp_post_execution_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_post_execution_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_post_execution_node_t *)node)->keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_post_execution_node_t *)node)->opening_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_post_execution_node_t *)node)->closing_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_PRE_EXECUTION_NODE: {
yp_buffer_append_str(buffer, "PreExecutionNode(", 17);
if (((yp_pre_execution_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_pre_execution_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_pre_execution_node_t *)node)->keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_pre_execution_node_t *)node)->opening_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_pre_execution_node_t *)node)->closing_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_PROGRAM_NODE: {
yp_buffer_append_str(buffer, "ProgramNode(", 12);
for (uint32_t index = 0; index < ((yp_program_node_t *)node)->locals.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
char locals_buffer[12];
yp_snprintf(locals_buffer, sizeof(locals_buffer), "%u", ((yp_program_node_t *)node)->locals.ids[index]);
yp_buffer_append_str(buffer, locals_buffer, strlen(locals_buffer));
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_program_node_t *)node)->statements);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_RANGE_NODE: {
yp_buffer_append_str(buffer, "RangeNode(", 10);
if (((yp_range_node_t *)node)->left == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_range_node_t *)node)->left);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_range_node_t *)node)->right == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_range_node_t *)node)->right);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_range_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
yp_snprintf(flags_buffer, sizeof(flags_buffer), "+%d", ((yp_range_node_t *)node)->flags);
yp_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_RATIONAL_NODE: {
yp_buffer_append_str(buffer, "RationalNode(", 13);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_rational_node_t *)node)->numeric);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_REDO_NODE: {
yp_buffer_append_str(buffer, "RedoNode(", 9);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_REGULAR_EXPRESSION_NODE: {
yp_buffer_append_str(buffer, "RegularExpressionNode(", 22);
prettyprint_location(buffer, parser, &((yp_regular_expression_node_t *)node)->opening_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_regular_expression_node_t *)node)->content_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_regular_expression_node_t *)node)->closing_loc);
yp_buffer_append_str(buffer, ", ", 2); yp_buffer_append_str(buffer, "\"", 1);
yp_buffer_append_str(buffer, yp_string_source(&((yp_regular_expression_node_t *)node)->unescaped), yp_string_length(&((yp_regular_expression_node_t *)node)->unescaped));
yp_buffer_append_str(buffer, "\"", 1);
yp_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
yp_snprintf(flags_buffer, sizeof(flags_buffer), "+%d", ((yp_regular_expression_node_t *)node)->flags);
yp_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_REQUIRED_DESTRUCTURED_PARAMETER_NODE: {
yp_buffer_append_str(buffer, "RequiredDestructuredParameterNode(", 34);
for (uint32_t index = 0; index < ((yp_required_destructured_parameter_node_t *)node)->parameters.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_required_destructured_parameter_node_t *) node)->parameters.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_required_destructured_parameter_node_t *)node)->opening_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_required_destructured_parameter_node_t *)node)->closing_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_REQUIRED_PARAMETER_NODE: {
yp_buffer_append_str(buffer, "RequiredParameterNode(", 22);
char constant_id_buffer[12];
yp_snprintf(constant_id_buffer, sizeof(constant_id_buffer), "%u", ((yp_required_parameter_node_t *)node)->constant_id);
yp_buffer_append_str(buffer, constant_id_buffer, strlen(constant_id_buffer));
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_RESCUE_MODIFIER_NODE: {
yp_buffer_append_str(buffer, "RescueModifierNode(", 19);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_rescue_modifier_node_t *)node)->expression);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_rescue_modifier_node_t *)node)->keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_rescue_modifier_node_t *)node)->rescue_expression);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_RESCUE_NODE: {
yp_buffer_append_str(buffer, "RescueNode(", 11);
prettyprint_location(buffer, parser, &((yp_rescue_node_t *)node)->keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); for (uint32_t index = 0; index < ((yp_rescue_node_t *)node)->exceptions.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_rescue_node_t *) node)->exceptions.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_rescue_node_t *)node)->operator_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_rescue_node_t *)node)->operator_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_rescue_node_t *)node)->exception == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_rescue_node_t *)node)->exception);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_rescue_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_rescue_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_rescue_node_t *)node)->consequent == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_rescue_node_t *)node)->consequent);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_REST_PARAMETER_NODE: {
yp_buffer_append_str(buffer, "RestParameterNode(", 18);
prettyprint_location(buffer, parser, &((yp_rest_parameter_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_rest_parameter_node_t *)node)->name_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_rest_parameter_node_t *)node)->name_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_RETRY_NODE: {
yp_buffer_append_str(buffer, "RetryNode(", 10);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_RETURN_NODE: {
yp_buffer_append_str(buffer, "ReturnNode(", 11);
prettyprint_location(buffer, parser, &((yp_return_node_t *)node)->keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_return_node_t *)node)->arguments == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_return_node_t *)node)->arguments);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_SELF_NODE: {
yp_buffer_append_str(buffer, "SelfNode(", 9);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_SINGLETON_CLASS_NODE: {
yp_buffer_append_str(buffer, "SingletonClassNode(", 19);
for (uint32_t index = 0; index < ((yp_singleton_class_node_t *)node)->locals.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
char locals_buffer[12];
yp_snprintf(locals_buffer, sizeof(locals_buffer), "%u", ((yp_singleton_class_node_t *)node)->locals.ids[index]);
yp_buffer_append_str(buffer, locals_buffer, strlen(locals_buffer));
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_singleton_class_node_t *)node)->class_keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_singleton_class_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_singleton_class_node_t *)node)->expression);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_singleton_class_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_singleton_class_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_singleton_class_node_t *)node)->end_keyword_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_SOURCE_ENCODING_NODE: {
yp_buffer_append_str(buffer, "SourceEncodingNode(", 19);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_SOURCE_FILE_NODE: {
yp_buffer_append_str(buffer, "SourceFileNode(", 15);
yp_buffer_append_str(buffer, "\"", 1);
yp_buffer_append_str(buffer, yp_string_source(&((yp_source_file_node_t *)node)->filepath), yp_string_length(&((yp_source_file_node_t *)node)->filepath));
yp_buffer_append_str(buffer, "\"", 1);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_SOURCE_LINE_NODE: {
yp_buffer_append_str(buffer, "SourceLineNode(", 15);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_SPLAT_NODE: {
yp_buffer_append_str(buffer, "SplatNode(", 10);
prettyprint_location(buffer, parser, &((yp_splat_node_t *)node)->operator_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_splat_node_t *)node)->expression == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_splat_node_t *)node)->expression);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_STATEMENTS_NODE: {
yp_buffer_append_str(buffer, "StatementsNode(", 15);
for (uint32_t index = 0; index < ((yp_statements_node_t *)node)->body.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_statements_node_t *) node)->body.nodes[index]);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_STRING_CONCAT_NODE: {
yp_buffer_append_str(buffer, "StringConcatNode(", 17);
prettyprint_node(buffer, parser, (yp_node_t *)((yp_string_concat_node_t *)node)->left);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_string_concat_node_t *)node)->right);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_STRING_NODE: {
yp_buffer_append_str(buffer, "StringNode(", 11);
if (((yp_string_node_t *)node)->opening_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_string_node_t *)node)->opening_loc);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_string_node_t *)node)->content_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_string_node_t *)node)->closing_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_string_node_t *)node)->closing_loc);
}
yp_buffer_append_str(buffer, ", ", 2); yp_buffer_append_str(buffer, "\"", 1);
yp_buffer_append_str(buffer, yp_string_source(&((yp_string_node_t *)node)->unescaped), yp_string_length(&((yp_string_node_t *)node)->unescaped));
yp_buffer_append_str(buffer, "\"", 1);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_SUPER_NODE: {
yp_buffer_append_str(buffer, "SuperNode(", 10);
prettyprint_location(buffer, parser, &((yp_super_node_t *)node)->keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_super_node_t *)node)->lparen_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_super_node_t *)node)->lparen_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_super_node_t *)node)->arguments == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_super_node_t *)node)->arguments);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_super_node_t *)node)->rparen_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_super_node_t *)node)->rparen_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_super_node_t *)node)->block == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_super_node_t *)node)->block);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_SYMBOL_NODE: {
yp_buffer_append_str(buffer, "SymbolNode(", 11);
if (((yp_symbol_node_t *)node)->opening_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_symbol_node_t *)node)->opening_loc);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_symbol_node_t *)node)->value_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_symbol_node_t *)node)->closing_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_symbol_node_t *)node)->closing_loc);
}
yp_buffer_append_str(buffer, ", ", 2); yp_buffer_append_str(buffer, "\"", 1);
yp_buffer_append_str(buffer, yp_string_source(&((yp_symbol_node_t *)node)->unescaped), yp_string_length(&((yp_symbol_node_t *)node)->unescaped));
yp_buffer_append_str(buffer, "\"", 1);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_TRUE_NODE: {
yp_buffer_append_str(buffer, "TrueNode(", 9);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_UNDEF_NODE: {
yp_buffer_append_str(buffer, "UndefNode(", 10);
for (uint32_t index = 0; index < ((yp_undef_node_t *)node)->names.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_undef_node_t *) node)->names.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_undef_node_t *)node)->keyword_loc);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_UNLESS_NODE: {
yp_buffer_append_str(buffer, "UnlessNode(", 11);
prettyprint_location(buffer, parser, &((yp_unless_node_t *)node)->keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_unless_node_t *)node)->predicate);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_unless_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_unless_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_unless_node_t *)node)->consequent == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_unless_node_t *)node)->consequent);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_unless_node_t *)node)->end_keyword_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_unless_node_t *)node)->end_keyword_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_UNTIL_NODE: {
yp_buffer_append_str(buffer, "UntilNode(", 10);
prettyprint_location(buffer, parser, &((yp_until_node_t *)node)->keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_until_node_t *)node)->predicate);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_until_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_until_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_WHEN_NODE: {
yp_buffer_append_str(buffer, "WhenNode(", 9);
prettyprint_location(buffer, parser, &((yp_when_node_t *)node)->keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); for (uint32_t index = 0; index < ((yp_when_node_t *)node)->conditions.size; index++) {
if (index != 0) yp_buffer_append_str(buffer, ", ", 2);
prettyprint_node(buffer, parser, (yp_node_t *) ((yp_when_node_t *) node)->conditions.nodes[index]);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_when_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_when_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_WHILE_NODE: {
yp_buffer_append_str(buffer, "WhileNode(", 10);
prettyprint_location(buffer, parser, &((yp_while_node_t *)node)->keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (yp_node_t *)((yp_while_node_t *)node)->predicate);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_while_node_t *)node)->statements == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_while_node_t *)node)->statements);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_X_STRING_NODE: {
yp_buffer_append_str(buffer, "XStringNode(", 12);
prettyprint_location(buffer, parser, &((yp_x_string_node_t *)node)->opening_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_x_string_node_t *)node)->content_loc);
yp_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((yp_x_string_node_t *)node)->closing_loc);
yp_buffer_append_str(buffer, ", ", 2); yp_buffer_append_str(buffer, "\"", 1);
yp_buffer_append_str(buffer, yp_string_source(&((yp_x_string_node_t *)node)->unescaped), yp_string_length(&((yp_x_string_node_t *)node)->unescaped));
yp_buffer_append_str(buffer, "\"", 1);
yp_buffer_append_str(buffer, ")", 1);
break;
}
case YP_NODE_YIELD_NODE: {
yp_buffer_append_str(buffer, "YieldNode(", 10);
prettyprint_location(buffer, parser, &((yp_yield_node_t *)node)->keyword_loc);
yp_buffer_append_str(buffer, ", ", 2); if (((yp_yield_node_t *)node)->lparen_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_yield_node_t *)node)->lparen_loc);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_yield_node_t *)node)->arguments == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_node(buffer, parser, (yp_node_t *)((yp_yield_node_t *)node)->arguments);
}
yp_buffer_append_str(buffer, ", ", 2); if (((yp_yield_node_t *)node)->rparen_loc.start == NULL) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
prettyprint_location(buffer, parser, &((yp_yield_node_t *)node)->rparen_loc);
}
yp_buffer_append_str(buffer, ")", 1);
break;
}
}
}
void
yp_print_node(yp_parser_t *parser, yp_node_t *node) {
yp_buffer_t buffer;
if (!yp_buffer_init(&buffer)) return;
prettyprint_node(&buffer, parser, node);
printf("%.*s\n", (int) buffer.length, buffer.value);
yp_buffer_free(&buffer);
}
// Pretty-prints the AST represented by the given node to the given buffer.
YP_EXPORTED_FUNCTION void
yp_prettyprint(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
prettyprint_node(buffer, parser, node);
}