prism 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +172 -0
  3. data/CODE_OF_CONDUCT.md +76 -0
  4. data/CONTRIBUTING.md +62 -0
  5. data/LICENSE.md +7 -0
  6. data/Makefile +84 -0
  7. data/README.md +89 -0
  8. data/config.yml +2481 -0
  9. data/docs/build_system.md +74 -0
  10. data/docs/building.md +22 -0
  11. data/docs/configuration.md +60 -0
  12. data/docs/design.md +53 -0
  13. data/docs/encoding.md +117 -0
  14. data/docs/fuzzing.md +93 -0
  15. data/docs/heredocs.md +36 -0
  16. data/docs/mapping.md +117 -0
  17. data/docs/ripper.md +36 -0
  18. data/docs/ruby_api.md +25 -0
  19. data/docs/serialization.md +181 -0
  20. data/docs/testing.md +55 -0
  21. data/ext/prism/api_node.c +4725 -0
  22. data/ext/prism/api_pack.c +256 -0
  23. data/ext/prism/extconf.rb +136 -0
  24. data/ext/prism/extension.c +626 -0
  25. data/ext/prism/extension.h +18 -0
  26. data/include/prism/ast.h +1932 -0
  27. data/include/prism/defines.h +45 -0
  28. data/include/prism/diagnostic.h +231 -0
  29. data/include/prism/enc/pm_encoding.h +95 -0
  30. data/include/prism/node.h +41 -0
  31. data/include/prism/pack.h +141 -0
  32. data/include/prism/parser.h +418 -0
  33. data/include/prism/regexp.h +19 -0
  34. data/include/prism/unescape.h +48 -0
  35. data/include/prism/util/pm_buffer.h +51 -0
  36. data/include/prism/util/pm_char.h +91 -0
  37. data/include/prism/util/pm_constant_pool.h +78 -0
  38. data/include/prism/util/pm_list.h +67 -0
  39. data/include/prism/util/pm_memchr.h +14 -0
  40. data/include/prism/util/pm_newline_list.h +61 -0
  41. data/include/prism/util/pm_state_stack.h +24 -0
  42. data/include/prism/util/pm_string.h +61 -0
  43. data/include/prism/util/pm_string_list.h +25 -0
  44. data/include/prism/util/pm_strpbrk.h +29 -0
  45. data/include/prism/version.h +4 -0
  46. data/include/prism.h +82 -0
  47. data/lib/prism/compiler.rb +465 -0
  48. data/lib/prism/debug.rb +157 -0
  49. data/lib/prism/desugar_compiler.rb +206 -0
  50. data/lib/prism/dispatcher.rb +2051 -0
  51. data/lib/prism/dsl.rb +750 -0
  52. data/lib/prism/ffi.rb +251 -0
  53. data/lib/prism/lex_compat.rb +838 -0
  54. data/lib/prism/mutation_compiler.rb +718 -0
  55. data/lib/prism/node.rb +14540 -0
  56. data/lib/prism/node_ext.rb +55 -0
  57. data/lib/prism/node_inspector.rb +68 -0
  58. data/lib/prism/pack.rb +185 -0
  59. data/lib/prism/parse_result/comments.rb +172 -0
  60. data/lib/prism/parse_result/newlines.rb +60 -0
  61. data/lib/prism/parse_result.rb +266 -0
  62. data/lib/prism/pattern.rb +239 -0
  63. data/lib/prism/ripper_compat.rb +174 -0
  64. data/lib/prism/serialize.rb +662 -0
  65. data/lib/prism/visitor.rb +470 -0
  66. data/lib/prism.rb +64 -0
  67. data/prism.gemspec +113 -0
  68. data/src/diagnostic.c +287 -0
  69. data/src/enc/pm_big5.c +52 -0
  70. data/src/enc/pm_euc_jp.c +58 -0
  71. data/src/enc/pm_gbk.c +61 -0
  72. data/src/enc/pm_shift_jis.c +56 -0
  73. data/src/enc/pm_tables.c +507 -0
  74. data/src/enc/pm_unicode.c +2324 -0
  75. data/src/enc/pm_windows_31j.c +56 -0
  76. data/src/node.c +2633 -0
  77. data/src/pack.c +493 -0
  78. data/src/prettyprint.c +2136 -0
  79. data/src/prism.c +14587 -0
  80. data/src/regexp.c +580 -0
  81. data/src/serialize.c +1899 -0
  82. data/src/token_type.c +349 -0
  83. data/src/unescape.c +637 -0
  84. data/src/util/pm_buffer.c +103 -0
  85. data/src/util/pm_char.c +272 -0
  86. data/src/util/pm_constant_pool.c +252 -0
  87. data/src/util/pm_list.c +41 -0
  88. data/src/util/pm_memchr.c +33 -0
  89. data/src/util/pm_newline_list.c +134 -0
  90. data/src/util/pm_state_stack.c +19 -0
  91. data/src/util/pm_string.c +200 -0
  92. data/src/util/pm_string_list.c +29 -0
  93. data/src/util/pm_strncasecmp.c +17 -0
  94. data/src/util/pm_strpbrk.c +66 -0
  95. metadata +138 -0
data/src/prettyprint.c ADDED
@@ -0,0 +1,2136 @@
1
+ /******************************************************************************/
2
+ /* This file is generated by the templates/template.rb script and should not */
3
+ /* be modified manually. See */
4
+ /* templates/src/prettyprint.c.erb */
5
+ /* if you are looking to modify the */
6
+ /* template */
7
+ /******************************************************************************/
8
+ #include "prism/defines.h"
9
+
10
+ #include <stdio.h>
11
+
12
+ #include "prism/ast.h"
13
+ #include "prism/parser.h"
14
+ #include "prism/util/pm_buffer.h"
15
+
16
+ static void
17
+ prettyprint_location(pm_buffer_t *buffer, pm_parser_t *parser, pm_location_t *location) {
18
+ char printed[] = "[0000-0000]";
19
+ snprintf(printed, sizeof(printed), "[%04ld-%04ld]", (long int)(location->start - parser->start), (long int)(location->end - parser->start));
20
+ pm_buffer_append_str(buffer, printed, strlen(printed));
21
+ }
22
+
23
+ static void
24
+ prettyprint_node(pm_buffer_t *buffer, pm_parser_t *parser, pm_node_t *node) {
25
+ switch (PM_NODE_TYPE(node)) {
26
+ // We do not need to print a ScopeNode as it's not part
27
+ // of the AST
28
+ case PM_SCOPE_NODE:
29
+ return;
30
+ case PM_ALIAS_GLOBAL_VARIABLE_NODE: {
31
+ pm_buffer_append_str(buffer, "AliasGlobalVariableNode(", 24);
32
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_alias_global_variable_node_t *)node)->new_name);
33
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_alias_global_variable_node_t *)node)->old_name);
34
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_alias_global_variable_node_t *)node)->keyword_loc);
35
+ pm_buffer_append_str(buffer, ")", 1);
36
+ break;
37
+ }
38
+ case PM_ALIAS_METHOD_NODE: {
39
+ pm_buffer_append_str(buffer, "AliasMethodNode(", 16);
40
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_alias_method_node_t *)node)->new_name);
41
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_alias_method_node_t *)node)->old_name);
42
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_alias_method_node_t *)node)->keyword_loc);
43
+ pm_buffer_append_str(buffer, ")", 1);
44
+ break;
45
+ }
46
+ case PM_ALTERNATION_PATTERN_NODE: {
47
+ pm_buffer_append_str(buffer, "AlternationPatternNode(", 23);
48
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_alternation_pattern_node_t *)node)->left);
49
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_alternation_pattern_node_t *)node)->right);
50
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_alternation_pattern_node_t *)node)->operator_loc);
51
+ pm_buffer_append_str(buffer, ")", 1);
52
+ break;
53
+ }
54
+ case PM_AND_NODE: {
55
+ pm_buffer_append_str(buffer, "AndNode(", 8);
56
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_and_node_t *)node)->left);
57
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_and_node_t *)node)->right);
58
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_and_node_t *)node)->operator_loc);
59
+ pm_buffer_append_str(buffer, ")", 1);
60
+ break;
61
+ }
62
+ case PM_ARGUMENTS_NODE: {
63
+ pm_buffer_append_str(buffer, "ArgumentsNode(", 14);
64
+ pm_buffer_append_str(buffer, "[", 1);
65
+ for (uint32_t index = 0; index < ((pm_arguments_node_t *)node)->arguments.size; index++) {
66
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
67
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_arguments_node_t *) node)->arguments.nodes[index]);
68
+ }
69
+ pm_buffer_append_str(buffer, "]", 1);
70
+ pm_buffer_append_str(buffer, ")", 1);
71
+ break;
72
+ }
73
+ case PM_ARRAY_NODE: {
74
+ pm_buffer_append_str(buffer, "ArrayNode(", 10);
75
+ pm_buffer_append_str(buffer, "[", 1);
76
+ for (uint32_t index = 0; index < ((pm_array_node_t *)node)->elements.size; index++) {
77
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
78
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_array_node_t *) node)->elements.nodes[index]);
79
+ }
80
+ pm_buffer_append_str(buffer, "]", 1);
81
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_array_node_t *)node)->opening_loc.start == NULL) {
82
+ pm_buffer_append_str(buffer, "nil", 3);
83
+ } else {
84
+ prettyprint_location(buffer, parser, &((pm_array_node_t *)node)->opening_loc);
85
+ }
86
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_array_node_t *)node)->closing_loc.start == NULL) {
87
+ pm_buffer_append_str(buffer, "nil", 3);
88
+ } else {
89
+ prettyprint_location(buffer, parser, &((pm_array_node_t *)node)->closing_loc);
90
+ }
91
+ pm_buffer_append_str(buffer, ")", 1);
92
+ break;
93
+ }
94
+ case PM_ARRAY_PATTERN_NODE: {
95
+ pm_buffer_append_str(buffer, "ArrayPatternNode(", 17);
96
+ if (((pm_array_pattern_node_t *)node)->constant == NULL) {
97
+ pm_buffer_append_str(buffer, "nil", 3);
98
+ } else {
99
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_array_pattern_node_t *)node)->constant);
100
+ }
101
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
102
+ for (uint32_t index = 0; index < ((pm_array_pattern_node_t *)node)->requireds.size; index++) {
103
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
104
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_array_pattern_node_t *) node)->requireds.nodes[index]);
105
+ }
106
+ pm_buffer_append_str(buffer, "]", 1);
107
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_array_pattern_node_t *)node)->rest == NULL) {
108
+ pm_buffer_append_str(buffer, "nil", 3);
109
+ } else {
110
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_array_pattern_node_t *)node)->rest);
111
+ }
112
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
113
+ for (uint32_t index = 0; index < ((pm_array_pattern_node_t *)node)->posts.size; index++) {
114
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
115
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_array_pattern_node_t *) node)->posts.nodes[index]);
116
+ }
117
+ pm_buffer_append_str(buffer, "]", 1);
118
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_array_pattern_node_t *)node)->opening_loc.start == NULL) {
119
+ pm_buffer_append_str(buffer, "nil", 3);
120
+ } else {
121
+ prettyprint_location(buffer, parser, &((pm_array_pattern_node_t *)node)->opening_loc);
122
+ }
123
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_array_pattern_node_t *)node)->closing_loc.start == NULL) {
124
+ pm_buffer_append_str(buffer, "nil", 3);
125
+ } else {
126
+ prettyprint_location(buffer, parser, &((pm_array_pattern_node_t *)node)->closing_loc);
127
+ }
128
+ pm_buffer_append_str(buffer, ")", 1);
129
+ break;
130
+ }
131
+ case PM_ASSOC_NODE: {
132
+ pm_buffer_append_str(buffer, "AssocNode(", 10);
133
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_assoc_node_t *)node)->key);
134
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_assoc_node_t *)node)->value == NULL) {
135
+ pm_buffer_append_str(buffer, "nil", 3);
136
+ } else {
137
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_assoc_node_t *)node)->value);
138
+ }
139
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_assoc_node_t *)node)->operator_loc.start == NULL) {
140
+ pm_buffer_append_str(buffer, "nil", 3);
141
+ } else {
142
+ prettyprint_location(buffer, parser, &((pm_assoc_node_t *)node)->operator_loc);
143
+ }
144
+ pm_buffer_append_str(buffer, ")", 1);
145
+ break;
146
+ }
147
+ case PM_ASSOC_SPLAT_NODE: {
148
+ pm_buffer_append_str(buffer, "AssocSplatNode(", 15);
149
+ if (((pm_assoc_splat_node_t *)node)->value == NULL) {
150
+ pm_buffer_append_str(buffer, "nil", 3);
151
+ } else {
152
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_assoc_splat_node_t *)node)->value);
153
+ }
154
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_assoc_splat_node_t *)node)->operator_loc);
155
+ pm_buffer_append_str(buffer, ")", 1);
156
+ break;
157
+ }
158
+ case PM_BACK_REFERENCE_READ_NODE: {
159
+ pm_buffer_append_str(buffer, "BackReferenceReadNode(", 22);
160
+ pm_buffer_append_str(buffer, ")", 1);
161
+ break;
162
+ }
163
+ case PM_BEGIN_NODE: {
164
+ pm_buffer_append_str(buffer, "BeginNode(", 10);
165
+ if (((pm_begin_node_t *)node)->begin_keyword_loc.start == NULL) {
166
+ pm_buffer_append_str(buffer, "nil", 3);
167
+ } else {
168
+ prettyprint_location(buffer, parser, &((pm_begin_node_t *)node)->begin_keyword_loc);
169
+ }
170
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_begin_node_t *)node)->statements == NULL) {
171
+ pm_buffer_append_str(buffer, "nil", 3);
172
+ } else {
173
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_begin_node_t *)node)->statements);
174
+ }
175
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_begin_node_t *)node)->rescue_clause == NULL) {
176
+ pm_buffer_append_str(buffer, "nil", 3);
177
+ } else {
178
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_begin_node_t *)node)->rescue_clause);
179
+ }
180
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_begin_node_t *)node)->else_clause == NULL) {
181
+ pm_buffer_append_str(buffer, "nil", 3);
182
+ } else {
183
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_begin_node_t *)node)->else_clause);
184
+ }
185
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_begin_node_t *)node)->ensure_clause == NULL) {
186
+ pm_buffer_append_str(buffer, "nil", 3);
187
+ } else {
188
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_begin_node_t *)node)->ensure_clause);
189
+ }
190
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_begin_node_t *)node)->end_keyword_loc.start == NULL) {
191
+ pm_buffer_append_str(buffer, "nil", 3);
192
+ } else {
193
+ prettyprint_location(buffer, parser, &((pm_begin_node_t *)node)->end_keyword_loc);
194
+ }
195
+ pm_buffer_append_str(buffer, ")", 1);
196
+ break;
197
+ }
198
+ case PM_BLOCK_ARGUMENT_NODE: {
199
+ pm_buffer_append_str(buffer, "BlockArgumentNode(", 18);
200
+ if (((pm_block_argument_node_t *)node)->expression == NULL) {
201
+ pm_buffer_append_str(buffer, "nil", 3);
202
+ } else {
203
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_block_argument_node_t *)node)->expression);
204
+ }
205
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_block_argument_node_t *)node)->operator_loc);
206
+ pm_buffer_append_str(buffer, ")", 1);
207
+ break;
208
+ }
209
+ case PM_BLOCK_LOCAL_VARIABLE_NODE: {
210
+ pm_buffer_append_str(buffer, "BlockLocalVariableNode(", 23);
211
+ char name_buffer[12];
212
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_block_local_variable_node_t *)node)->name);
213
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
214
+ pm_buffer_append_str(buffer, ")", 1);
215
+ break;
216
+ }
217
+ case PM_BLOCK_NODE: {
218
+ pm_buffer_append_str(buffer, "BlockNode(", 10);
219
+ pm_buffer_append_str(buffer, "[", 1);
220
+ for (uint32_t index = 0; index < ((pm_block_node_t *)node)->locals.size; index++) {
221
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
222
+ char locals_buffer[12];
223
+ snprintf(locals_buffer, sizeof(locals_buffer), "%u", ((pm_block_node_t *)node)->locals.ids[index]);
224
+ pm_buffer_append_str(buffer, locals_buffer, strlen(locals_buffer));
225
+ }
226
+ pm_buffer_append_str(buffer, "]", 1);
227
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_block_node_t *)node)->parameters == NULL) {
228
+ pm_buffer_append_str(buffer, "nil", 3);
229
+ } else {
230
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_block_node_t *)node)->parameters);
231
+ }
232
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_block_node_t *)node)->body == NULL) {
233
+ pm_buffer_append_str(buffer, "nil", 3);
234
+ } else {
235
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_block_node_t *)node)->body);
236
+ }
237
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_block_node_t *)node)->opening_loc);
238
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_block_node_t *)node)->closing_loc);
239
+ pm_buffer_append_str(buffer, ")", 1);
240
+ break;
241
+ }
242
+ case PM_BLOCK_PARAMETER_NODE: {
243
+ pm_buffer_append_str(buffer, "BlockParameterNode(", 19);
244
+ if (((pm_block_parameter_node_t *)node)->name == 0) {
245
+ pm_buffer_append_str(buffer, "nil", 3);
246
+ } else {
247
+ char name_buffer[12];
248
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_block_parameter_node_t *)node)->name);
249
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
250
+ }
251
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_block_parameter_node_t *)node)->name_loc.start == NULL) {
252
+ pm_buffer_append_str(buffer, "nil", 3);
253
+ } else {
254
+ prettyprint_location(buffer, parser, &((pm_block_parameter_node_t *)node)->name_loc);
255
+ }
256
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_block_parameter_node_t *)node)->operator_loc);
257
+ pm_buffer_append_str(buffer, ")", 1);
258
+ break;
259
+ }
260
+ case PM_BLOCK_PARAMETERS_NODE: {
261
+ pm_buffer_append_str(buffer, "BlockParametersNode(", 20);
262
+ if (((pm_block_parameters_node_t *)node)->parameters == NULL) {
263
+ pm_buffer_append_str(buffer, "nil", 3);
264
+ } else {
265
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_block_parameters_node_t *)node)->parameters);
266
+ }
267
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
268
+ for (uint32_t index = 0; index < ((pm_block_parameters_node_t *)node)->locals.size; index++) {
269
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
270
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_block_parameters_node_t *) node)->locals.nodes[index]);
271
+ }
272
+ pm_buffer_append_str(buffer, "]", 1);
273
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_block_parameters_node_t *)node)->opening_loc.start == NULL) {
274
+ pm_buffer_append_str(buffer, "nil", 3);
275
+ } else {
276
+ prettyprint_location(buffer, parser, &((pm_block_parameters_node_t *)node)->opening_loc);
277
+ }
278
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_block_parameters_node_t *)node)->closing_loc.start == NULL) {
279
+ pm_buffer_append_str(buffer, "nil", 3);
280
+ } else {
281
+ prettyprint_location(buffer, parser, &((pm_block_parameters_node_t *)node)->closing_loc);
282
+ }
283
+ pm_buffer_append_str(buffer, ")", 1);
284
+ break;
285
+ }
286
+ case PM_BREAK_NODE: {
287
+ pm_buffer_append_str(buffer, "BreakNode(", 10);
288
+ if (((pm_break_node_t *)node)->arguments == NULL) {
289
+ pm_buffer_append_str(buffer, "nil", 3);
290
+ } else {
291
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_break_node_t *)node)->arguments);
292
+ }
293
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_break_node_t *)node)->keyword_loc);
294
+ pm_buffer_append_str(buffer, ")", 1);
295
+ break;
296
+ }
297
+ case PM_CALL_AND_WRITE_NODE: {
298
+ pm_buffer_append_str(buffer, "CallAndWriteNode(", 17);
299
+ if (((pm_call_and_write_node_t *)node)->receiver == NULL) {
300
+ pm_buffer_append_str(buffer, "nil", 3);
301
+ } else {
302
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_call_and_write_node_t *)node)->receiver);
303
+ }
304
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_and_write_node_t *)node)->call_operator_loc.start == NULL) {
305
+ pm_buffer_append_str(buffer, "nil", 3);
306
+ } else {
307
+ prettyprint_location(buffer, parser, &((pm_call_and_write_node_t *)node)->call_operator_loc);
308
+ }
309
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_and_write_node_t *)node)->message_loc.start == NULL) {
310
+ pm_buffer_append_str(buffer, "nil", 3);
311
+ } else {
312
+ prettyprint_location(buffer, parser, &((pm_call_and_write_node_t *)node)->message_loc);
313
+ }
314
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_and_write_node_t *)node)->opening_loc.start == NULL) {
315
+ pm_buffer_append_str(buffer, "nil", 3);
316
+ } else {
317
+ prettyprint_location(buffer, parser, &((pm_call_and_write_node_t *)node)->opening_loc);
318
+ }
319
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_and_write_node_t *)node)->arguments == NULL) {
320
+ pm_buffer_append_str(buffer, "nil", 3);
321
+ } else {
322
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_call_and_write_node_t *)node)->arguments);
323
+ }
324
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_and_write_node_t *)node)->closing_loc.start == NULL) {
325
+ pm_buffer_append_str(buffer, "nil", 3);
326
+ } else {
327
+ prettyprint_location(buffer, parser, &((pm_call_and_write_node_t *)node)->closing_loc);
328
+ }
329
+ pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
330
+ snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags >> 2);
331
+ pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
332
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "\"", 1);
333
+ pm_buffer_append_bytes(buffer, pm_string_source(&((pm_call_and_write_node_t *)node)->read_name), pm_string_length(&((pm_call_and_write_node_t *)node)->read_name));
334
+ pm_buffer_append_str(buffer, "\"", 1);
335
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "\"", 1);
336
+ pm_buffer_append_bytes(buffer, pm_string_source(&((pm_call_and_write_node_t *)node)->write_name), pm_string_length(&((pm_call_and_write_node_t *)node)->write_name));
337
+ pm_buffer_append_str(buffer, "\"", 1);
338
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_call_and_write_node_t *)node)->operator_loc);
339
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_call_and_write_node_t *)node)->value);
340
+ pm_buffer_append_str(buffer, ")", 1);
341
+ break;
342
+ }
343
+ case PM_CALL_NODE: {
344
+ pm_buffer_append_str(buffer, "CallNode(", 9);
345
+ if (((pm_call_node_t *)node)->receiver == NULL) {
346
+ pm_buffer_append_str(buffer, "nil", 3);
347
+ } else {
348
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_call_node_t *)node)->receiver);
349
+ }
350
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_node_t *)node)->call_operator_loc.start == NULL) {
351
+ pm_buffer_append_str(buffer, "nil", 3);
352
+ } else {
353
+ prettyprint_location(buffer, parser, &((pm_call_node_t *)node)->call_operator_loc);
354
+ }
355
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_node_t *)node)->message_loc.start == NULL) {
356
+ pm_buffer_append_str(buffer, "nil", 3);
357
+ } else {
358
+ prettyprint_location(buffer, parser, &((pm_call_node_t *)node)->message_loc);
359
+ }
360
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_node_t *)node)->opening_loc.start == NULL) {
361
+ pm_buffer_append_str(buffer, "nil", 3);
362
+ } else {
363
+ prettyprint_location(buffer, parser, &((pm_call_node_t *)node)->opening_loc);
364
+ }
365
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_node_t *)node)->arguments == NULL) {
366
+ pm_buffer_append_str(buffer, "nil", 3);
367
+ } else {
368
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_call_node_t *)node)->arguments);
369
+ }
370
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_node_t *)node)->closing_loc.start == NULL) {
371
+ pm_buffer_append_str(buffer, "nil", 3);
372
+ } else {
373
+ prettyprint_location(buffer, parser, &((pm_call_node_t *)node)->closing_loc);
374
+ }
375
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_node_t *)node)->block == NULL) {
376
+ pm_buffer_append_str(buffer, "nil", 3);
377
+ } else {
378
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_call_node_t *)node)->block);
379
+ }
380
+ pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
381
+ snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags >> 2);
382
+ pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
383
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "\"", 1);
384
+ pm_buffer_append_bytes(buffer, pm_string_source(&((pm_call_node_t *)node)->name), pm_string_length(&((pm_call_node_t *)node)->name));
385
+ pm_buffer_append_str(buffer, "\"", 1);
386
+ pm_buffer_append_str(buffer, ")", 1);
387
+ break;
388
+ }
389
+ case PM_CALL_OPERATOR_WRITE_NODE: {
390
+ pm_buffer_append_str(buffer, "CallOperatorWriteNode(", 22);
391
+ if (((pm_call_operator_write_node_t *)node)->receiver == NULL) {
392
+ pm_buffer_append_str(buffer, "nil", 3);
393
+ } else {
394
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_call_operator_write_node_t *)node)->receiver);
395
+ }
396
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_operator_write_node_t *)node)->call_operator_loc.start == NULL) {
397
+ pm_buffer_append_str(buffer, "nil", 3);
398
+ } else {
399
+ prettyprint_location(buffer, parser, &((pm_call_operator_write_node_t *)node)->call_operator_loc);
400
+ }
401
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_operator_write_node_t *)node)->message_loc.start == NULL) {
402
+ pm_buffer_append_str(buffer, "nil", 3);
403
+ } else {
404
+ prettyprint_location(buffer, parser, &((pm_call_operator_write_node_t *)node)->message_loc);
405
+ }
406
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_operator_write_node_t *)node)->opening_loc.start == NULL) {
407
+ pm_buffer_append_str(buffer, "nil", 3);
408
+ } else {
409
+ prettyprint_location(buffer, parser, &((pm_call_operator_write_node_t *)node)->opening_loc);
410
+ }
411
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_operator_write_node_t *)node)->arguments == NULL) {
412
+ pm_buffer_append_str(buffer, "nil", 3);
413
+ } else {
414
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_call_operator_write_node_t *)node)->arguments);
415
+ }
416
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_operator_write_node_t *)node)->closing_loc.start == NULL) {
417
+ pm_buffer_append_str(buffer, "nil", 3);
418
+ } else {
419
+ prettyprint_location(buffer, parser, &((pm_call_operator_write_node_t *)node)->closing_loc);
420
+ }
421
+ pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
422
+ snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags >> 2);
423
+ pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
424
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "\"", 1);
425
+ pm_buffer_append_bytes(buffer, pm_string_source(&((pm_call_operator_write_node_t *)node)->read_name), pm_string_length(&((pm_call_operator_write_node_t *)node)->read_name));
426
+ pm_buffer_append_str(buffer, "\"", 1);
427
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "\"", 1);
428
+ pm_buffer_append_bytes(buffer, pm_string_source(&((pm_call_operator_write_node_t *)node)->write_name), pm_string_length(&((pm_call_operator_write_node_t *)node)->write_name));
429
+ pm_buffer_append_str(buffer, "\"", 1);
430
+ pm_buffer_append_str(buffer, ", ", 2); char operator_buffer[12];
431
+ snprintf(operator_buffer, sizeof(operator_buffer), "%u", ((pm_call_operator_write_node_t *)node)->operator);
432
+ pm_buffer_append_str(buffer, operator_buffer, strlen(operator_buffer));
433
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_call_operator_write_node_t *)node)->operator_loc);
434
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_call_operator_write_node_t *)node)->value);
435
+ pm_buffer_append_str(buffer, ")", 1);
436
+ break;
437
+ }
438
+ case PM_CALL_OR_WRITE_NODE: {
439
+ pm_buffer_append_str(buffer, "CallOrWriteNode(", 16);
440
+ if (((pm_call_or_write_node_t *)node)->receiver == NULL) {
441
+ pm_buffer_append_str(buffer, "nil", 3);
442
+ } else {
443
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_call_or_write_node_t *)node)->receiver);
444
+ }
445
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_or_write_node_t *)node)->call_operator_loc.start == NULL) {
446
+ pm_buffer_append_str(buffer, "nil", 3);
447
+ } else {
448
+ prettyprint_location(buffer, parser, &((pm_call_or_write_node_t *)node)->call_operator_loc);
449
+ }
450
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_or_write_node_t *)node)->message_loc.start == NULL) {
451
+ pm_buffer_append_str(buffer, "nil", 3);
452
+ } else {
453
+ prettyprint_location(buffer, parser, &((pm_call_or_write_node_t *)node)->message_loc);
454
+ }
455
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_or_write_node_t *)node)->opening_loc.start == NULL) {
456
+ pm_buffer_append_str(buffer, "nil", 3);
457
+ } else {
458
+ prettyprint_location(buffer, parser, &((pm_call_or_write_node_t *)node)->opening_loc);
459
+ }
460
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_or_write_node_t *)node)->arguments == NULL) {
461
+ pm_buffer_append_str(buffer, "nil", 3);
462
+ } else {
463
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_call_or_write_node_t *)node)->arguments);
464
+ }
465
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_call_or_write_node_t *)node)->closing_loc.start == NULL) {
466
+ pm_buffer_append_str(buffer, "nil", 3);
467
+ } else {
468
+ prettyprint_location(buffer, parser, &((pm_call_or_write_node_t *)node)->closing_loc);
469
+ }
470
+ pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
471
+ snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags >> 2);
472
+ pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
473
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "\"", 1);
474
+ pm_buffer_append_bytes(buffer, pm_string_source(&((pm_call_or_write_node_t *)node)->read_name), pm_string_length(&((pm_call_or_write_node_t *)node)->read_name));
475
+ pm_buffer_append_str(buffer, "\"", 1);
476
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "\"", 1);
477
+ pm_buffer_append_bytes(buffer, pm_string_source(&((pm_call_or_write_node_t *)node)->write_name), pm_string_length(&((pm_call_or_write_node_t *)node)->write_name));
478
+ pm_buffer_append_str(buffer, "\"", 1);
479
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_call_or_write_node_t *)node)->operator_loc);
480
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_call_or_write_node_t *)node)->value);
481
+ pm_buffer_append_str(buffer, ")", 1);
482
+ break;
483
+ }
484
+ case PM_CAPTURE_PATTERN_NODE: {
485
+ pm_buffer_append_str(buffer, "CapturePatternNode(", 19);
486
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_capture_pattern_node_t *)node)->value);
487
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_capture_pattern_node_t *)node)->target);
488
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_capture_pattern_node_t *)node)->operator_loc);
489
+ pm_buffer_append_str(buffer, ")", 1);
490
+ break;
491
+ }
492
+ case PM_CASE_NODE: {
493
+ pm_buffer_append_str(buffer, "CaseNode(", 9);
494
+ if (((pm_case_node_t *)node)->predicate == NULL) {
495
+ pm_buffer_append_str(buffer, "nil", 3);
496
+ } else {
497
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_case_node_t *)node)->predicate);
498
+ }
499
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
500
+ for (uint32_t index = 0; index < ((pm_case_node_t *)node)->conditions.size; index++) {
501
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
502
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_case_node_t *) node)->conditions.nodes[index]);
503
+ }
504
+ pm_buffer_append_str(buffer, "]", 1);
505
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_case_node_t *)node)->consequent == NULL) {
506
+ pm_buffer_append_str(buffer, "nil", 3);
507
+ } else {
508
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_case_node_t *)node)->consequent);
509
+ }
510
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_case_node_t *)node)->case_keyword_loc);
511
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_case_node_t *)node)->end_keyword_loc);
512
+ pm_buffer_append_str(buffer, ")", 1);
513
+ break;
514
+ }
515
+ case PM_CLASS_NODE: {
516
+ pm_buffer_append_str(buffer, "ClassNode(", 10);
517
+ pm_buffer_append_str(buffer, "[", 1);
518
+ for (uint32_t index = 0; index < ((pm_class_node_t *)node)->locals.size; index++) {
519
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
520
+ char locals_buffer[12];
521
+ snprintf(locals_buffer, sizeof(locals_buffer), "%u", ((pm_class_node_t *)node)->locals.ids[index]);
522
+ pm_buffer_append_str(buffer, locals_buffer, strlen(locals_buffer));
523
+ }
524
+ pm_buffer_append_str(buffer, "]", 1);
525
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_class_node_t *)node)->class_keyword_loc);
526
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_class_node_t *)node)->constant_path);
527
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_class_node_t *)node)->inheritance_operator_loc.start == NULL) {
528
+ pm_buffer_append_str(buffer, "nil", 3);
529
+ } else {
530
+ prettyprint_location(buffer, parser, &((pm_class_node_t *)node)->inheritance_operator_loc);
531
+ }
532
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_class_node_t *)node)->superclass == NULL) {
533
+ pm_buffer_append_str(buffer, "nil", 3);
534
+ } else {
535
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_class_node_t *)node)->superclass);
536
+ }
537
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_class_node_t *)node)->body == NULL) {
538
+ pm_buffer_append_str(buffer, "nil", 3);
539
+ } else {
540
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_class_node_t *)node)->body);
541
+ }
542
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_class_node_t *)node)->end_keyword_loc);
543
+ pm_buffer_append_str(buffer, ", ", 2); char name_buffer[12];
544
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_class_node_t *)node)->name);
545
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
546
+ pm_buffer_append_str(buffer, ")", 1);
547
+ break;
548
+ }
549
+ case PM_CLASS_VARIABLE_AND_WRITE_NODE: {
550
+ pm_buffer_append_str(buffer, "ClassVariableAndWriteNode(", 26);
551
+ char name_buffer[12];
552
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_class_variable_and_write_node_t *)node)->name);
553
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
554
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_class_variable_and_write_node_t *)node)->name_loc);
555
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_class_variable_and_write_node_t *)node)->operator_loc);
556
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_class_variable_and_write_node_t *)node)->value);
557
+ pm_buffer_append_str(buffer, ")", 1);
558
+ break;
559
+ }
560
+ case PM_CLASS_VARIABLE_OPERATOR_WRITE_NODE: {
561
+ pm_buffer_append_str(buffer, "ClassVariableOperatorWriteNode(", 31);
562
+ char name_buffer[12];
563
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_class_variable_operator_write_node_t *)node)->name);
564
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
565
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_class_variable_operator_write_node_t *)node)->name_loc);
566
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_class_variable_operator_write_node_t *)node)->operator_loc);
567
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_class_variable_operator_write_node_t *)node)->value);
568
+ pm_buffer_append_str(buffer, ", ", 2); char operator_buffer[12];
569
+ snprintf(operator_buffer, sizeof(operator_buffer), "%u", ((pm_class_variable_operator_write_node_t *)node)->operator);
570
+ pm_buffer_append_str(buffer, operator_buffer, strlen(operator_buffer));
571
+ pm_buffer_append_str(buffer, ")", 1);
572
+ break;
573
+ }
574
+ case PM_CLASS_VARIABLE_OR_WRITE_NODE: {
575
+ pm_buffer_append_str(buffer, "ClassVariableOrWriteNode(", 25);
576
+ char name_buffer[12];
577
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_class_variable_or_write_node_t *)node)->name);
578
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
579
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_class_variable_or_write_node_t *)node)->name_loc);
580
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_class_variable_or_write_node_t *)node)->operator_loc);
581
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_class_variable_or_write_node_t *)node)->value);
582
+ pm_buffer_append_str(buffer, ")", 1);
583
+ break;
584
+ }
585
+ case PM_CLASS_VARIABLE_READ_NODE: {
586
+ pm_buffer_append_str(buffer, "ClassVariableReadNode(", 22);
587
+ char name_buffer[12];
588
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_class_variable_read_node_t *)node)->name);
589
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
590
+ pm_buffer_append_str(buffer, ")", 1);
591
+ break;
592
+ }
593
+ case PM_CLASS_VARIABLE_TARGET_NODE: {
594
+ pm_buffer_append_str(buffer, "ClassVariableTargetNode(", 24);
595
+ char name_buffer[12];
596
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_class_variable_target_node_t *)node)->name);
597
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
598
+ pm_buffer_append_str(buffer, ")", 1);
599
+ break;
600
+ }
601
+ case PM_CLASS_VARIABLE_WRITE_NODE: {
602
+ pm_buffer_append_str(buffer, "ClassVariableWriteNode(", 23);
603
+ char name_buffer[12];
604
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_class_variable_write_node_t *)node)->name);
605
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
606
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_class_variable_write_node_t *)node)->name_loc);
607
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_class_variable_write_node_t *)node)->value);
608
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_class_variable_write_node_t *)node)->operator_loc.start == NULL) {
609
+ pm_buffer_append_str(buffer, "nil", 3);
610
+ } else {
611
+ prettyprint_location(buffer, parser, &((pm_class_variable_write_node_t *)node)->operator_loc);
612
+ }
613
+ pm_buffer_append_str(buffer, ")", 1);
614
+ break;
615
+ }
616
+ case PM_CONSTANT_AND_WRITE_NODE: {
617
+ pm_buffer_append_str(buffer, "ConstantAndWriteNode(", 21);
618
+ char name_buffer[12];
619
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_constant_and_write_node_t *)node)->name);
620
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
621
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_constant_and_write_node_t *)node)->name_loc);
622
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_constant_and_write_node_t *)node)->operator_loc);
623
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_constant_and_write_node_t *)node)->value);
624
+ pm_buffer_append_str(buffer, ")", 1);
625
+ break;
626
+ }
627
+ case PM_CONSTANT_OPERATOR_WRITE_NODE: {
628
+ pm_buffer_append_str(buffer, "ConstantOperatorWriteNode(", 26);
629
+ char name_buffer[12];
630
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_constant_operator_write_node_t *)node)->name);
631
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
632
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_constant_operator_write_node_t *)node)->name_loc);
633
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_constant_operator_write_node_t *)node)->operator_loc);
634
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_constant_operator_write_node_t *)node)->value);
635
+ pm_buffer_append_str(buffer, ", ", 2); char operator_buffer[12];
636
+ snprintf(operator_buffer, sizeof(operator_buffer), "%u", ((pm_constant_operator_write_node_t *)node)->operator);
637
+ pm_buffer_append_str(buffer, operator_buffer, strlen(operator_buffer));
638
+ pm_buffer_append_str(buffer, ")", 1);
639
+ break;
640
+ }
641
+ case PM_CONSTANT_OR_WRITE_NODE: {
642
+ pm_buffer_append_str(buffer, "ConstantOrWriteNode(", 20);
643
+ char name_buffer[12];
644
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_constant_or_write_node_t *)node)->name);
645
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
646
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_constant_or_write_node_t *)node)->name_loc);
647
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_constant_or_write_node_t *)node)->operator_loc);
648
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_constant_or_write_node_t *)node)->value);
649
+ pm_buffer_append_str(buffer, ")", 1);
650
+ break;
651
+ }
652
+ case PM_CONSTANT_PATH_AND_WRITE_NODE: {
653
+ pm_buffer_append_str(buffer, "ConstantPathAndWriteNode(", 25);
654
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_constant_path_and_write_node_t *)node)->target);
655
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_constant_path_and_write_node_t *)node)->operator_loc);
656
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_constant_path_and_write_node_t *)node)->value);
657
+ pm_buffer_append_str(buffer, ")", 1);
658
+ break;
659
+ }
660
+ case PM_CONSTANT_PATH_NODE: {
661
+ pm_buffer_append_str(buffer, "ConstantPathNode(", 17);
662
+ if (((pm_constant_path_node_t *)node)->parent == NULL) {
663
+ pm_buffer_append_str(buffer, "nil", 3);
664
+ } else {
665
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_constant_path_node_t *)node)->parent);
666
+ }
667
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_constant_path_node_t *)node)->child);
668
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_constant_path_node_t *)node)->delimiter_loc);
669
+ pm_buffer_append_str(buffer, ")", 1);
670
+ break;
671
+ }
672
+ case PM_CONSTANT_PATH_OPERATOR_WRITE_NODE: {
673
+ pm_buffer_append_str(buffer, "ConstantPathOperatorWriteNode(", 30);
674
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_constant_path_operator_write_node_t *)node)->target);
675
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_constant_path_operator_write_node_t *)node)->operator_loc);
676
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_constant_path_operator_write_node_t *)node)->value);
677
+ pm_buffer_append_str(buffer, ", ", 2); char operator_buffer[12];
678
+ snprintf(operator_buffer, sizeof(operator_buffer), "%u", ((pm_constant_path_operator_write_node_t *)node)->operator);
679
+ pm_buffer_append_str(buffer, operator_buffer, strlen(operator_buffer));
680
+ pm_buffer_append_str(buffer, ")", 1);
681
+ break;
682
+ }
683
+ case PM_CONSTANT_PATH_OR_WRITE_NODE: {
684
+ pm_buffer_append_str(buffer, "ConstantPathOrWriteNode(", 24);
685
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_constant_path_or_write_node_t *)node)->target);
686
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_constant_path_or_write_node_t *)node)->operator_loc);
687
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_constant_path_or_write_node_t *)node)->value);
688
+ pm_buffer_append_str(buffer, ")", 1);
689
+ break;
690
+ }
691
+ case PM_CONSTANT_PATH_TARGET_NODE: {
692
+ pm_buffer_append_str(buffer, "ConstantPathTargetNode(", 23);
693
+ if (((pm_constant_path_target_node_t *)node)->parent == NULL) {
694
+ pm_buffer_append_str(buffer, "nil", 3);
695
+ } else {
696
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_constant_path_target_node_t *)node)->parent);
697
+ }
698
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_constant_path_target_node_t *)node)->child);
699
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_constant_path_target_node_t *)node)->delimiter_loc);
700
+ pm_buffer_append_str(buffer, ")", 1);
701
+ break;
702
+ }
703
+ case PM_CONSTANT_PATH_WRITE_NODE: {
704
+ pm_buffer_append_str(buffer, "ConstantPathWriteNode(", 22);
705
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_constant_path_write_node_t *)node)->target);
706
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_constant_path_write_node_t *)node)->operator_loc);
707
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_constant_path_write_node_t *)node)->value);
708
+ pm_buffer_append_str(buffer, ")", 1);
709
+ break;
710
+ }
711
+ case PM_CONSTANT_READ_NODE: {
712
+ pm_buffer_append_str(buffer, "ConstantReadNode(", 17);
713
+ char name_buffer[12];
714
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_constant_read_node_t *)node)->name);
715
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
716
+ pm_buffer_append_str(buffer, ")", 1);
717
+ break;
718
+ }
719
+ case PM_CONSTANT_TARGET_NODE: {
720
+ pm_buffer_append_str(buffer, "ConstantTargetNode(", 19);
721
+ char name_buffer[12];
722
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_constant_target_node_t *)node)->name);
723
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
724
+ pm_buffer_append_str(buffer, ")", 1);
725
+ break;
726
+ }
727
+ case PM_CONSTANT_WRITE_NODE: {
728
+ pm_buffer_append_str(buffer, "ConstantWriteNode(", 18);
729
+ char name_buffer[12];
730
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_constant_write_node_t *)node)->name);
731
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
732
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_constant_write_node_t *)node)->name_loc);
733
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_constant_write_node_t *)node)->value);
734
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_constant_write_node_t *)node)->operator_loc);
735
+ pm_buffer_append_str(buffer, ")", 1);
736
+ break;
737
+ }
738
+ case PM_DEF_NODE: {
739
+ pm_buffer_append_str(buffer, "DefNode(", 8);
740
+ char name_buffer[12];
741
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_def_node_t *)node)->name);
742
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
743
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_def_node_t *)node)->name_loc);
744
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_def_node_t *)node)->receiver == NULL) {
745
+ pm_buffer_append_str(buffer, "nil", 3);
746
+ } else {
747
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_def_node_t *)node)->receiver);
748
+ }
749
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_def_node_t *)node)->parameters == NULL) {
750
+ pm_buffer_append_str(buffer, "nil", 3);
751
+ } else {
752
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_def_node_t *)node)->parameters);
753
+ }
754
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_def_node_t *)node)->body == NULL) {
755
+ pm_buffer_append_str(buffer, "nil", 3);
756
+ } else {
757
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_def_node_t *)node)->body);
758
+ }
759
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
760
+ for (uint32_t index = 0; index < ((pm_def_node_t *)node)->locals.size; index++) {
761
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
762
+ char locals_buffer[12];
763
+ snprintf(locals_buffer, sizeof(locals_buffer), "%u", ((pm_def_node_t *)node)->locals.ids[index]);
764
+ pm_buffer_append_str(buffer, locals_buffer, strlen(locals_buffer));
765
+ }
766
+ pm_buffer_append_str(buffer, "]", 1);
767
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_def_node_t *)node)->def_keyword_loc);
768
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_def_node_t *)node)->operator_loc.start == NULL) {
769
+ pm_buffer_append_str(buffer, "nil", 3);
770
+ } else {
771
+ prettyprint_location(buffer, parser, &((pm_def_node_t *)node)->operator_loc);
772
+ }
773
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_def_node_t *)node)->lparen_loc.start == NULL) {
774
+ pm_buffer_append_str(buffer, "nil", 3);
775
+ } else {
776
+ prettyprint_location(buffer, parser, &((pm_def_node_t *)node)->lparen_loc);
777
+ }
778
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_def_node_t *)node)->rparen_loc.start == NULL) {
779
+ pm_buffer_append_str(buffer, "nil", 3);
780
+ } else {
781
+ prettyprint_location(buffer, parser, &((pm_def_node_t *)node)->rparen_loc);
782
+ }
783
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_def_node_t *)node)->equal_loc.start == NULL) {
784
+ pm_buffer_append_str(buffer, "nil", 3);
785
+ } else {
786
+ prettyprint_location(buffer, parser, &((pm_def_node_t *)node)->equal_loc);
787
+ }
788
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_def_node_t *)node)->end_keyword_loc.start == NULL) {
789
+ pm_buffer_append_str(buffer, "nil", 3);
790
+ } else {
791
+ prettyprint_location(buffer, parser, &((pm_def_node_t *)node)->end_keyword_loc);
792
+ }
793
+ pm_buffer_append_str(buffer, ")", 1);
794
+ break;
795
+ }
796
+ case PM_DEFINED_NODE: {
797
+ pm_buffer_append_str(buffer, "DefinedNode(", 12);
798
+ if (((pm_defined_node_t *)node)->lparen_loc.start == NULL) {
799
+ pm_buffer_append_str(buffer, "nil", 3);
800
+ } else {
801
+ prettyprint_location(buffer, parser, &((pm_defined_node_t *)node)->lparen_loc);
802
+ }
803
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_defined_node_t *)node)->value);
804
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_defined_node_t *)node)->rparen_loc.start == NULL) {
805
+ pm_buffer_append_str(buffer, "nil", 3);
806
+ } else {
807
+ prettyprint_location(buffer, parser, &((pm_defined_node_t *)node)->rparen_loc);
808
+ }
809
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_defined_node_t *)node)->keyword_loc);
810
+ pm_buffer_append_str(buffer, ")", 1);
811
+ break;
812
+ }
813
+ case PM_ELSE_NODE: {
814
+ pm_buffer_append_str(buffer, "ElseNode(", 9);
815
+ prettyprint_location(buffer, parser, &((pm_else_node_t *)node)->else_keyword_loc);
816
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_else_node_t *)node)->statements == NULL) {
817
+ pm_buffer_append_str(buffer, "nil", 3);
818
+ } else {
819
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_else_node_t *)node)->statements);
820
+ }
821
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_else_node_t *)node)->end_keyword_loc.start == NULL) {
822
+ pm_buffer_append_str(buffer, "nil", 3);
823
+ } else {
824
+ prettyprint_location(buffer, parser, &((pm_else_node_t *)node)->end_keyword_loc);
825
+ }
826
+ pm_buffer_append_str(buffer, ")", 1);
827
+ break;
828
+ }
829
+ case PM_EMBEDDED_STATEMENTS_NODE: {
830
+ pm_buffer_append_str(buffer, "EmbeddedStatementsNode(", 23);
831
+ prettyprint_location(buffer, parser, &((pm_embedded_statements_node_t *)node)->opening_loc);
832
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_embedded_statements_node_t *)node)->statements == NULL) {
833
+ pm_buffer_append_str(buffer, "nil", 3);
834
+ } else {
835
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_embedded_statements_node_t *)node)->statements);
836
+ }
837
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_embedded_statements_node_t *)node)->closing_loc);
838
+ pm_buffer_append_str(buffer, ")", 1);
839
+ break;
840
+ }
841
+ case PM_EMBEDDED_VARIABLE_NODE: {
842
+ pm_buffer_append_str(buffer, "EmbeddedVariableNode(", 21);
843
+ prettyprint_location(buffer, parser, &((pm_embedded_variable_node_t *)node)->operator_loc);
844
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_embedded_variable_node_t *)node)->variable);
845
+ pm_buffer_append_str(buffer, ")", 1);
846
+ break;
847
+ }
848
+ case PM_ENSURE_NODE: {
849
+ pm_buffer_append_str(buffer, "EnsureNode(", 11);
850
+ prettyprint_location(buffer, parser, &((pm_ensure_node_t *)node)->ensure_keyword_loc);
851
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_ensure_node_t *)node)->statements == NULL) {
852
+ pm_buffer_append_str(buffer, "nil", 3);
853
+ } else {
854
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_ensure_node_t *)node)->statements);
855
+ }
856
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_ensure_node_t *)node)->end_keyword_loc);
857
+ pm_buffer_append_str(buffer, ")", 1);
858
+ break;
859
+ }
860
+ case PM_FALSE_NODE: {
861
+ pm_buffer_append_str(buffer, "FalseNode(", 10);
862
+ pm_buffer_append_str(buffer, ")", 1);
863
+ break;
864
+ }
865
+ case PM_FIND_PATTERN_NODE: {
866
+ pm_buffer_append_str(buffer, "FindPatternNode(", 16);
867
+ if (((pm_find_pattern_node_t *)node)->constant == NULL) {
868
+ pm_buffer_append_str(buffer, "nil", 3);
869
+ } else {
870
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_find_pattern_node_t *)node)->constant);
871
+ }
872
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_find_pattern_node_t *)node)->left);
873
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
874
+ for (uint32_t index = 0; index < ((pm_find_pattern_node_t *)node)->requireds.size; index++) {
875
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
876
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_find_pattern_node_t *) node)->requireds.nodes[index]);
877
+ }
878
+ pm_buffer_append_str(buffer, "]", 1);
879
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_find_pattern_node_t *)node)->right);
880
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_find_pattern_node_t *)node)->opening_loc.start == NULL) {
881
+ pm_buffer_append_str(buffer, "nil", 3);
882
+ } else {
883
+ prettyprint_location(buffer, parser, &((pm_find_pattern_node_t *)node)->opening_loc);
884
+ }
885
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_find_pattern_node_t *)node)->closing_loc.start == NULL) {
886
+ pm_buffer_append_str(buffer, "nil", 3);
887
+ } else {
888
+ prettyprint_location(buffer, parser, &((pm_find_pattern_node_t *)node)->closing_loc);
889
+ }
890
+ pm_buffer_append_str(buffer, ")", 1);
891
+ break;
892
+ }
893
+ case PM_FLIP_FLOP_NODE: {
894
+ pm_buffer_append_str(buffer, "FlipFlopNode(", 13);
895
+ if (((pm_flip_flop_node_t *)node)->left == NULL) {
896
+ pm_buffer_append_str(buffer, "nil", 3);
897
+ } else {
898
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_flip_flop_node_t *)node)->left);
899
+ }
900
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_flip_flop_node_t *)node)->right == NULL) {
901
+ pm_buffer_append_str(buffer, "nil", 3);
902
+ } else {
903
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_flip_flop_node_t *)node)->right);
904
+ }
905
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_flip_flop_node_t *)node)->operator_loc);
906
+ pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
907
+ snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags >> 2);
908
+ pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
909
+ pm_buffer_append_str(buffer, ")", 1);
910
+ break;
911
+ }
912
+ case PM_FLOAT_NODE: {
913
+ pm_buffer_append_str(buffer, "FloatNode(", 10);
914
+ pm_buffer_append_str(buffer, ")", 1);
915
+ break;
916
+ }
917
+ case PM_FOR_NODE: {
918
+ pm_buffer_append_str(buffer, "ForNode(", 8);
919
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_for_node_t *)node)->index);
920
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_for_node_t *)node)->collection);
921
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_for_node_t *)node)->statements == NULL) {
922
+ pm_buffer_append_str(buffer, "nil", 3);
923
+ } else {
924
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_for_node_t *)node)->statements);
925
+ }
926
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_for_node_t *)node)->for_keyword_loc);
927
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_for_node_t *)node)->in_keyword_loc);
928
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_for_node_t *)node)->do_keyword_loc.start == NULL) {
929
+ pm_buffer_append_str(buffer, "nil", 3);
930
+ } else {
931
+ prettyprint_location(buffer, parser, &((pm_for_node_t *)node)->do_keyword_loc);
932
+ }
933
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_for_node_t *)node)->end_keyword_loc);
934
+ pm_buffer_append_str(buffer, ")", 1);
935
+ break;
936
+ }
937
+ case PM_FORWARDING_ARGUMENTS_NODE: {
938
+ pm_buffer_append_str(buffer, "ForwardingArgumentsNode(", 24);
939
+ pm_buffer_append_str(buffer, ")", 1);
940
+ break;
941
+ }
942
+ case PM_FORWARDING_PARAMETER_NODE: {
943
+ pm_buffer_append_str(buffer, "ForwardingParameterNode(", 24);
944
+ pm_buffer_append_str(buffer, ")", 1);
945
+ break;
946
+ }
947
+ case PM_FORWARDING_SUPER_NODE: {
948
+ pm_buffer_append_str(buffer, "ForwardingSuperNode(", 20);
949
+ if (((pm_forwarding_super_node_t *)node)->block == NULL) {
950
+ pm_buffer_append_str(buffer, "nil", 3);
951
+ } else {
952
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_forwarding_super_node_t *)node)->block);
953
+ }
954
+ pm_buffer_append_str(buffer, ")", 1);
955
+ break;
956
+ }
957
+ case PM_GLOBAL_VARIABLE_AND_WRITE_NODE: {
958
+ pm_buffer_append_str(buffer, "GlobalVariableAndWriteNode(", 27);
959
+ char name_buffer[12];
960
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_global_variable_and_write_node_t *)node)->name);
961
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
962
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_global_variable_and_write_node_t *)node)->name_loc);
963
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_global_variable_and_write_node_t *)node)->operator_loc);
964
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_global_variable_and_write_node_t *)node)->value);
965
+ pm_buffer_append_str(buffer, ")", 1);
966
+ break;
967
+ }
968
+ case PM_GLOBAL_VARIABLE_OPERATOR_WRITE_NODE: {
969
+ pm_buffer_append_str(buffer, "GlobalVariableOperatorWriteNode(", 32);
970
+ char name_buffer[12];
971
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_global_variable_operator_write_node_t *)node)->name);
972
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
973
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_global_variable_operator_write_node_t *)node)->name_loc);
974
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_global_variable_operator_write_node_t *)node)->operator_loc);
975
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_global_variable_operator_write_node_t *)node)->value);
976
+ pm_buffer_append_str(buffer, ", ", 2); char operator_buffer[12];
977
+ snprintf(operator_buffer, sizeof(operator_buffer), "%u", ((pm_global_variable_operator_write_node_t *)node)->operator);
978
+ pm_buffer_append_str(buffer, operator_buffer, strlen(operator_buffer));
979
+ pm_buffer_append_str(buffer, ")", 1);
980
+ break;
981
+ }
982
+ case PM_GLOBAL_VARIABLE_OR_WRITE_NODE: {
983
+ pm_buffer_append_str(buffer, "GlobalVariableOrWriteNode(", 26);
984
+ char name_buffer[12];
985
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_global_variable_or_write_node_t *)node)->name);
986
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
987
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_global_variable_or_write_node_t *)node)->name_loc);
988
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_global_variable_or_write_node_t *)node)->operator_loc);
989
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_global_variable_or_write_node_t *)node)->value);
990
+ pm_buffer_append_str(buffer, ")", 1);
991
+ break;
992
+ }
993
+ case PM_GLOBAL_VARIABLE_READ_NODE: {
994
+ pm_buffer_append_str(buffer, "GlobalVariableReadNode(", 23);
995
+ char name_buffer[12];
996
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_global_variable_read_node_t *)node)->name);
997
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
998
+ pm_buffer_append_str(buffer, ")", 1);
999
+ break;
1000
+ }
1001
+ case PM_GLOBAL_VARIABLE_TARGET_NODE: {
1002
+ pm_buffer_append_str(buffer, "GlobalVariableTargetNode(", 25);
1003
+ char name_buffer[12];
1004
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_global_variable_target_node_t *)node)->name);
1005
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1006
+ pm_buffer_append_str(buffer, ")", 1);
1007
+ break;
1008
+ }
1009
+ case PM_GLOBAL_VARIABLE_WRITE_NODE: {
1010
+ pm_buffer_append_str(buffer, "GlobalVariableWriteNode(", 24);
1011
+ char name_buffer[12];
1012
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_global_variable_write_node_t *)node)->name);
1013
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1014
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_global_variable_write_node_t *)node)->name_loc);
1015
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_global_variable_write_node_t *)node)->value);
1016
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_global_variable_write_node_t *)node)->operator_loc);
1017
+ pm_buffer_append_str(buffer, ")", 1);
1018
+ break;
1019
+ }
1020
+ case PM_HASH_NODE: {
1021
+ pm_buffer_append_str(buffer, "HashNode(", 9);
1022
+ prettyprint_location(buffer, parser, &((pm_hash_node_t *)node)->opening_loc);
1023
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
1024
+ for (uint32_t index = 0; index < ((pm_hash_node_t *)node)->elements.size; index++) {
1025
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1026
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_hash_node_t *) node)->elements.nodes[index]);
1027
+ }
1028
+ pm_buffer_append_str(buffer, "]", 1);
1029
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_hash_node_t *)node)->closing_loc);
1030
+ pm_buffer_append_str(buffer, ")", 1);
1031
+ break;
1032
+ }
1033
+ case PM_HASH_PATTERN_NODE: {
1034
+ pm_buffer_append_str(buffer, "HashPatternNode(", 16);
1035
+ if (((pm_hash_pattern_node_t *)node)->constant == NULL) {
1036
+ pm_buffer_append_str(buffer, "nil", 3);
1037
+ } else {
1038
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_hash_pattern_node_t *)node)->constant);
1039
+ }
1040
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
1041
+ for (uint32_t index = 0; index < ((pm_hash_pattern_node_t *)node)->assocs.size; index++) {
1042
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1043
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_hash_pattern_node_t *) node)->assocs.nodes[index]);
1044
+ }
1045
+ pm_buffer_append_str(buffer, "]", 1);
1046
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_hash_pattern_node_t *)node)->kwrest == NULL) {
1047
+ pm_buffer_append_str(buffer, "nil", 3);
1048
+ } else {
1049
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_hash_pattern_node_t *)node)->kwrest);
1050
+ }
1051
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_hash_pattern_node_t *)node)->opening_loc.start == NULL) {
1052
+ pm_buffer_append_str(buffer, "nil", 3);
1053
+ } else {
1054
+ prettyprint_location(buffer, parser, &((pm_hash_pattern_node_t *)node)->opening_loc);
1055
+ }
1056
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_hash_pattern_node_t *)node)->closing_loc.start == NULL) {
1057
+ pm_buffer_append_str(buffer, "nil", 3);
1058
+ } else {
1059
+ prettyprint_location(buffer, parser, &((pm_hash_pattern_node_t *)node)->closing_loc);
1060
+ }
1061
+ pm_buffer_append_str(buffer, ")", 1);
1062
+ break;
1063
+ }
1064
+ case PM_IF_NODE: {
1065
+ pm_buffer_append_str(buffer, "IfNode(", 7);
1066
+ if (((pm_if_node_t *)node)->if_keyword_loc.start == NULL) {
1067
+ pm_buffer_append_str(buffer, "nil", 3);
1068
+ } else {
1069
+ prettyprint_location(buffer, parser, &((pm_if_node_t *)node)->if_keyword_loc);
1070
+ }
1071
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_if_node_t *)node)->predicate);
1072
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_if_node_t *)node)->statements == NULL) {
1073
+ pm_buffer_append_str(buffer, "nil", 3);
1074
+ } else {
1075
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_if_node_t *)node)->statements);
1076
+ }
1077
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_if_node_t *)node)->consequent == NULL) {
1078
+ pm_buffer_append_str(buffer, "nil", 3);
1079
+ } else {
1080
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_if_node_t *)node)->consequent);
1081
+ }
1082
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_if_node_t *)node)->end_keyword_loc.start == NULL) {
1083
+ pm_buffer_append_str(buffer, "nil", 3);
1084
+ } else {
1085
+ prettyprint_location(buffer, parser, &((pm_if_node_t *)node)->end_keyword_loc);
1086
+ }
1087
+ pm_buffer_append_str(buffer, ")", 1);
1088
+ break;
1089
+ }
1090
+ case PM_IMAGINARY_NODE: {
1091
+ pm_buffer_append_str(buffer, "ImaginaryNode(", 14);
1092
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_imaginary_node_t *)node)->numeric);
1093
+ pm_buffer_append_str(buffer, ")", 1);
1094
+ break;
1095
+ }
1096
+ case PM_IMPLICIT_NODE: {
1097
+ pm_buffer_append_str(buffer, "ImplicitNode(", 13);
1098
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_implicit_node_t *)node)->value);
1099
+ pm_buffer_append_str(buffer, ")", 1);
1100
+ break;
1101
+ }
1102
+ case PM_IN_NODE: {
1103
+ pm_buffer_append_str(buffer, "InNode(", 7);
1104
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_in_node_t *)node)->pattern);
1105
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_in_node_t *)node)->statements == NULL) {
1106
+ pm_buffer_append_str(buffer, "nil", 3);
1107
+ } else {
1108
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_in_node_t *)node)->statements);
1109
+ }
1110
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_in_node_t *)node)->in_loc);
1111
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_in_node_t *)node)->then_loc.start == NULL) {
1112
+ pm_buffer_append_str(buffer, "nil", 3);
1113
+ } else {
1114
+ prettyprint_location(buffer, parser, &((pm_in_node_t *)node)->then_loc);
1115
+ }
1116
+ pm_buffer_append_str(buffer, ")", 1);
1117
+ break;
1118
+ }
1119
+ case PM_INSTANCE_VARIABLE_AND_WRITE_NODE: {
1120
+ pm_buffer_append_str(buffer, "InstanceVariableAndWriteNode(", 29);
1121
+ char name_buffer[12];
1122
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_instance_variable_and_write_node_t *)node)->name);
1123
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1124
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_instance_variable_and_write_node_t *)node)->name_loc);
1125
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_instance_variable_and_write_node_t *)node)->operator_loc);
1126
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_instance_variable_and_write_node_t *)node)->value);
1127
+ pm_buffer_append_str(buffer, ")", 1);
1128
+ break;
1129
+ }
1130
+ case PM_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE: {
1131
+ pm_buffer_append_str(buffer, "InstanceVariableOperatorWriteNode(", 34);
1132
+ char name_buffer[12];
1133
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_instance_variable_operator_write_node_t *)node)->name);
1134
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1135
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_instance_variable_operator_write_node_t *)node)->name_loc);
1136
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_instance_variable_operator_write_node_t *)node)->operator_loc);
1137
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_instance_variable_operator_write_node_t *)node)->value);
1138
+ pm_buffer_append_str(buffer, ", ", 2); char operator_buffer[12];
1139
+ snprintf(operator_buffer, sizeof(operator_buffer), "%u", ((pm_instance_variable_operator_write_node_t *)node)->operator);
1140
+ pm_buffer_append_str(buffer, operator_buffer, strlen(operator_buffer));
1141
+ pm_buffer_append_str(buffer, ")", 1);
1142
+ break;
1143
+ }
1144
+ case PM_INSTANCE_VARIABLE_OR_WRITE_NODE: {
1145
+ pm_buffer_append_str(buffer, "InstanceVariableOrWriteNode(", 28);
1146
+ char name_buffer[12];
1147
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_instance_variable_or_write_node_t *)node)->name);
1148
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1149
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_instance_variable_or_write_node_t *)node)->name_loc);
1150
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_instance_variable_or_write_node_t *)node)->operator_loc);
1151
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_instance_variable_or_write_node_t *)node)->value);
1152
+ pm_buffer_append_str(buffer, ")", 1);
1153
+ break;
1154
+ }
1155
+ case PM_INSTANCE_VARIABLE_READ_NODE: {
1156
+ pm_buffer_append_str(buffer, "InstanceVariableReadNode(", 25);
1157
+ char name_buffer[12];
1158
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_instance_variable_read_node_t *)node)->name);
1159
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1160
+ pm_buffer_append_str(buffer, ")", 1);
1161
+ break;
1162
+ }
1163
+ case PM_INSTANCE_VARIABLE_TARGET_NODE: {
1164
+ pm_buffer_append_str(buffer, "InstanceVariableTargetNode(", 27);
1165
+ char name_buffer[12];
1166
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_instance_variable_target_node_t *)node)->name);
1167
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1168
+ pm_buffer_append_str(buffer, ")", 1);
1169
+ break;
1170
+ }
1171
+ case PM_INSTANCE_VARIABLE_WRITE_NODE: {
1172
+ pm_buffer_append_str(buffer, "InstanceVariableWriteNode(", 26);
1173
+ char name_buffer[12];
1174
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_instance_variable_write_node_t *)node)->name);
1175
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1176
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_instance_variable_write_node_t *)node)->name_loc);
1177
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_instance_variable_write_node_t *)node)->value);
1178
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_instance_variable_write_node_t *)node)->operator_loc);
1179
+ pm_buffer_append_str(buffer, ")", 1);
1180
+ break;
1181
+ }
1182
+ case PM_INTEGER_NODE: {
1183
+ pm_buffer_append_str(buffer, "IntegerNode(", 12);
1184
+ char flags_buffer[12];
1185
+ snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags >> 2);
1186
+ pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
1187
+ pm_buffer_append_str(buffer, ")", 1);
1188
+ break;
1189
+ }
1190
+ case PM_INTERPOLATED_MATCH_LAST_LINE_NODE: {
1191
+ pm_buffer_append_str(buffer, "InterpolatedMatchLastLineNode(", 30);
1192
+ prettyprint_location(buffer, parser, &((pm_interpolated_match_last_line_node_t *)node)->opening_loc);
1193
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
1194
+ for (uint32_t index = 0; index < ((pm_interpolated_match_last_line_node_t *)node)->parts.size; index++) {
1195
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1196
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_interpolated_match_last_line_node_t *) node)->parts.nodes[index]);
1197
+ }
1198
+ pm_buffer_append_str(buffer, "]", 1);
1199
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_interpolated_match_last_line_node_t *)node)->closing_loc);
1200
+ pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
1201
+ snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags >> 2);
1202
+ pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
1203
+ pm_buffer_append_str(buffer, ")", 1);
1204
+ break;
1205
+ }
1206
+ case PM_INTERPOLATED_REGULAR_EXPRESSION_NODE: {
1207
+ pm_buffer_append_str(buffer, "InterpolatedRegularExpressionNode(", 34);
1208
+ prettyprint_location(buffer, parser, &((pm_interpolated_regular_expression_node_t *)node)->opening_loc);
1209
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
1210
+ for (uint32_t index = 0; index < ((pm_interpolated_regular_expression_node_t *)node)->parts.size; index++) {
1211
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1212
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_interpolated_regular_expression_node_t *) node)->parts.nodes[index]);
1213
+ }
1214
+ pm_buffer_append_str(buffer, "]", 1);
1215
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_interpolated_regular_expression_node_t *)node)->closing_loc);
1216
+ pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
1217
+ snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags >> 2);
1218
+ pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
1219
+ pm_buffer_append_str(buffer, ")", 1);
1220
+ break;
1221
+ }
1222
+ case PM_INTERPOLATED_STRING_NODE: {
1223
+ pm_buffer_append_str(buffer, "InterpolatedStringNode(", 23);
1224
+ if (((pm_interpolated_string_node_t *)node)->opening_loc.start == NULL) {
1225
+ pm_buffer_append_str(buffer, "nil", 3);
1226
+ } else {
1227
+ prettyprint_location(buffer, parser, &((pm_interpolated_string_node_t *)node)->opening_loc);
1228
+ }
1229
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
1230
+ for (uint32_t index = 0; index < ((pm_interpolated_string_node_t *)node)->parts.size; index++) {
1231
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1232
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_interpolated_string_node_t *) node)->parts.nodes[index]);
1233
+ }
1234
+ pm_buffer_append_str(buffer, "]", 1);
1235
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_interpolated_string_node_t *)node)->closing_loc.start == NULL) {
1236
+ pm_buffer_append_str(buffer, "nil", 3);
1237
+ } else {
1238
+ prettyprint_location(buffer, parser, &((pm_interpolated_string_node_t *)node)->closing_loc);
1239
+ }
1240
+ pm_buffer_append_str(buffer, ")", 1);
1241
+ break;
1242
+ }
1243
+ case PM_INTERPOLATED_SYMBOL_NODE: {
1244
+ pm_buffer_append_str(buffer, "InterpolatedSymbolNode(", 23);
1245
+ if (((pm_interpolated_symbol_node_t *)node)->opening_loc.start == NULL) {
1246
+ pm_buffer_append_str(buffer, "nil", 3);
1247
+ } else {
1248
+ prettyprint_location(buffer, parser, &((pm_interpolated_symbol_node_t *)node)->opening_loc);
1249
+ }
1250
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
1251
+ for (uint32_t index = 0; index < ((pm_interpolated_symbol_node_t *)node)->parts.size; index++) {
1252
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1253
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_interpolated_symbol_node_t *) node)->parts.nodes[index]);
1254
+ }
1255
+ pm_buffer_append_str(buffer, "]", 1);
1256
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_interpolated_symbol_node_t *)node)->closing_loc.start == NULL) {
1257
+ pm_buffer_append_str(buffer, "nil", 3);
1258
+ } else {
1259
+ prettyprint_location(buffer, parser, &((pm_interpolated_symbol_node_t *)node)->closing_loc);
1260
+ }
1261
+ pm_buffer_append_str(buffer, ")", 1);
1262
+ break;
1263
+ }
1264
+ case PM_INTERPOLATED_X_STRING_NODE: {
1265
+ pm_buffer_append_str(buffer, "InterpolatedXStringNode(", 24);
1266
+ prettyprint_location(buffer, parser, &((pm_interpolated_x_string_node_t *)node)->opening_loc);
1267
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
1268
+ for (uint32_t index = 0; index < ((pm_interpolated_x_string_node_t *)node)->parts.size; index++) {
1269
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1270
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_interpolated_x_string_node_t *) node)->parts.nodes[index]);
1271
+ }
1272
+ pm_buffer_append_str(buffer, "]", 1);
1273
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_interpolated_x_string_node_t *)node)->closing_loc);
1274
+ pm_buffer_append_str(buffer, ")", 1);
1275
+ break;
1276
+ }
1277
+ case PM_KEYWORD_HASH_NODE: {
1278
+ pm_buffer_append_str(buffer, "KeywordHashNode(", 16);
1279
+ pm_buffer_append_str(buffer, "[", 1);
1280
+ for (uint32_t index = 0; index < ((pm_keyword_hash_node_t *)node)->elements.size; index++) {
1281
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1282
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_keyword_hash_node_t *) node)->elements.nodes[index]);
1283
+ }
1284
+ pm_buffer_append_str(buffer, "]", 1);
1285
+ pm_buffer_append_str(buffer, ")", 1);
1286
+ break;
1287
+ }
1288
+ case PM_KEYWORD_PARAMETER_NODE: {
1289
+ pm_buffer_append_str(buffer, "KeywordParameterNode(", 21);
1290
+ char name_buffer[12];
1291
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_keyword_parameter_node_t *)node)->name);
1292
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1293
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_keyword_parameter_node_t *)node)->name_loc);
1294
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_keyword_parameter_node_t *)node)->value == NULL) {
1295
+ pm_buffer_append_str(buffer, "nil", 3);
1296
+ } else {
1297
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_keyword_parameter_node_t *)node)->value);
1298
+ }
1299
+ pm_buffer_append_str(buffer, ")", 1);
1300
+ break;
1301
+ }
1302
+ case PM_KEYWORD_REST_PARAMETER_NODE: {
1303
+ pm_buffer_append_str(buffer, "KeywordRestParameterNode(", 25);
1304
+ if (((pm_keyword_rest_parameter_node_t *)node)->name == 0) {
1305
+ pm_buffer_append_str(buffer, "nil", 3);
1306
+ } else {
1307
+ char name_buffer[12];
1308
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_keyword_rest_parameter_node_t *)node)->name);
1309
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1310
+ }
1311
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_keyword_rest_parameter_node_t *)node)->name_loc.start == NULL) {
1312
+ pm_buffer_append_str(buffer, "nil", 3);
1313
+ } else {
1314
+ prettyprint_location(buffer, parser, &((pm_keyword_rest_parameter_node_t *)node)->name_loc);
1315
+ }
1316
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_keyword_rest_parameter_node_t *)node)->operator_loc);
1317
+ pm_buffer_append_str(buffer, ")", 1);
1318
+ break;
1319
+ }
1320
+ case PM_LAMBDA_NODE: {
1321
+ pm_buffer_append_str(buffer, "LambdaNode(", 11);
1322
+ pm_buffer_append_str(buffer, "[", 1);
1323
+ for (uint32_t index = 0; index < ((pm_lambda_node_t *)node)->locals.size; index++) {
1324
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1325
+ char locals_buffer[12];
1326
+ snprintf(locals_buffer, sizeof(locals_buffer), "%u", ((pm_lambda_node_t *)node)->locals.ids[index]);
1327
+ pm_buffer_append_str(buffer, locals_buffer, strlen(locals_buffer));
1328
+ }
1329
+ pm_buffer_append_str(buffer, "]", 1);
1330
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_lambda_node_t *)node)->operator_loc);
1331
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_lambda_node_t *)node)->opening_loc);
1332
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_lambda_node_t *)node)->closing_loc);
1333
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_lambda_node_t *)node)->parameters == NULL) {
1334
+ pm_buffer_append_str(buffer, "nil", 3);
1335
+ } else {
1336
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_lambda_node_t *)node)->parameters);
1337
+ }
1338
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_lambda_node_t *)node)->body == NULL) {
1339
+ pm_buffer_append_str(buffer, "nil", 3);
1340
+ } else {
1341
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_lambda_node_t *)node)->body);
1342
+ }
1343
+ pm_buffer_append_str(buffer, ")", 1);
1344
+ break;
1345
+ }
1346
+ case PM_LOCAL_VARIABLE_AND_WRITE_NODE: {
1347
+ pm_buffer_append_str(buffer, "LocalVariableAndWriteNode(", 26);
1348
+ prettyprint_location(buffer, parser, &((pm_local_variable_and_write_node_t *)node)->name_loc);
1349
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_local_variable_and_write_node_t *)node)->operator_loc);
1350
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_local_variable_and_write_node_t *)node)->value);
1351
+ pm_buffer_append_str(buffer, ", ", 2); char name_buffer[12];
1352
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_local_variable_and_write_node_t *)node)->name);
1353
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1354
+ pm_buffer_append_str(buffer, ", ", 2); char depth_buffer[12];
1355
+ snprintf(depth_buffer, sizeof(depth_buffer), "+%d", ((pm_local_variable_and_write_node_t *)node)->depth);
1356
+ pm_buffer_append_str(buffer, depth_buffer, strlen(depth_buffer));
1357
+ pm_buffer_append_str(buffer, ")", 1);
1358
+ break;
1359
+ }
1360
+ case PM_LOCAL_VARIABLE_OPERATOR_WRITE_NODE: {
1361
+ pm_buffer_append_str(buffer, "LocalVariableOperatorWriteNode(", 31);
1362
+ prettyprint_location(buffer, parser, &((pm_local_variable_operator_write_node_t *)node)->name_loc);
1363
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_local_variable_operator_write_node_t *)node)->operator_loc);
1364
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_local_variable_operator_write_node_t *)node)->value);
1365
+ pm_buffer_append_str(buffer, ", ", 2); char name_buffer[12];
1366
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_local_variable_operator_write_node_t *)node)->name);
1367
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1368
+ pm_buffer_append_str(buffer, ", ", 2); char operator_buffer[12];
1369
+ snprintf(operator_buffer, sizeof(operator_buffer), "%u", ((pm_local_variable_operator_write_node_t *)node)->operator);
1370
+ pm_buffer_append_str(buffer, operator_buffer, strlen(operator_buffer));
1371
+ pm_buffer_append_str(buffer, ", ", 2); char depth_buffer[12];
1372
+ snprintf(depth_buffer, sizeof(depth_buffer), "+%d", ((pm_local_variable_operator_write_node_t *)node)->depth);
1373
+ pm_buffer_append_str(buffer, depth_buffer, strlen(depth_buffer));
1374
+ pm_buffer_append_str(buffer, ")", 1);
1375
+ break;
1376
+ }
1377
+ case PM_LOCAL_VARIABLE_OR_WRITE_NODE: {
1378
+ pm_buffer_append_str(buffer, "LocalVariableOrWriteNode(", 25);
1379
+ prettyprint_location(buffer, parser, &((pm_local_variable_or_write_node_t *)node)->name_loc);
1380
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_local_variable_or_write_node_t *)node)->operator_loc);
1381
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_local_variable_or_write_node_t *)node)->value);
1382
+ pm_buffer_append_str(buffer, ", ", 2); char name_buffer[12];
1383
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_local_variable_or_write_node_t *)node)->name);
1384
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1385
+ pm_buffer_append_str(buffer, ", ", 2); char depth_buffer[12];
1386
+ snprintf(depth_buffer, sizeof(depth_buffer), "+%d", ((pm_local_variable_or_write_node_t *)node)->depth);
1387
+ pm_buffer_append_str(buffer, depth_buffer, strlen(depth_buffer));
1388
+ pm_buffer_append_str(buffer, ")", 1);
1389
+ break;
1390
+ }
1391
+ case PM_LOCAL_VARIABLE_READ_NODE: {
1392
+ pm_buffer_append_str(buffer, "LocalVariableReadNode(", 22);
1393
+ char name_buffer[12];
1394
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_local_variable_read_node_t *)node)->name);
1395
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1396
+ pm_buffer_append_str(buffer, ", ", 2); char depth_buffer[12];
1397
+ snprintf(depth_buffer, sizeof(depth_buffer), "+%d", ((pm_local_variable_read_node_t *)node)->depth);
1398
+ pm_buffer_append_str(buffer, depth_buffer, strlen(depth_buffer));
1399
+ pm_buffer_append_str(buffer, ")", 1);
1400
+ break;
1401
+ }
1402
+ case PM_LOCAL_VARIABLE_TARGET_NODE: {
1403
+ pm_buffer_append_str(buffer, "LocalVariableTargetNode(", 24);
1404
+ char name_buffer[12];
1405
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_local_variable_target_node_t *)node)->name);
1406
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1407
+ pm_buffer_append_str(buffer, ", ", 2); char depth_buffer[12];
1408
+ snprintf(depth_buffer, sizeof(depth_buffer), "+%d", ((pm_local_variable_target_node_t *)node)->depth);
1409
+ pm_buffer_append_str(buffer, depth_buffer, strlen(depth_buffer));
1410
+ pm_buffer_append_str(buffer, ")", 1);
1411
+ break;
1412
+ }
1413
+ case PM_LOCAL_VARIABLE_WRITE_NODE: {
1414
+ pm_buffer_append_str(buffer, "LocalVariableWriteNode(", 23);
1415
+ char name_buffer[12];
1416
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_local_variable_write_node_t *)node)->name);
1417
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1418
+ pm_buffer_append_str(buffer, ", ", 2); char depth_buffer[12];
1419
+ snprintf(depth_buffer, sizeof(depth_buffer), "+%d", ((pm_local_variable_write_node_t *)node)->depth);
1420
+ pm_buffer_append_str(buffer, depth_buffer, strlen(depth_buffer));
1421
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_local_variable_write_node_t *)node)->name_loc);
1422
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_local_variable_write_node_t *)node)->value);
1423
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_local_variable_write_node_t *)node)->operator_loc);
1424
+ pm_buffer_append_str(buffer, ")", 1);
1425
+ break;
1426
+ }
1427
+ case PM_MATCH_LAST_LINE_NODE: {
1428
+ pm_buffer_append_str(buffer, "MatchLastLineNode(", 18);
1429
+ prettyprint_location(buffer, parser, &((pm_match_last_line_node_t *)node)->opening_loc);
1430
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_match_last_line_node_t *)node)->content_loc);
1431
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_match_last_line_node_t *)node)->closing_loc);
1432
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "\"", 1);
1433
+ pm_buffer_append_bytes(buffer, pm_string_source(&((pm_match_last_line_node_t *)node)->unescaped), pm_string_length(&((pm_match_last_line_node_t *)node)->unescaped));
1434
+ pm_buffer_append_str(buffer, "\"", 1);
1435
+ pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
1436
+ snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags >> 2);
1437
+ pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
1438
+ pm_buffer_append_str(buffer, ")", 1);
1439
+ break;
1440
+ }
1441
+ case PM_MATCH_PREDICATE_NODE: {
1442
+ pm_buffer_append_str(buffer, "MatchPredicateNode(", 19);
1443
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_match_predicate_node_t *)node)->value);
1444
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_match_predicate_node_t *)node)->pattern);
1445
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_match_predicate_node_t *)node)->operator_loc);
1446
+ pm_buffer_append_str(buffer, ")", 1);
1447
+ break;
1448
+ }
1449
+ case PM_MATCH_REQUIRED_NODE: {
1450
+ pm_buffer_append_str(buffer, "MatchRequiredNode(", 18);
1451
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_match_required_node_t *)node)->value);
1452
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_match_required_node_t *)node)->pattern);
1453
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_match_required_node_t *)node)->operator_loc);
1454
+ pm_buffer_append_str(buffer, ")", 1);
1455
+ break;
1456
+ }
1457
+ case PM_MATCH_WRITE_NODE: {
1458
+ pm_buffer_append_str(buffer, "MatchWriteNode(", 15);
1459
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_match_write_node_t *)node)->call);
1460
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
1461
+ for (uint32_t index = 0; index < ((pm_match_write_node_t *)node)->locals.size; index++) {
1462
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1463
+ char locals_buffer[12];
1464
+ snprintf(locals_buffer, sizeof(locals_buffer), "%u", ((pm_match_write_node_t *)node)->locals.ids[index]);
1465
+ pm_buffer_append_str(buffer, locals_buffer, strlen(locals_buffer));
1466
+ }
1467
+ pm_buffer_append_str(buffer, "]", 1);
1468
+ pm_buffer_append_str(buffer, ")", 1);
1469
+ break;
1470
+ }
1471
+ case PM_MISSING_NODE: {
1472
+ pm_buffer_append_str(buffer, "MissingNode(", 12);
1473
+ pm_buffer_append_str(buffer, ")", 1);
1474
+ break;
1475
+ }
1476
+ case PM_MODULE_NODE: {
1477
+ pm_buffer_append_str(buffer, "ModuleNode(", 11);
1478
+ pm_buffer_append_str(buffer, "[", 1);
1479
+ for (uint32_t index = 0; index < ((pm_module_node_t *)node)->locals.size; index++) {
1480
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1481
+ char locals_buffer[12];
1482
+ snprintf(locals_buffer, sizeof(locals_buffer), "%u", ((pm_module_node_t *)node)->locals.ids[index]);
1483
+ pm_buffer_append_str(buffer, locals_buffer, strlen(locals_buffer));
1484
+ }
1485
+ pm_buffer_append_str(buffer, "]", 1);
1486
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_module_node_t *)node)->module_keyword_loc);
1487
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_module_node_t *)node)->constant_path);
1488
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_module_node_t *)node)->body == NULL) {
1489
+ pm_buffer_append_str(buffer, "nil", 3);
1490
+ } else {
1491
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_module_node_t *)node)->body);
1492
+ }
1493
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_module_node_t *)node)->end_keyword_loc);
1494
+ pm_buffer_append_str(buffer, ", ", 2); char name_buffer[12];
1495
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_module_node_t *)node)->name);
1496
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1497
+ pm_buffer_append_str(buffer, ")", 1);
1498
+ break;
1499
+ }
1500
+ case PM_MULTI_TARGET_NODE: {
1501
+ pm_buffer_append_str(buffer, "MultiTargetNode(", 16);
1502
+ pm_buffer_append_str(buffer, "[", 1);
1503
+ for (uint32_t index = 0; index < ((pm_multi_target_node_t *)node)->targets.size; index++) {
1504
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1505
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_multi_target_node_t *) node)->targets.nodes[index]);
1506
+ }
1507
+ pm_buffer_append_str(buffer, "]", 1);
1508
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_multi_target_node_t *)node)->lparen_loc.start == NULL) {
1509
+ pm_buffer_append_str(buffer, "nil", 3);
1510
+ } else {
1511
+ prettyprint_location(buffer, parser, &((pm_multi_target_node_t *)node)->lparen_loc);
1512
+ }
1513
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_multi_target_node_t *)node)->rparen_loc.start == NULL) {
1514
+ pm_buffer_append_str(buffer, "nil", 3);
1515
+ } else {
1516
+ prettyprint_location(buffer, parser, &((pm_multi_target_node_t *)node)->rparen_loc);
1517
+ }
1518
+ pm_buffer_append_str(buffer, ")", 1);
1519
+ break;
1520
+ }
1521
+ case PM_MULTI_WRITE_NODE: {
1522
+ pm_buffer_append_str(buffer, "MultiWriteNode(", 15);
1523
+ pm_buffer_append_str(buffer, "[", 1);
1524
+ for (uint32_t index = 0; index < ((pm_multi_write_node_t *)node)->targets.size; index++) {
1525
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1526
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_multi_write_node_t *) node)->targets.nodes[index]);
1527
+ }
1528
+ pm_buffer_append_str(buffer, "]", 1);
1529
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_multi_write_node_t *)node)->lparen_loc.start == NULL) {
1530
+ pm_buffer_append_str(buffer, "nil", 3);
1531
+ } else {
1532
+ prettyprint_location(buffer, parser, &((pm_multi_write_node_t *)node)->lparen_loc);
1533
+ }
1534
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_multi_write_node_t *)node)->rparen_loc.start == NULL) {
1535
+ pm_buffer_append_str(buffer, "nil", 3);
1536
+ } else {
1537
+ prettyprint_location(buffer, parser, &((pm_multi_write_node_t *)node)->rparen_loc);
1538
+ }
1539
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_multi_write_node_t *)node)->operator_loc);
1540
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_multi_write_node_t *)node)->value);
1541
+ pm_buffer_append_str(buffer, ")", 1);
1542
+ break;
1543
+ }
1544
+ case PM_NEXT_NODE: {
1545
+ pm_buffer_append_str(buffer, "NextNode(", 9);
1546
+ if (((pm_next_node_t *)node)->arguments == NULL) {
1547
+ pm_buffer_append_str(buffer, "nil", 3);
1548
+ } else {
1549
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_next_node_t *)node)->arguments);
1550
+ }
1551
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_next_node_t *)node)->keyword_loc);
1552
+ pm_buffer_append_str(buffer, ")", 1);
1553
+ break;
1554
+ }
1555
+ case PM_NIL_NODE: {
1556
+ pm_buffer_append_str(buffer, "NilNode(", 8);
1557
+ pm_buffer_append_str(buffer, ")", 1);
1558
+ break;
1559
+ }
1560
+ case PM_NO_KEYWORDS_PARAMETER_NODE: {
1561
+ pm_buffer_append_str(buffer, "NoKeywordsParameterNode(", 24);
1562
+ prettyprint_location(buffer, parser, &((pm_no_keywords_parameter_node_t *)node)->operator_loc);
1563
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_no_keywords_parameter_node_t *)node)->keyword_loc);
1564
+ pm_buffer_append_str(buffer, ")", 1);
1565
+ break;
1566
+ }
1567
+ case PM_NUMBERED_REFERENCE_READ_NODE: {
1568
+ pm_buffer_append_str(buffer, "NumberedReferenceReadNode(", 26);
1569
+ char number_buffer[12];
1570
+ snprintf(number_buffer, sizeof(number_buffer), "+%d", ((pm_numbered_reference_read_node_t *)node)->number);
1571
+ pm_buffer_append_str(buffer, number_buffer, strlen(number_buffer));
1572
+ pm_buffer_append_str(buffer, ")", 1);
1573
+ break;
1574
+ }
1575
+ case PM_OPTIONAL_PARAMETER_NODE: {
1576
+ pm_buffer_append_str(buffer, "OptionalParameterNode(", 22);
1577
+ char name_buffer[12];
1578
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_optional_parameter_node_t *)node)->name);
1579
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1580
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_optional_parameter_node_t *)node)->name_loc);
1581
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_optional_parameter_node_t *)node)->operator_loc);
1582
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_optional_parameter_node_t *)node)->value);
1583
+ pm_buffer_append_str(buffer, ")", 1);
1584
+ break;
1585
+ }
1586
+ case PM_OR_NODE: {
1587
+ pm_buffer_append_str(buffer, "OrNode(", 7);
1588
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_or_node_t *)node)->left);
1589
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_or_node_t *)node)->right);
1590
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_or_node_t *)node)->operator_loc);
1591
+ pm_buffer_append_str(buffer, ")", 1);
1592
+ break;
1593
+ }
1594
+ case PM_PARAMETERS_NODE: {
1595
+ pm_buffer_append_str(buffer, "ParametersNode(", 15);
1596
+ pm_buffer_append_str(buffer, "[", 1);
1597
+ for (uint32_t index = 0; index < ((pm_parameters_node_t *)node)->requireds.size; index++) {
1598
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1599
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_parameters_node_t *) node)->requireds.nodes[index]);
1600
+ }
1601
+ pm_buffer_append_str(buffer, "]", 1);
1602
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
1603
+ for (uint32_t index = 0; index < ((pm_parameters_node_t *)node)->optionals.size; index++) {
1604
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1605
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_parameters_node_t *) node)->optionals.nodes[index]);
1606
+ }
1607
+ pm_buffer_append_str(buffer, "]", 1);
1608
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_parameters_node_t *)node)->rest == NULL) {
1609
+ pm_buffer_append_str(buffer, "nil", 3);
1610
+ } else {
1611
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_parameters_node_t *)node)->rest);
1612
+ }
1613
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
1614
+ for (uint32_t index = 0; index < ((pm_parameters_node_t *)node)->posts.size; index++) {
1615
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1616
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_parameters_node_t *) node)->posts.nodes[index]);
1617
+ }
1618
+ pm_buffer_append_str(buffer, "]", 1);
1619
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
1620
+ for (uint32_t index = 0; index < ((pm_parameters_node_t *)node)->keywords.size; index++) {
1621
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1622
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_parameters_node_t *) node)->keywords.nodes[index]);
1623
+ }
1624
+ pm_buffer_append_str(buffer, "]", 1);
1625
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_parameters_node_t *)node)->keyword_rest == NULL) {
1626
+ pm_buffer_append_str(buffer, "nil", 3);
1627
+ } else {
1628
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_parameters_node_t *)node)->keyword_rest);
1629
+ }
1630
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_parameters_node_t *)node)->block == NULL) {
1631
+ pm_buffer_append_str(buffer, "nil", 3);
1632
+ } else {
1633
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_parameters_node_t *)node)->block);
1634
+ }
1635
+ pm_buffer_append_str(buffer, ")", 1);
1636
+ break;
1637
+ }
1638
+ case PM_PARENTHESES_NODE: {
1639
+ pm_buffer_append_str(buffer, "ParenthesesNode(", 16);
1640
+ if (((pm_parentheses_node_t *)node)->body == NULL) {
1641
+ pm_buffer_append_str(buffer, "nil", 3);
1642
+ } else {
1643
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_parentheses_node_t *)node)->body);
1644
+ }
1645
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_parentheses_node_t *)node)->opening_loc);
1646
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_parentheses_node_t *)node)->closing_loc);
1647
+ pm_buffer_append_str(buffer, ")", 1);
1648
+ break;
1649
+ }
1650
+ case PM_PINNED_EXPRESSION_NODE: {
1651
+ pm_buffer_append_str(buffer, "PinnedExpressionNode(", 21);
1652
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_pinned_expression_node_t *)node)->expression);
1653
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_pinned_expression_node_t *)node)->operator_loc);
1654
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_pinned_expression_node_t *)node)->lparen_loc);
1655
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_pinned_expression_node_t *)node)->rparen_loc);
1656
+ pm_buffer_append_str(buffer, ")", 1);
1657
+ break;
1658
+ }
1659
+ case PM_PINNED_VARIABLE_NODE: {
1660
+ pm_buffer_append_str(buffer, "PinnedVariableNode(", 19);
1661
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_pinned_variable_node_t *)node)->variable);
1662
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_pinned_variable_node_t *)node)->operator_loc);
1663
+ pm_buffer_append_str(buffer, ")", 1);
1664
+ break;
1665
+ }
1666
+ case PM_POST_EXECUTION_NODE: {
1667
+ pm_buffer_append_str(buffer, "PostExecutionNode(", 18);
1668
+ if (((pm_post_execution_node_t *)node)->statements == NULL) {
1669
+ pm_buffer_append_str(buffer, "nil", 3);
1670
+ } else {
1671
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_post_execution_node_t *)node)->statements);
1672
+ }
1673
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_post_execution_node_t *)node)->keyword_loc);
1674
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_post_execution_node_t *)node)->opening_loc);
1675
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_post_execution_node_t *)node)->closing_loc);
1676
+ pm_buffer_append_str(buffer, ")", 1);
1677
+ break;
1678
+ }
1679
+ case PM_PRE_EXECUTION_NODE: {
1680
+ pm_buffer_append_str(buffer, "PreExecutionNode(", 17);
1681
+ if (((pm_pre_execution_node_t *)node)->statements == NULL) {
1682
+ pm_buffer_append_str(buffer, "nil", 3);
1683
+ } else {
1684
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_pre_execution_node_t *)node)->statements);
1685
+ }
1686
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_pre_execution_node_t *)node)->keyword_loc);
1687
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_pre_execution_node_t *)node)->opening_loc);
1688
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_pre_execution_node_t *)node)->closing_loc);
1689
+ pm_buffer_append_str(buffer, ")", 1);
1690
+ break;
1691
+ }
1692
+ case PM_PROGRAM_NODE: {
1693
+ pm_buffer_append_str(buffer, "ProgramNode(", 12);
1694
+ pm_buffer_append_str(buffer, "[", 1);
1695
+ for (uint32_t index = 0; index < ((pm_program_node_t *)node)->locals.size; index++) {
1696
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1697
+ char locals_buffer[12];
1698
+ snprintf(locals_buffer, sizeof(locals_buffer), "%u", ((pm_program_node_t *)node)->locals.ids[index]);
1699
+ pm_buffer_append_str(buffer, locals_buffer, strlen(locals_buffer));
1700
+ }
1701
+ pm_buffer_append_str(buffer, "]", 1);
1702
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_program_node_t *)node)->statements);
1703
+ pm_buffer_append_str(buffer, ")", 1);
1704
+ break;
1705
+ }
1706
+ case PM_RANGE_NODE: {
1707
+ pm_buffer_append_str(buffer, "RangeNode(", 10);
1708
+ if (((pm_range_node_t *)node)->left == NULL) {
1709
+ pm_buffer_append_str(buffer, "nil", 3);
1710
+ } else {
1711
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_range_node_t *)node)->left);
1712
+ }
1713
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_range_node_t *)node)->right == NULL) {
1714
+ pm_buffer_append_str(buffer, "nil", 3);
1715
+ } else {
1716
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_range_node_t *)node)->right);
1717
+ }
1718
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_range_node_t *)node)->operator_loc);
1719
+ pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
1720
+ snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags >> 2);
1721
+ pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
1722
+ pm_buffer_append_str(buffer, ")", 1);
1723
+ break;
1724
+ }
1725
+ case PM_RATIONAL_NODE: {
1726
+ pm_buffer_append_str(buffer, "RationalNode(", 13);
1727
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_rational_node_t *)node)->numeric);
1728
+ pm_buffer_append_str(buffer, ")", 1);
1729
+ break;
1730
+ }
1731
+ case PM_REDO_NODE: {
1732
+ pm_buffer_append_str(buffer, "RedoNode(", 9);
1733
+ pm_buffer_append_str(buffer, ")", 1);
1734
+ break;
1735
+ }
1736
+ case PM_REGULAR_EXPRESSION_NODE: {
1737
+ pm_buffer_append_str(buffer, "RegularExpressionNode(", 22);
1738
+ prettyprint_location(buffer, parser, &((pm_regular_expression_node_t *)node)->opening_loc);
1739
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_regular_expression_node_t *)node)->content_loc);
1740
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_regular_expression_node_t *)node)->closing_loc);
1741
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "\"", 1);
1742
+ pm_buffer_append_bytes(buffer, pm_string_source(&((pm_regular_expression_node_t *)node)->unescaped), pm_string_length(&((pm_regular_expression_node_t *)node)->unescaped));
1743
+ pm_buffer_append_str(buffer, "\"", 1);
1744
+ pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
1745
+ snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags >> 2);
1746
+ pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
1747
+ pm_buffer_append_str(buffer, ")", 1);
1748
+ break;
1749
+ }
1750
+ case PM_REQUIRED_DESTRUCTURED_PARAMETER_NODE: {
1751
+ pm_buffer_append_str(buffer, "RequiredDestructuredParameterNode(", 34);
1752
+ pm_buffer_append_str(buffer, "[", 1);
1753
+ for (uint32_t index = 0; index < ((pm_required_destructured_parameter_node_t *)node)->parameters.size; index++) {
1754
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1755
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_required_destructured_parameter_node_t *) node)->parameters.nodes[index]);
1756
+ }
1757
+ pm_buffer_append_str(buffer, "]", 1);
1758
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_required_destructured_parameter_node_t *)node)->opening_loc);
1759
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_required_destructured_parameter_node_t *)node)->closing_loc);
1760
+ pm_buffer_append_str(buffer, ")", 1);
1761
+ break;
1762
+ }
1763
+ case PM_REQUIRED_PARAMETER_NODE: {
1764
+ pm_buffer_append_str(buffer, "RequiredParameterNode(", 22);
1765
+ char name_buffer[12];
1766
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_required_parameter_node_t *)node)->name);
1767
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1768
+ pm_buffer_append_str(buffer, ")", 1);
1769
+ break;
1770
+ }
1771
+ case PM_RESCUE_MODIFIER_NODE: {
1772
+ pm_buffer_append_str(buffer, "RescueModifierNode(", 19);
1773
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_rescue_modifier_node_t *)node)->expression);
1774
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_rescue_modifier_node_t *)node)->keyword_loc);
1775
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_rescue_modifier_node_t *)node)->rescue_expression);
1776
+ pm_buffer_append_str(buffer, ")", 1);
1777
+ break;
1778
+ }
1779
+ case PM_RESCUE_NODE: {
1780
+ pm_buffer_append_str(buffer, "RescueNode(", 11);
1781
+ prettyprint_location(buffer, parser, &((pm_rescue_node_t *)node)->keyword_loc);
1782
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
1783
+ for (uint32_t index = 0; index < ((pm_rescue_node_t *)node)->exceptions.size; index++) {
1784
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1785
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_rescue_node_t *) node)->exceptions.nodes[index]);
1786
+ }
1787
+ pm_buffer_append_str(buffer, "]", 1);
1788
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_rescue_node_t *)node)->operator_loc.start == NULL) {
1789
+ pm_buffer_append_str(buffer, "nil", 3);
1790
+ } else {
1791
+ prettyprint_location(buffer, parser, &((pm_rescue_node_t *)node)->operator_loc);
1792
+ }
1793
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_rescue_node_t *)node)->reference == NULL) {
1794
+ pm_buffer_append_str(buffer, "nil", 3);
1795
+ } else {
1796
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_rescue_node_t *)node)->reference);
1797
+ }
1798
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_rescue_node_t *)node)->statements == NULL) {
1799
+ pm_buffer_append_str(buffer, "nil", 3);
1800
+ } else {
1801
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_rescue_node_t *)node)->statements);
1802
+ }
1803
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_rescue_node_t *)node)->consequent == NULL) {
1804
+ pm_buffer_append_str(buffer, "nil", 3);
1805
+ } else {
1806
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_rescue_node_t *)node)->consequent);
1807
+ }
1808
+ pm_buffer_append_str(buffer, ")", 1);
1809
+ break;
1810
+ }
1811
+ case PM_REST_PARAMETER_NODE: {
1812
+ pm_buffer_append_str(buffer, "RestParameterNode(", 18);
1813
+ if (((pm_rest_parameter_node_t *)node)->name == 0) {
1814
+ pm_buffer_append_str(buffer, "nil", 3);
1815
+ } else {
1816
+ char name_buffer[12];
1817
+ snprintf(name_buffer, sizeof(name_buffer), "%u", ((pm_rest_parameter_node_t *)node)->name);
1818
+ pm_buffer_append_str(buffer, name_buffer, strlen(name_buffer));
1819
+ }
1820
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_rest_parameter_node_t *)node)->name_loc.start == NULL) {
1821
+ pm_buffer_append_str(buffer, "nil", 3);
1822
+ } else {
1823
+ prettyprint_location(buffer, parser, &((pm_rest_parameter_node_t *)node)->name_loc);
1824
+ }
1825
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_rest_parameter_node_t *)node)->operator_loc);
1826
+ pm_buffer_append_str(buffer, ")", 1);
1827
+ break;
1828
+ }
1829
+ case PM_RETRY_NODE: {
1830
+ pm_buffer_append_str(buffer, "RetryNode(", 10);
1831
+ pm_buffer_append_str(buffer, ")", 1);
1832
+ break;
1833
+ }
1834
+ case PM_RETURN_NODE: {
1835
+ pm_buffer_append_str(buffer, "ReturnNode(", 11);
1836
+ prettyprint_location(buffer, parser, &((pm_return_node_t *)node)->keyword_loc);
1837
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_return_node_t *)node)->arguments == NULL) {
1838
+ pm_buffer_append_str(buffer, "nil", 3);
1839
+ } else {
1840
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_return_node_t *)node)->arguments);
1841
+ }
1842
+ pm_buffer_append_str(buffer, ")", 1);
1843
+ break;
1844
+ }
1845
+ case PM_SELF_NODE: {
1846
+ pm_buffer_append_str(buffer, "SelfNode(", 9);
1847
+ pm_buffer_append_str(buffer, ")", 1);
1848
+ break;
1849
+ }
1850
+ case PM_SINGLETON_CLASS_NODE: {
1851
+ pm_buffer_append_str(buffer, "SingletonClassNode(", 19);
1852
+ pm_buffer_append_str(buffer, "[", 1);
1853
+ for (uint32_t index = 0; index < ((pm_singleton_class_node_t *)node)->locals.size; index++) {
1854
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1855
+ char locals_buffer[12];
1856
+ snprintf(locals_buffer, sizeof(locals_buffer), "%u", ((pm_singleton_class_node_t *)node)->locals.ids[index]);
1857
+ pm_buffer_append_str(buffer, locals_buffer, strlen(locals_buffer));
1858
+ }
1859
+ pm_buffer_append_str(buffer, "]", 1);
1860
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_singleton_class_node_t *)node)->class_keyword_loc);
1861
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_singleton_class_node_t *)node)->operator_loc);
1862
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_singleton_class_node_t *)node)->expression);
1863
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_singleton_class_node_t *)node)->body == NULL) {
1864
+ pm_buffer_append_str(buffer, "nil", 3);
1865
+ } else {
1866
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_singleton_class_node_t *)node)->body);
1867
+ }
1868
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_singleton_class_node_t *)node)->end_keyword_loc);
1869
+ pm_buffer_append_str(buffer, ")", 1);
1870
+ break;
1871
+ }
1872
+ case PM_SOURCE_ENCODING_NODE: {
1873
+ pm_buffer_append_str(buffer, "SourceEncodingNode(", 19);
1874
+ pm_buffer_append_str(buffer, ")", 1);
1875
+ break;
1876
+ }
1877
+ case PM_SOURCE_FILE_NODE: {
1878
+ pm_buffer_append_str(buffer, "SourceFileNode(", 15);
1879
+ pm_buffer_append_str(buffer, "\"", 1);
1880
+ pm_buffer_append_bytes(buffer, pm_string_source(&((pm_source_file_node_t *)node)->filepath), pm_string_length(&((pm_source_file_node_t *)node)->filepath));
1881
+ pm_buffer_append_str(buffer, "\"", 1);
1882
+ pm_buffer_append_str(buffer, ")", 1);
1883
+ break;
1884
+ }
1885
+ case PM_SOURCE_LINE_NODE: {
1886
+ pm_buffer_append_str(buffer, "SourceLineNode(", 15);
1887
+ pm_buffer_append_str(buffer, ")", 1);
1888
+ break;
1889
+ }
1890
+ case PM_SPLAT_NODE: {
1891
+ pm_buffer_append_str(buffer, "SplatNode(", 10);
1892
+ prettyprint_location(buffer, parser, &((pm_splat_node_t *)node)->operator_loc);
1893
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_splat_node_t *)node)->expression == NULL) {
1894
+ pm_buffer_append_str(buffer, "nil", 3);
1895
+ } else {
1896
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_splat_node_t *)node)->expression);
1897
+ }
1898
+ pm_buffer_append_str(buffer, ")", 1);
1899
+ break;
1900
+ }
1901
+ case PM_STATEMENTS_NODE: {
1902
+ pm_buffer_append_str(buffer, "StatementsNode(", 15);
1903
+ pm_buffer_append_str(buffer, "[", 1);
1904
+ for (uint32_t index = 0; index < ((pm_statements_node_t *)node)->body.size; index++) {
1905
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
1906
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_statements_node_t *) node)->body.nodes[index]);
1907
+ }
1908
+ pm_buffer_append_str(buffer, "]", 1);
1909
+ pm_buffer_append_str(buffer, ")", 1);
1910
+ break;
1911
+ }
1912
+ case PM_STRING_CONCAT_NODE: {
1913
+ pm_buffer_append_str(buffer, "StringConcatNode(", 17);
1914
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_string_concat_node_t *)node)->left);
1915
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_string_concat_node_t *)node)->right);
1916
+ pm_buffer_append_str(buffer, ")", 1);
1917
+ break;
1918
+ }
1919
+ case PM_STRING_NODE: {
1920
+ pm_buffer_append_str(buffer, "StringNode(", 11);
1921
+ char flags_buffer[12];
1922
+ snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags >> 2);
1923
+ pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
1924
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_string_node_t *)node)->opening_loc.start == NULL) {
1925
+ pm_buffer_append_str(buffer, "nil", 3);
1926
+ } else {
1927
+ prettyprint_location(buffer, parser, &((pm_string_node_t *)node)->opening_loc);
1928
+ }
1929
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_string_node_t *)node)->content_loc);
1930
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_string_node_t *)node)->closing_loc.start == NULL) {
1931
+ pm_buffer_append_str(buffer, "nil", 3);
1932
+ } else {
1933
+ prettyprint_location(buffer, parser, &((pm_string_node_t *)node)->closing_loc);
1934
+ }
1935
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "\"", 1);
1936
+ pm_buffer_append_bytes(buffer, pm_string_source(&((pm_string_node_t *)node)->unescaped), pm_string_length(&((pm_string_node_t *)node)->unescaped));
1937
+ pm_buffer_append_str(buffer, "\"", 1);
1938
+ pm_buffer_append_str(buffer, ")", 1);
1939
+ break;
1940
+ }
1941
+ case PM_SUPER_NODE: {
1942
+ pm_buffer_append_str(buffer, "SuperNode(", 10);
1943
+ prettyprint_location(buffer, parser, &((pm_super_node_t *)node)->keyword_loc);
1944
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_super_node_t *)node)->lparen_loc.start == NULL) {
1945
+ pm_buffer_append_str(buffer, "nil", 3);
1946
+ } else {
1947
+ prettyprint_location(buffer, parser, &((pm_super_node_t *)node)->lparen_loc);
1948
+ }
1949
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_super_node_t *)node)->arguments == NULL) {
1950
+ pm_buffer_append_str(buffer, "nil", 3);
1951
+ } else {
1952
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_super_node_t *)node)->arguments);
1953
+ }
1954
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_super_node_t *)node)->rparen_loc.start == NULL) {
1955
+ pm_buffer_append_str(buffer, "nil", 3);
1956
+ } else {
1957
+ prettyprint_location(buffer, parser, &((pm_super_node_t *)node)->rparen_loc);
1958
+ }
1959
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_super_node_t *)node)->block == NULL) {
1960
+ pm_buffer_append_str(buffer, "nil", 3);
1961
+ } else {
1962
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_super_node_t *)node)->block);
1963
+ }
1964
+ pm_buffer_append_str(buffer, ")", 1);
1965
+ break;
1966
+ }
1967
+ case PM_SYMBOL_NODE: {
1968
+ pm_buffer_append_str(buffer, "SymbolNode(", 11);
1969
+ if (((pm_symbol_node_t *)node)->opening_loc.start == NULL) {
1970
+ pm_buffer_append_str(buffer, "nil", 3);
1971
+ } else {
1972
+ prettyprint_location(buffer, parser, &((pm_symbol_node_t *)node)->opening_loc);
1973
+ }
1974
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_symbol_node_t *)node)->value_loc.start == NULL) {
1975
+ pm_buffer_append_str(buffer, "nil", 3);
1976
+ } else {
1977
+ prettyprint_location(buffer, parser, &((pm_symbol_node_t *)node)->value_loc);
1978
+ }
1979
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_symbol_node_t *)node)->closing_loc.start == NULL) {
1980
+ pm_buffer_append_str(buffer, "nil", 3);
1981
+ } else {
1982
+ prettyprint_location(buffer, parser, &((pm_symbol_node_t *)node)->closing_loc);
1983
+ }
1984
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "\"", 1);
1985
+ pm_buffer_append_bytes(buffer, pm_string_source(&((pm_symbol_node_t *)node)->unescaped), pm_string_length(&((pm_symbol_node_t *)node)->unescaped));
1986
+ pm_buffer_append_str(buffer, "\"", 1);
1987
+ pm_buffer_append_str(buffer, ")", 1);
1988
+ break;
1989
+ }
1990
+ case PM_TRUE_NODE: {
1991
+ pm_buffer_append_str(buffer, "TrueNode(", 9);
1992
+ pm_buffer_append_str(buffer, ")", 1);
1993
+ break;
1994
+ }
1995
+ case PM_UNDEF_NODE: {
1996
+ pm_buffer_append_str(buffer, "UndefNode(", 10);
1997
+ pm_buffer_append_str(buffer, "[", 1);
1998
+ for (uint32_t index = 0; index < ((pm_undef_node_t *)node)->names.size; index++) {
1999
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
2000
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_undef_node_t *) node)->names.nodes[index]);
2001
+ }
2002
+ pm_buffer_append_str(buffer, "]", 1);
2003
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_undef_node_t *)node)->keyword_loc);
2004
+ pm_buffer_append_str(buffer, ")", 1);
2005
+ break;
2006
+ }
2007
+ case PM_UNLESS_NODE: {
2008
+ pm_buffer_append_str(buffer, "UnlessNode(", 11);
2009
+ prettyprint_location(buffer, parser, &((pm_unless_node_t *)node)->keyword_loc);
2010
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_unless_node_t *)node)->predicate);
2011
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_unless_node_t *)node)->statements == NULL) {
2012
+ pm_buffer_append_str(buffer, "nil", 3);
2013
+ } else {
2014
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_unless_node_t *)node)->statements);
2015
+ }
2016
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_unless_node_t *)node)->consequent == NULL) {
2017
+ pm_buffer_append_str(buffer, "nil", 3);
2018
+ } else {
2019
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_unless_node_t *)node)->consequent);
2020
+ }
2021
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_unless_node_t *)node)->end_keyword_loc.start == NULL) {
2022
+ pm_buffer_append_str(buffer, "nil", 3);
2023
+ } else {
2024
+ prettyprint_location(buffer, parser, &((pm_unless_node_t *)node)->end_keyword_loc);
2025
+ }
2026
+ pm_buffer_append_str(buffer, ")", 1);
2027
+ break;
2028
+ }
2029
+ case PM_UNTIL_NODE: {
2030
+ pm_buffer_append_str(buffer, "UntilNode(", 10);
2031
+ prettyprint_location(buffer, parser, &((pm_until_node_t *)node)->keyword_loc);
2032
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_until_node_t *)node)->closing_loc.start == NULL) {
2033
+ pm_buffer_append_str(buffer, "nil", 3);
2034
+ } else {
2035
+ prettyprint_location(buffer, parser, &((pm_until_node_t *)node)->closing_loc);
2036
+ }
2037
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_until_node_t *)node)->predicate);
2038
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_until_node_t *)node)->statements == NULL) {
2039
+ pm_buffer_append_str(buffer, "nil", 3);
2040
+ } else {
2041
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_until_node_t *)node)->statements);
2042
+ }
2043
+ pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
2044
+ snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags >> 2);
2045
+ pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
2046
+ pm_buffer_append_str(buffer, ")", 1);
2047
+ break;
2048
+ }
2049
+ case PM_WHEN_NODE: {
2050
+ pm_buffer_append_str(buffer, "WhenNode(", 9);
2051
+ prettyprint_location(buffer, parser, &((pm_when_node_t *)node)->keyword_loc);
2052
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "[", 1);
2053
+ for (uint32_t index = 0; index < ((pm_when_node_t *)node)->conditions.size; index++) {
2054
+ if (index != 0) pm_buffer_append_str(buffer, ", ", 2);
2055
+ prettyprint_node(buffer, parser, (pm_node_t *) ((pm_when_node_t *) node)->conditions.nodes[index]);
2056
+ }
2057
+ pm_buffer_append_str(buffer, "]", 1);
2058
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_when_node_t *)node)->statements == NULL) {
2059
+ pm_buffer_append_str(buffer, "nil", 3);
2060
+ } else {
2061
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_when_node_t *)node)->statements);
2062
+ }
2063
+ pm_buffer_append_str(buffer, ")", 1);
2064
+ break;
2065
+ }
2066
+ case PM_WHILE_NODE: {
2067
+ pm_buffer_append_str(buffer, "WhileNode(", 10);
2068
+ prettyprint_location(buffer, parser, &((pm_while_node_t *)node)->keyword_loc);
2069
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_while_node_t *)node)->closing_loc.start == NULL) {
2070
+ pm_buffer_append_str(buffer, "nil", 3);
2071
+ } else {
2072
+ prettyprint_location(buffer, parser, &((pm_while_node_t *)node)->closing_loc);
2073
+ }
2074
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_node(buffer, parser, (pm_node_t *)((pm_while_node_t *)node)->predicate);
2075
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_while_node_t *)node)->statements == NULL) {
2076
+ pm_buffer_append_str(buffer, "nil", 3);
2077
+ } else {
2078
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_while_node_t *)node)->statements);
2079
+ }
2080
+ pm_buffer_append_str(buffer, ", ", 2); char flags_buffer[12];
2081
+ snprintf(flags_buffer, sizeof(flags_buffer), "+%d", node->flags >> 2);
2082
+ pm_buffer_append_str(buffer, flags_buffer, strlen(flags_buffer));
2083
+ pm_buffer_append_str(buffer, ")", 1);
2084
+ break;
2085
+ }
2086
+ case PM_X_STRING_NODE: {
2087
+ pm_buffer_append_str(buffer, "XStringNode(", 12);
2088
+ prettyprint_location(buffer, parser, &((pm_x_string_node_t *)node)->opening_loc);
2089
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_x_string_node_t *)node)->content_loc);
2090
+ pm_buffer_append_str(buffer, ", ", 2); prettyprint_location(buffer, parser, &((pm_x_string_node_t *)node)->closing_loc);
2091
+ pm_buffer_append_str(buffer, ", ", 2); pm_buffer_append_str(buffer, "\"", 1);
2092
+ pm_buffer_append_bytes(buffer, pm_string_source(&((pm_x_string_node_t *)node)->unescaped), pm_string_length(&((pm_x_string_node_t *)node)->unescaped));
2093
+ pm_buffer_append_str(buffer, "\"", 1);
2094
+ pm_buffer_append_str(buffer, ")", 1);
2095
+ break;
2096
+ }
2097
+ case PM_YIELD_NODE: {
2098
+ pm_buffer_append_str(buffer, "YieldNode(", 10);
2099
+ prettyprint_location(buffer, parser, &((pm_yield_node_t *)node)->keyword_loc);
2100
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_yield_node_t *)node)->lparen_loc.start == NULL) {
2101
+ pm_buffer_append_str(buffer, "nil", 3);
2102
+ } else {
2103
+ prettyprint_location(buffer, parser, &((pm_yield_node_t *)node)->lparen_loc);
2104
+ }
2105
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_yield_node_t *)node)->arguments == NULL) {
2106
+ pm_buffer_append_str(buffer, "nil", 3);
2107
+ } else {
2108
+ prettyprint_node(buffer, parser, (pm_node_t *)((pm_yield_node_t *)node)->arguments);
2109
+ }
2110
+ pm_buffer_append_str(buffer, ", ", 2); if (((pm_yield_node_t *)node)->rparen_loc.start == NULL) {
2111
+ pm_buffer_append_str(buffer, "nil", 3);
2112
+ } else {
2113
+ prettyprint_location(buffer, parser, &((pm_yield_node_t *)node)->rparen_loc);
2114
+ }
2115
+ pm_buffer_append_str(buffer, ")", 1);
2116
+ break;
2117
+ }
2118
+ }
2119
+ }
2120
+
2121
+ void
2122
+ pm_print_node(pm_parser_t *parser, pm_node_t *node) {
2123
+ pm_buffer_t buffer;
2124
+ if (!pm_buffer_init(&buffer)) return;
2125
+
2126
+ prettyprint_node(&buffer, parser, node);
2127
+ printf("%.*s\n", (int) buffer.length, buffer.value);
2128
+
2129
+ pm_buffer_free(&buffer);
2130
+ }
2131
+
2132
+ // Pretty-prints the AST represented by the given node to the given buffer.
2133
+ PRISM_EXPORTED_FUNCTION void
2134
+ pm_prettyprint(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
2135
+ prettyprint_node(buffer, parser, node);
2136
+ }