herb 0.8.6 → 0.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +7 -0
  3. data/config.yml +12 -0
  4. data/ext/herb/error_helpers.c +1 -1
  5. data/ext/herb/extconf.rb +0 -4
  6. data/ext/herb/extension_helpers.c +1 -1
  7. data/ext/herb/nodes.c +18 -10
  8. data/lib/herb/ast/nodes.rb +32 -8
  9. data/lib/herb/engine/debug_visitor.rb +1 -1
  10. data/lib/herb/version.rb +1 -1
  11. data/lib/herb.rb +30 -3
  12. data/sig/herb/ast/nodes.rbs +16 -8
  13. data/sig/serialized_ast_nodes.rbs +4 -0
  14. data/src/analyze.c +137 -42
  15. data/src/analyze_helpers.c +80 -12
  16. data/src/analyzed_ruby.c +1 -0
  17. data/src/ast_node.c +1 -1
  18. data/src/ast_nodes.c +65 -161
  19. data/src/ast_pretty_print.c +52 -0
  20. data/src/errors.c +5 -5
  21. data/src/extract.c +2 -2
  22. data/src/herb.c +2 -2
  23. data/src/include/analyze_helpers.h +7 -0
  24. data/src/include/analyzed_ruby.h +1 -0
  25. data/src/include/ast_nodes.h +8 -4
  26. data/src/include/location.h +4 -0
  27. data/src/include/prism_helpers.h +6 -0
  28. data/src/include/util/hb_narray.h +1 -0
  29. data/src/include/version.h +1 -1
  30. data/src/location.c +16 -0
  31. data/src/parser.c +9 -9
  32. data/src/parser_helpers.c +4 -4
  33. data/src/pretty_print.c +6 -6
  34. data/src/prism_helpers.c +188 -0
  35. data/src/util/hb_array.c +1 -0
  36. data/src/util/hb_narray.c +6 -0
  37. data/src/visitor.c +26 -26
  38. data/templates/ext/herb/error_helpers.c.erb +1 -1
  39. data/templates/ext/herb/nodes.c.erb +3 -1
  40. data/templates/java/error_helpers.c.erb +1 -1
  41. data/templates/java/nodes.c.erb +5 -3
  42. data/templates/java/org/herb/ast/Nodes.java.erb +11 -0
  43. data/templates/javascript/packages/core/src/nodes.ts.erb +14 -0
  44. data/templates/javascript/packages/node/extension/error_helpers.cpp.erb +1 -1
  45. data/templates/javascript/packages/node/extension/nodes.cpp.erb +10 -1
  46. data/templates/lib/herb/ast/nodes.rb.erb +4 -0
  47. data/templates/rust/src/ast/nodes.rs.erb +12 -2
  48. data/templates/rust/src/nodes.rs.erb +4 -0
  49. data/templates/src/ast_nodes.c.erb +7 -7
  50. data/templates/src/ast_pretty_print.c.erb +14 -0
  51. data/templates/src/errors.c.erb +5 -5
  52. data/templates/src/visitor.c.erb +1 -1
  53. data/templates/template.rb +11 -0
  54. data/templates/wasm/error_helpers.cpp.erb +1 -1
  55. data/templates/wasm/nodes.cpp.erb +7 -1
  56. data/vendor/prism/include/prism/version.h +2 -2
  57. data/vendor/prism/src/prism.c +48 -27
  58. data/vendor/prism/templates/java/org/prism/Loader.java.erb +1 -1
  59. data/vendor/prism/templates/javascript/src/deserialize.js.erb +1 -1
  60. data/vendor/prism/templates/lib/prism/compiler.rb.erb +2 -2
  61. data/vendor/prism/templates/lib/prism/node.rb.erb +24 -1
  62. data/vendor/prism/templates/lib/prism/serialize.rb.erb +1 -1
  63. data/vendor/prism/templates/lib/prism/visitor.rb.erb +2 -2
  64. data/vendor/prism/templates/sig/prism/node.rbs.erb +1 -0
  65. metadata +2 -2
data/src/ast_nodes.c CHANGED
@@ -20,11 +20,7 @@ AST_DOCUMENT_NODE_T* ast_document_node_init(hb_array_T* children, position_T sta
20
20
 
21
21
  ast_node_init(&document_node->base, AST_DOCUMENT_NODE, start_position, end_position, errors);
22
22
 
23
- if (children == NULL) {
24
- document_node->children = hb_array_init(8);
25
- } else {
26
- document_node->children = children;
27
- }
23
+ document_node->children = children;
28
24
 
29
25
  return document_node;
30
26
  }
@@ -47,11 +43,7 @@ AST_HTML_OPEN_TAG_NODE_T* ast_html_open_tag_node_init(token_T* tag_opening, toke
47
43
  html_open_tag_node->tag_opening = token_copy(tag_opening);
48
44
  html_open_tag_node->tag_name = token_copy(tag_name);
49
45
  html_open_tag_node->tag_closing = token_copy(tag_closing);
50
- if (children == NULL) {
51
- html_open_tag_node->children = hb_array_init(8);
52
- } else {
53
- html_open_tag_node->children = children;
54
- }
46
+ html_open_tag_node->children = children;
55
47
  html_open_tag_node->is_void = is_void;
56
48
 
57
49
  return html_open_tag_node;
@@ -64,11 +56,7 @@ AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, to
64
56
 
65
57
  html_close_tag_node->tag_opening = token_copy(tag_opening);
66
58
  html_close_tag_node->tag_name = token_copy(tag_name);
67
- if (children == NULL) {
68
- html_close_tag_node->children = hb_array_init(8);
69
- } else {
70
- html_close_tag_node->children = children;
71
- }
59
+ html_close_tag_node->children = children;
72
60
  html_close_tag_node->tag_closing = token_copy(tag_closing);
73
61
 
74
62
  return html_close_tag_node;
@@ -81,11 +69,7 @@ AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NOD
81
69
 
82
70
  html_element_node->open_tag = open_tag;
83
71
  html_element_node->tag_name = token_copy(tag_name);
84
- if (body == NULL) {
85
- html_element_node->body = hb_array_init(8);
86
- } else {
87
- html_element_node->body = body;
88
- }
72
+ html_element_node->body = body;
89
73
  html_element_node->close_tag = close_tag;
90
74
  html_element_node->is_void = is_void;
91
75
  html_element_node->source = source;
@@ -99,11 +83,7 @@ AST_HTML_ATTRIBUTE_VALUE_NODE_T* ast_html_attribute_value_node_init(token_T* ope
99
83
  ast_node_init(&html_attribute_value_node->base, AST_HTML_ATTRIBUTE_VALUE_NODE, start_position, end_position, errors);
100
84
 
101
85
  html_attribute_value_node->open_quote = token_copy(open_quote);
102
- if (children == NULL) {
103
- html_attribute_value_node->children = hb_array_init(8);
104
- } else {
105
- html_attribute_value_node->children = children;
106
- }
86
+ html_attribute_value_node->children = children;
107
87
  html_attribute_value_node->close_quote = token_copy(close_quote);
108
88
  html_attribute_value_node->quoted = quoted;
109
89
 
@@ -115,11 +95,7 @@ AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(hb_array_T* ch
115
95
 
116
96
  ast_node_init(&html_attribute_name_node->base, AST_HTML_ATTRIBUTE_NAME_NODE, start_position, end_position, errors);
117
97
 
118
- if (children == NULL) {
119
- html_attribute_name_node->children = hb_array_init(8);
120
- } else {
121
- html_attribute_name_node->children = children;
122
- }
98
+ html_attribute_name_node->children = children;
123
99
 
124
100
  return html_attribute_name_node;
125
101
  }
@@ -152,11 +128,7 @@ AST_HTML_COMMENT_NODE_T* ast_html_comment_node_init(token_T* comment_start, hb_a
152
128
  ast_node_init(&html_comment_node->base, AST_HTML_COMMENT_NODE, start_position, end_position, errors);
153
129
 
154
130
  html_comment_node->comment_start = token_copy(comment_start);
155
- if (children == NULL) {
156
- html_comment_node->children = hb_array_init(8);
157
- } else {
158
- html_comment_node->children = children;
159
- }
131
+ html_comment_node->children = children;
160
132
  html_comment_node->comment_end = token_copy(comment_end);
161
133
 
162
134
  return html_comment_node;
@@ -168,11 +140,7 @@ AST_HTML_DOCTYPE_NODE_T* ast_html_doctype_node_init(token_T* tag_opening, hb_arr
168
140
  ast_node_init(&html_doctype_node->base, AST_HTML_DOCTYPE_NODE, start_position, end_position, errors);
169
141
 
170
142
  html_doctype_node->tag_opening = token_copy(tag_opening);
171
- if (children == NULL) {
172
- html_doctype_node->children = hb_array_init(8);
173
- } else {
174
- html_doctype_node->children = children;
175
- }
143
+ html_doctype_node->children = children;
176
144
  html_doctype_node->tag_closing = token_copy(tag_closing);
177
145
 
178
146
  return html_doctype_node;
@@ -184,11 +152,7 @@ AST_XML_DECLARATION_NODE_T* ast_xml_declaration_node_init(token_T* tag_opening,
184
152
  ast_node_init(&xml_declaration_node->base, AST_XML_DECLARATION_NODE, start_position, end_position, errors);
185
153
 
186
154
  xml_declaration_node->tag_opening = token_copy(tag_opening);
187
- if (children == NULL) {
188
- xml_declaration_node->children = hb_array_init(8);
189
- } else {
190
- xml_declaration_node->children = children;
191
- }
155
+ xml_declaration_node->children = children;
192
156
  xml_declaration_node->tag_closing = token_copy(tag_closing);
193
157
 
194
158
  return xml_declaration_node;
@@ -200,11 +164,7 @@ AST_CDATA_NODE_T* ast_cdata_node_init(token_T* tag_opening, hb_array_T* children
200
164
  ast_node_init(&cdata_node->base, AST_CDATA_NODE, start_position, end_position, errors);
201
165
 
202
166
  cdata_node->tag_opening = token_copy(tag_opening);
203
- if (children == NULL) {
204
- cdata_node->children = hb_array_init(8);
205
- } else {
206
- cdata_node->children = children;
207
- }
167
+ cdata_node->children = children;
208
168
  cdata_node->tag_closing = token_copy(tag_closing);
209
169
 
210
170
  return cdata_node;
@@ -255,16 +215,12 @@ AST_ERB_ELSE_NODE_T* ast_erb_else_node_init(token_T* tag_opening, token_T* conte
255
215
  erb_else_node->tag_opening = token_copy(tag_opening);
256
216
  erb_else_node->content = token_copy(content);
257
217
  erb_else_node->tag_closing = token_copy(tag_closing);
258
- if (statements == NULL) {
259
- erb_else_node->statements = hb_array_init(8);
260
- } else {
261
- erb_else_node->statements = statements;
262
- }
218
+ erb_else_node->statements = statements;
263
219
 
264
220
  return erb_else_node;
265
221
  }
266
222
 
267
- AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, struct AST_NODE_STRUCT* subsequent, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors) {
223
+ AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, hb_array_T* statements, struct AST_NODE_STRUCT* subsequent, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors) {
268
224
  AST_ERB_IF_NODE_T* erb_if_node = malloc(sizeof(AST_ERB_IF_NODE_T));
269
225
 
270
226
  ast_node_init(&erb_if_node->base, AST_ERB_IF_NODE, start_position, end_position, errors);
@@ -272,11 +228,8 @@ AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content,
272
228
  erb_if_node->tag_opening = token_copy(tag_opening);
273
229
  erb_if_node->content = token_copy(content);
274
230
  erb_if_node->tag_closing = token_copy(tag_closing);
275
- if (statements == NULL) {
276
- erb_if_node->statements = hb_array_init(8);
277
- } else {
278
- erb_if_node->statements = statements;
279
- }
231
+ erb_if_node->then_keyword = then_keyword;
232
+ erb_if_node->statements = statements;
280
233
  erb_if_node->subsequent = subsequent;
281
234
  erb_if_node->end_node = end_node;
282
235
 
@@ -291,17 +244,13 @@ AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* con
291
244
  erb_block_node->tag_opening = token_copy(tag_opening);
292
245
  erb_block_node->content = token_copy(content);
293
246
  erb_block_node->tag_closing = token_copy(tag_closing);
294
- if (body == NULL) {
295
- erb_block_node->body = hb_array_init(8);
296
- } else {
297
- erb_block_node->body = body;
298
- }
247
+ erb_block_node->body = body;
299
248
  erb_block_node->end_node = end_node;
300
249
 
301
250
  return erb_block_node;
302
251
  }
303
252
 
304
- AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors) {
253
+ AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors) {
305
254
  AST_ERB_WHEN_NODE_T* erb_when_node = malloc(sizeof(AST_ERB_WHEN_NODE_T));
306
255
 
307
256
  ast_node_init(&erb_when_node->base, AST_ERB_WHEN_NODE, start_position, end_position, errors);
@@ -309,11 +258,8 @@ AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* conte
309
258
  erb_when_node->tag_opening = token_copy(tag_opening);
310
259
  erb_when_node->content = token_copy(content);
311
260
  erb_when_node->tag_closing = token_copy(tag_closing);
312
- if (statements == NULL) {
313
- erb_when_node->statements = hb_array_init(8);
314
- } else {
315
- erb_when_node->statements = statements;
316
- }
261
+ erb_when_node->then_keyword = then_keyword;
262
+ erb_when_node->statements = statements;
317
263
 
318
264
  return erb_when_node;
319
265
  }
@@ -326,16 +272,8 @@ AST_ERB_CASE_NODE_T* ast_erb_case_node_init(token_T* tag_opening, token_T* conte
326
272
  erb_case_node->tag_opening = token_copy(tag_opening);
327
273
  erb_case_node->content = token_copy(content);
328
274
  erb_case_node->tag_closing = token_copy(tag_closing);
329
- if (children == NULL) {
330
- erb_case_node->children = hb_array_init(8);
331
- } else {
332
- erb_case_node->children = children;
333
- }
334
- if (conditions == NULL) {
335
- erb_case_node->conditions = hb_array_init(8);
336
- } else {
337
- erb_case_node->conditions = conditions;
338
- }
275
+ erb_case_node->children = children;
276
+ erb_case_node->conditions = conditions;
339
277
  erb_case_node->else_clause = else_clause;
340
278
  erb_case_node->end_node = end_node;
341
279
 
@@ -350,16 +288,8 @@ AST_ERB_CASE_MATCH_NODE_T* ast_erb_case_match_node_init(token_T* tag_opening, to
350
288
  erb_case_match_node->tag_opening = token_copy(tag_opening);
351
289
  erb_case_match_node->content = token_copy(content);
352
290
  erb_case_match_node->tag_closing = token_copy(tag_closing);
353
- if (children == NULL) {
354
- erb_case_match_node->children = hb_array_init(8);
355
- } else {
356
- erb_case_match_node->children = children;
357
- }
358
- if (conditions == NULL) {
359
- erb_case_match_node->conditions = hb_array_init(8);
360
- } else {
361
- erb_case_match_node->conditions = conditions;
362
- }
291
+ erb_case_match_node->children = children;
292
+ erb_case_match_node->conditions = conditions;
363
293
  erb_case_match_node->else_clause = else_clause;
364
294
  erb_case_match_node->end_node = end_node;
365
295
 
@@ -374,11 +304,7 @@ AST_ERB_WHILE_NODE_T* ast_erb_while_node_init(token_T* tag_opening, token_T* con
374
304
  erb_while_node->tag_opening = token_copy(tag_opening);
375
305
  erb_while_node->content = token_copy(content);
376
306
  erb_while_node->tag_closing = token_copy(tag_closing);
377
- if (statements == NULL) {
378
- erb_while_node->statements = hb_array_init(8);
379
- } else {
380
- erb_while_node->statements = statements;
381
- }
307
+ erb_while_node->statements = statements;
382
308
  erb_while_node->end_node = end_node;
383
309
 
384
310
  return erb_while_node;
@@ -392,11 +318,7 @@ AST_ERB_UNTIL_NODE_T* ast_erb_until_node_init(token_T* tag_opening, token_T* con
392
318
  erb_until_node->tag_opening = token_copy(tag_opening);
393
319
  erb_until_node->content = token_copy(content);
394
320
  erb_until_node->tag_closing = token_copy(tag_closing);
395
- if (statements == NULL) {
396
- erb_until_node->statements = hb_array_init(8);
397
- } else {
398
- erb_until_node->statements = statements;
399
- }
321
+ erb_until_node->statements = statements;
400
322
  erb_until_node->end_node = end_node;
401
323
 
402
324
  return erb_until_node;
@@ -410,11 +332,7 @@ AST_ERB_FOR_NODE_T* ast_erb_for_node_init(token_T* tag_opening, token_T* content
410
332
  erb_for_node->tag_opening = token_copy(tag_opening);
411
333
  erb_for_node->content = token_copy(content);
412
334
  erb_for_node->tag_closing = token_copy(tag_closing);
413
- if (statements == NULL) {
414
- erb_for_node->statements = hb_array_init(8);
415
- } else {
416
- erb_for_node->statements = statements;
417
- }
335
+ erb_for_node->statements = statements;
418
336
  erb_for_node->end_node = end_node;
419
337
 
420
338
  return erb_for_node;
@@ -428,11 +346,7 @@ AST_ERB_RESCUE_NODE_T* ast_erb_rescue_node_init(token_T* tag_opening, token_T* c
428
346
  erb_rescue_node->tag_opening = token_copy(tag_opening);
429
347
  erb_rescue_node->content = token_copy(content);
430
348
  erb_rescue_node->tag_closing = token_copy(tag_closing);
431
- if (statements == NULL) {
432
- erb_rescue_node->statements = hb_array_init(8);
433
- } else {
434
- erb_rescue_node->statements = statements;
435
- }
349
+ erb_rescue_node->statements = statements;
436
350
  erb_rescue_node->subsequent = subsequent;
437
351
 
438
352
  return erb_rescue_node;
@@ -446,11 +360,7 @@ AST_ERB_ENSURE_NODE_T* ast_erb_ensure_node_init(token_T* tag_opening, token_T* c
446
360
  erb_ensure_node->tag_opening = token_copy(tag_opening);
447
361
  erb_ensure_node->content = token_copy(content);
448
362
  erb_ensure_node->tag_closing = token_copy(tag_closing);
449
- if (statements == NULL) {
450
- erb_ensure_node->statements = hb_array_init(8);
451
- } else {
452
- erb_ensure_node->statements = statements;
453
- }
363
+ erb_ensure_node->statements = statements;
454
364
 
455
365
  return erb_ensure_node;
456
366
  }
@@ -463,11 +373,7 @@ AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* con
463
373
  erb_begin_node->tag_opening = token_copy(tag_opening);
464
374
  erb_begin_node->content = token_copy(content);
465
375
  erb_begin_node->tag_closing = token_copy(tag_closing);
466
- if (statements == NULL) {
467
- erb_begin_node->statements = hb_array_init(8);
468
- } else {
469
- erb_begin_node->statements = statements;
470
- }
376
+ erb_begin_node->statements = statements;
471
377
  erb_begin_node->rescue_clause = rescue_clause;
472
378
  erb_begin_node->else_clause = else_clause;
473
379
  erb_begin_node->ensure_clause = ensure_clause;
@@ -476,7 +382,7 @@ AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* con
476
382
  return erb_begin_node;
477
383
  }
478
384
 
479
- AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors) {
385
+ AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, hb_array_T* statements, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors) {
480
386
  AST_ERB_UNLESS_NODE_T* erb_unless_node = malloc(sizeof(AST_ERB_UNLESS_NODE_T));
481
387
 
482
388
  ast_node_init(&erb_unless_node->base, AST_ERB_UNLESS_NODE, start_position, end_position, errors);
@@ -484,11 +390,8 @@ AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* c
484
390
  erb_unless_node->tag_opening = token_copy(tag_opening);
485
391
  erb_unless_node->content = token_copy(content);
486
392
  erb_unless_node->tag_closing = token_copy(tag_closing);
487
- if (statements == NULL) {
488
- erb_unless_node->statements = hb_array_init(8);
489
- } else {
490
- erb_unless_node->statements = statements;
491
- }
393
+ erb_unless_node->then_keyword = then_keyword;
394
+ erb_unless_node->statements = statements;
492
395
  erb_unless_node->else_clause = else_clause;
493
396
  erb_unless_node->end_node = end_node;
494
397
 
@@ -507,7 +410,7 @@ AST_ERB_YIELD_NODE_T* ast_erb_yield_node_init(token_T* tag_opening, token_T* con
507
410
  return erb_yield_node;
508
411
  }
509
412
 
510
- AST_ERB_IN_NODE_T* ast_erb_in_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors) {
413
+ AST_ERB_IN_NODE_T* ast_erb_in_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors) {
511
414
  AST_ERB_IN_NODE_T* erb_in_node = malloc(sizeof(AST_ERB_IN_NODE_T));
512
415
 
513
416
  ast_node_init(&erb_in_node->base, AST_ERB_IN_NODE, start_position, end_position, errors);
@@ -515,11 +418,8 @@ AST_ERB_IN_NODE_T* ast_erb_in_node_init(token_T* tag_opening, token_T* content,
515
418
  erb_in_node->tag_opening = token_copy(tag_opening);
516
419
  erb_in_node->content = token_copy(content);
517
420
  erb_in_node->tag_closing = token_copy(tag_closing);
518
- if (statements == NULL) {
519
- erb_in_node->statements = hb_array_init(8);
520
- } else {
521
- erb_in_node->statements = statements;
522
- }
421
+ erb_in_node->then_keyword = then_keyword;
422
+ erb_in_node->statements = statements;
523
423
 
524
424
  return erb_in_node;
525
425
  }
@@ -604,7 +504,7 @@ void ast_free_base_node(AST_NODE_T* node) {
604
504
  if (node == NULL) { return; }
605
505
 
606
506
  if (node->errors) {
607
- for (size_t i = 0; i < node->errors->size; i++) {
507
+ for (size_t i = 0; i < hb_array_size(node->errors); i++) {
608
508
  ERROR_T* child = hb_array_get(node->errors, i);
609
509
  if (child != NULL) { error_free(child); }
610
510
  }
@@ -618,7 +518,7 @@ void ast_free_base_node(AST_NODE_T* node) {
618
518
 
619
519
  static void ast_free_document_node(AST_DOCUMENT_NODE_T* document_node) {
620
520
  if (document_node->children != NULL) {
621
- for (size_t i = 0; i < document_node->children->size; i++) {
521
+ for (size_t i = 0; i < hb_array_size(document_node->children); i++) {
622
522
  AST_NODE_T* child = hb_array_get(document_node->children, i);
623
523
  if (child) { ast_node_free(child); }
624
524
  }
@@ -640,7 +540,7 @@ static void ast_free_html_open_tag_node(AST_HTML_OPEN_TAG_NODE_T* html_open_tag_
640
540
  if (html_open_tag_node->tag_name != NULL) { token_free(html_open_tag_node->tag_name); }
641
541
  if (html_open_tag_node->tag_closing != NULL) { token_free(html_open_tag_node->tag_closing); }
642
542
  if (html_open_tag_node->children != NULL) {
643
- for (size_t i = 0; i < html_open_tag_node->children->size; i++) {
543
+ for (size_t i = 0; i < hb_array_size(html_open_tag_node->children); i++) {
644
544
  AST_NODE_T* child = hb_array_get(html_open_tag_node->children, i);
645
545
  if (child) { ast_node_free(child); }
646
546
  }
@@ -655,7 +555,7 @@ static void ast_free_html_close_tag_node(AST_HTML_CLOSE_TAG_NODE_T* html_close_t
655
555
  if (html_close_tag_node->tag_opening != NULL) { token_free(html_close_tag_node->tag_opening); }
656
556
  if (html_close_tag_node->tag_name != NULL) { token_free(html_close_tag_node->tag_name); }
657
557
  if (html_close_tag_node->children != NULL) {
658
- for (size_t i = 0; i < html_close_tag_node->children->size; i++) {
558
+ for (size_t i = 0; i < hb_array_size(html_close_tag_node->children); i++) {
659
559
  AST_NODE_T* child = hb_array_get(html_close_tag_node->children, i);
660
560
  if (child) { ast_node_free(child); }
661
561
  }
@@ -671,7 +571,7 @@ static void ast_free_html_element_node(AST_HTML_ELEMENT_NODE_T* html_element_nod
671
571
  ast_node_free((AST_NODE_T*) html_element_node->open_tag);
672
572
  if (html_element_node->tag_name != NULL) { token_free(html_element_node->tag_name); }
673
573
  if (html_element_node->body != NULL) {
674
- for (size_t i = 0; i < html_element_node->body->size; i++) {
574
+ for (size_t i = 0; i < hb_array_size(html_element_node->body); i++) {
675
575
  AST_NODE_T* child = hb_array_get(html_element_node->body, i);
676
576
  if (child) { ast_node_free(child); }
677
577
  }
@@ -686,7 +586,7 @@ static void ast_free_html_element_node(AST_HTML_ELEMENT_NODE_T* html_element_nod
686
586
  static void ast_free_html_attribute_value_node(AST_HTML_ATTRIBUTE_VALUE_NODE_T* html_attribute_value_node) {
687
587
  if (html_attribute_value_node->open_quote != NULL) { token_free(html_attribute_value_node->open_quote); }
688
588
  if (html_attribute_value_node->children != NULL) {
689
- for (size_t i = 0; i < html_attribute_value_node->children->size; i++) {
589
+ for (size_t i = 0; i < hb_array_size(html_attribute_value_node->children); i++) {
690
590
  AST_NODE_T* child = hb_array_get(html_attribute_value_node->children, i);
691
591
  if (child) { ast_node_free(child); }
692
592
  }
@@ -700,7 +600,7 @@ static void ast_free_html_attribute_value_node(AST_HTML_ATTRIBUTE_VALUE_NODE_T*
700
600
 
701
601
  static void ast_free_html_attribute_name_node(AST_HTML_ATTRIBUTE_NAME_NODE_T* html_attribute_name_node) {
702
602
  if (html_attribute_name_node->children != NULL) {
703
- for (size_t i = 0; i < html_attribute_name_node->children->size; i++) {
603
+ for (size_t i = 0; i < hb_array_size(html_attribute_name_node->children); i++) {
704
604
  AST_NODE_T* child = hb_array_get(html_attribute_name_node->children, i);
705
605
  if (child) { ast_node_free(child); }
706
606
  }
@@ -728,7 +628,7 @@ static void ast_free_html_text_node(AST_HTML_TEXT_NODE_T* html_text_node) {
728
628
  static void ast_free_html_comment_node(AST_HTML_COMMENT_NODE_T* html_comment_node) {
729
629
  if (html_comment_node->comment_start != NULL) { token_free(html_comment_node->comment_start); }
730
630
  if (html_comment_node->children != NULL) {
731
- for (size_t i = 0; i < html_comment_node->children->size; i++) {
631
+ for (size_t i = 0; i < hb_array_size(html_comment_node->children); i++) {
732
632
  AST_NODE_T* child = hb_array_get(html_comment_node->children, i);
733
633
  if (child) { ast_node_free(child); }
734
634
  }
@@ -743,7 +643,7 @@ static void ast_free_html_comment_node(AST_HTML_COMMENT_NODE_T* html_comment_nod
743
643
  static void ast_free_html_doctype_node(AST_HTML_DOCTYPE_NODE_T* html_doctype_node) {
744
644
  if (html_doctype_node->tag_opening != NULL) { token_free(html_doctype_node->tag_opening); }
745
645
  if (html_doctype_node->children != NULL) {
746
- for (size_t i = 0; i < html_doctype_node->children->size; i++) {
646
+ for (size_t i = 0; i < hb_array_size(html_doctype_node->children); i++) {
747
647
  AST_NODE_T* child = hb_array_get(html_doctype_node->children, i);
748
648
  if (child) { ast_node_free(child); }
749
649
  }
@@ -758,7 +658,7 @@ static void ast_free_html_doctype_node(AST_HTML_DOCTYPE_NODE_T* html_doctype_nod
758
658
  static void ast_free_xml_declaration_node(AST_XML_DECLARATION_NODE_T* xml_declaration_node) {
759
659
  if (xml_declaration_node->tag_opening != NULL) { token_free(xml_declaration_node->tag_opening); }
760
660
  if (xml_declaration_node->children != NULL) {
761
- for (size_t i = 0; i < xml_declaration_node->children->size; i++) {
661
+ for (size_t i = 0; i < hb_array_size(xml_declaration_node->children); i++) {
762
662
  AST_NODE_T* child = hb_array_get(xml_declaration_node->children, i);
763
663
  if (child) { ast_node_free(child); }
764
664
  }
@@ -773,7 +673,7 @@ static void ast_free_xml_declaration_node(AST_XML_DECLARATION_NODE_T* xml_declar
773
673
  static void ast_free_cdata_node(AST_CDATA_NODE_T* cdata_node) {
774
674
  if (cdata_node->tag_opening != NULL) { token_free(cdata_node->tag_opening); }
775
675
  if (cdata_node->children != NULL) {
776
- for (size_t i = 0; i < cdata_node->children->size; i++) {
676
+ for (size_t i = 0; i < hb_array_size(cdata_node->children); i++) {
777
677
  AST_NODE_T* child = hb_array_get(cdata_node->children, i);
778
678
  if (child) { ast_node_free(child); }
779
679
  }
@@ -815,7 +715,7 @@ static void ast_free_erb_else_node(AST_ERB_ELSE_NODE_T* erb_else_node) {
815
715
  if (erb_else_node->content != NULL) { token_free(erb_else_node->content); }
816
716
  if (erb_else_node->tag_closing != NULL) { token_free(erb_else_node->tag_closing); }
817
717
  if (erb_else_node->statements != NULL) {
818
- for (size_t i = 0; i < erb_else_node->statements->size; i++) {
718
+ for (size_t i = 0; i < hb_array_size(erb_else_node->statements); i++) {
819
719
  AST_NODE_T* child = hb_array_get(erb_else_node->statements, i);
820
720
  if (child) { ast_node_free(child); }
821
721
  }
@@ -830,8 +730,9 @@ static void ast_free_erb_if_node(AST_ERB_IF_NODE_T* erb_if_node) {
830
730
  if (erb_if_node->tag_opening != NULL) { token_free(erb_if_node->tag_opening); }
831
731
  if (erb_if_node->content != NULL) { token_free(erb_if_node->content); }
832
732
  if (erb_if_node->tag_closing != NULL) { token_free(erb_if_node->tag_closing); }
733
+ if (erb_if_node->then_keyword != NULL) { free(erb_if_node->then_keyword); }
833
734
  if (erb_if_node->statements != NULL) {
834
- for (size_t i = 0; i < erb_if_node->statements->size; i++) {
735
+ for (size_t i = 0; i < hb_array_size(erb_if_node->statements); i++) {
835
736
  AST_NODE_T* child = hb_array_get(erb_if_node->statements, i);
836
737
  if (child) { ast_node_free(child); }
837
738
  }
@@ -849,7 +750,7 @@ static void ast_free_erb_block_node(AST_ERB_BLOCK_NODE_T* erb_block_node) {
849
750
  if (erb_block_node->content != NULL) { token_free(erb_block_node->content); }
850
751
  if (erb_block_node->tag_closing != NULL) { token_free(erb_block_node->tag_closing); }
851
752
  if (erb_block_node->body != NULL) {
852
- for (size_t i = 0; i < erb_block_node->body->size; i++) {
753
+ for (size_t i = 0; i < hb_array_size(erb_block_node->body); i++) {
853
754
  AST_NODE_T* child = hb_array_get(erb_block_node->body, i);
854
755
  if (child) { ast_node_free(child); }
855
756
  }
@@ -865,8 +766,9 @@ static void ast_free_erb_when_node(AST_ERB_WHEN_NODE_T* erb_when_node) {
865
766
  if (erb_when_node->tag_opening != NULL) { token_free(erb_when_node->tag_opening); }
866
767
  if (erb_when_node->content != NULL) { token_free(erb_when_node->content); }
867
768
  if (erb_when_node->tag_closing != NULL) { token_free(erb_when_node->tag_closing); }
769
+ if (erb_when_node->then_keyword != NULL) { free(erb_when_node->then_keyword); }
868
770
  if (erb_when_node->statements != NULL) {
869
- for (size_t i = 0; i < erb_when_node->statements->size; i++) {
771
+ for (size_t i = 0; i < hb_array_size(erb_when_node->statements); i++) {
870
772
  AST_NODE_T* child = hb_array_get(erb_when_node->statements, i);
871
773
  if (child) { ast_node_free(child); }
872
774
  }
@@ -882,7 +784,7 @@ static void ast_free_erb_case_node(AST_ERB_CASE_NODE_T* erb_case_node) {
882
784
  if (erb_case_node->content != NULL) { token_free(erb_case_node->content); }
883
785
  if (erb_case_node->tag_closing != NULL) { token_free(erb_case_node->tag_closing); }
884
786
  if (erb_case_node->children != NULL) {
885
- for (size_t i = 0; i < erb_case_node->children->size; i++) {
787
+ for (size_t i = 0; i < hb_array_size(erb_case_node->children); i++) {
886
788
  AST_NODE_T* child = hb_array_get(erb_case_node->children, i);
887
789
  if (child) { ast_node_free(child); }
888
790
  }
@@ -890,7 +792,7 @@ static void ast_free_erb_case_node(AST_ERB_CASE_NODE_T* erb_case_node) {
890
792
  hb_array_free(&erb_case_node->children);
891
793
  }
892
794
  if (erb_case_node->conditions != NULL) {
893
- for (size_t i = 0; i < erb_case_node->conditions->size; i++) {
795
+ for (size_t i = 0; i < hb_array_size(erb_case_node->conditions); i++) {
894
796
  AST_NODE_T* child = hb_array_get(erb_case_node->conditions, i);
895
797
  if (child) { ast_node_free(child); }
896
798
  }
@@ -908,7 +810,7 @@ static void ast_free_erb_case_match_node(AST_ERB_CASE_MATCH_NODE_T* erb_case_mat
908
810
  if (erb_case_match_node->content != NULL) { token_free(erb_case_match_node->content); }
909
811
  if (erb_case_match_node->tag_closing != NULL) { token_free(erb_case_match_node->tag_closing); }
910
812
  if (erb_case_match_node->children != NULL) {
911
- for (size_t i = 0; i < erb_case_match_node->children->size; i++) {
813
+ for (size_t i = 0; i < hb_array_size(erb_case_match_node->children); i++) {
912
814
  AST_NODE_T* child = hb_array_get(erb_case_match_node->children, i);
913
815
  if (child) { ast_node_free(child); }
914
816
  }
@@ -916,7 +818,7 @@ static void ast_free_erb_case_match_node(AST_ERB_CASE_MATCH_NODE_T* erb_case_mat
916
818
  hb_array_free(&erb_case_match_node->children);
917
819
  }
918
820
  if (erb_case_match_node->conditions != NULL) {
919
- for (size_t i = 0; i < erb_case_match_node->conditions->size; i++) {
821
+ for (size_t i = 0; i < hb_array_size(erb_case_match_node->conditions); i++) {
920
822
  AST_NODE_T* child = hb_array_get(erb_case_match_node->conditions, i);
921
823
  if (child) { ast_node_free(child); }
922
824
  }
@@ -934,7 +836,7 @@ static void ast_free_erb_while_node(AST_ERB_WHILE_NODE_T* erb_while_node) {
934
836
  if (erb_while_node->content != NULL) { token_free(erb_while_node->content); }
935
837
  if (erb_while_node->tag_closing != NULL) { token_free(erb_while_node->tag_closing); }
936
838
  if (erb_while_node->statements != NULL) {
937
- for (size_t i = 0; i < erb_while_node->statements->size; i++) {
839
+ for (size_t i = 0; i < hb_array_size(erb_while_node->statements); i++) {
938
840
  AST_NODE_T* child = hb_array_get(erb_while_node->statements, i);
939
841
  if (child) { ast_node_free(child); }
940
842
  }
@@ -951,7 +853,7 @@ static void ast_free_erb_until_node(AST_ERB_UNTIL_NODE_T* erb_until_node) {
951
853
  if (erb_until_node->content != NULL) { token_free(erb_until_node->content); }
952
854
  if (erb_until_node->tag_closing != NULL) { token_free(erb_until_node->tag_closing); }
953
855
  if (erb_until_node->statements != NULL) {
954
- for (size_t i = 0; i < erb_until_node->statements->size; i++) {
856
+ for (size_t i = 0; i < hb_array_size(erb_until_node->statements); i++) {
955
857
  AST_NODE_T* child = hb_array_get(erb_until_node->statements, i);
956
858
  if (child) { ast_node_free(child); }
957
859
  }
@@ -968,7 +870,7 @@ static void ast_free_erb_for_node(AST_ERB_FOR_NODE_T* erb_for_node) {
968
870
  if (erb_for_node->content != NULL) { token_free(erb_for_node->content); }
969
871
  if (erb_for_node->tag_closing != NULL) { token_free(erb_for_node->tag_closing); }
970
872
  if (erb_for_node->statements != NULL) {
971
- for (size_t i = 0; i < erb_for_node->statements->size; i++) {
873
+ for (size_t i = 0; i < hb_array_size(erb_for_node->statements); i++) {
972
874
  AST_NODE_T* child = hb_array_get(erb_for_node->statements, i);
973
875
  if (child) { ast_node_free(child); }
974
876
  }
@@ -985,7 +887,7 @@ static void ast_free_erb_rescue_node(AST_ERB_RESCUE_NODE_T* erb_rescue_node) {
985
887
  if (erb_rescue_node->content != NULL) { token_free(erb_rescue_node->content); }
986
888
  if (erb_rescue_node->tag_closing != NULL) { token_free(erb_rescue_node->tag_closing); }
987
889
  if (erb_rescue_node->statements != NULL) {
988
- for (size_t i = 0; i < erb_rescue_node->statements->size; i++) {
890
+ for (size_t i = 0; i < hb_array_size(erb_rescue_node->statements); i++) {
989
891
  AST_NODE_T* child = hb_array_get(erb_rescue_node->statements, i);
990
892
  if (child) { ast_node_free(child); }
991
893
  }
@@ -1002,7 +904,7 @@ static void ast_free_erb_ensure_node(AST_ERB_ENSURE_NODE_T* erb_ensure_node) {
1002
904
  if (erb_ensure_node->content != NULL) { token_free(erb_ensure_node->content); }
1003
905
  if (erb_ensure_node->tag_closing != NULL) { token_free(erb_ensure_node->tag_closing); }
1004
906
  if (erb_ensure_node->statements != NULL) {
1005
- for (size_t i = 0; i < erb_ensure_node->statements->size; i++) {
907
+ for (size_t i = 0; i < hb_array_size(erb_ensure_node->statements); i++) {
1006
908
  AST_NODE_T* child = hb_array_get(erb_ensure_node->statements, i);
1007
909
  if (child) { ast_node_free(child); }
1008
910
  }
@@ -1018,7 +920,7 @@ static void ast_free_erb_begin_node(AST_ERB_BEGIN_NODE_T* erb_begin_node) {
1018
920
  if (erb_begin_node->content != NULL) { token_free(erb_begin_node->content); }
1019
921
  if (erb_begin_node->tag_closing != NULL) { token_free(erb_begin_node->tag_closing); }
1020
922
  if (erb_begin_node->statements != NULL) {
1021
- for (size_t i = 0; i < erb_begin_node->statements->size; i++) {
923
+ for (size_t i = 0; i < hb_array_size(erb_begin_node->statements); i++) {
1022
924
  AST_NODE_T* child = hb_array_get(erb_begin_node->statements, i);
1023
925
  if (child) { ast_node_free(child); }
1024
926
  }
@@ -1037,8 +939,9 @@ static void ast_free_erb_unless_node(AST_ERB_UNLESS_NODE_T* erb_unless_node) {
1037
939
  if (erb_unless_node->tag_opening != NULL) { token_free(erb_unless_node->tag_opening); }
1038
940
  if (erb_unless_node->content != NULL) { token_free(erb_unless_node->content); }
1039
941
  if (erb_unless_node->tag_closing != NULL) { token_free(erb_unless_node->tag_closing); }
942
+ if (erb_unless_node->then_keyword != NULL) { free(erb_unless_node->then_keyword); }
1040
943
  if (erb_unless_node->statements != NULL) {
1041
- for (size_t i = 0; i < erb_unless_node->statements->size; i++) {
944
+ for (size_t i = 0; i < hb_array_size(erb_unless_node->statements); i++) {
1042
945
  AST_NODE_T* child = hb_array_get(erb_unless_node->statements, i);
1043
946
  if (child) { ast_node_free(child); }
1044
947
  }
@@ -1063,8 +966,9 @@ static void ast_free_erb_in_node(AST_ERB_IN_NODE_T* erb_in_node) {
1063
966
  if (erb_in_node->tag_opening != NULL) { token_free(erb_in_node->tag_opening); }
1064
967
  if (erb_in_node->content != NULL) { token_free(erb_in_node->content); }
1065
968
  if (erb_in_node->tag_closing != NULL) { token_free(erb_in_node->tag_closing); }
969
+ if (erb_in_node->then_keyword != NULL) { free(erb_in_node->then_keyword); }
1066
970
  if (erb_in_node->statements != NULL) {
1067
- for (size_t i = 0; i < erb_in_node->statements->size; i++) {
971
+ for (size_t i = 0; i < hb_array_size(erb_in_node->statements); i++) {
1068
972
  AST_NODE_T* child = hb_array_get(erb_in_node->statements, i);
1069
973
  if (child) { ast_node_free(child); }
1070
974
  }