@herb-tools/node 0.8.10 → 0.9.0

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 (169) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/binding.gyp +26 -8
  3. package/dist/herb-node.cjs +41 -12
  4. package/dist/herb-node.cjs.map +1 -1
  5. package/dist/herb-node.esm.js +8 -1
  6. package/dist/herb-node.esm.js.map +1 -1
  7. package/dist/types/node-backend.d.ts +3 -1
  8. package/extension/error_helpers.cpp +395 -73
  9. package/extension/error_helpers.h +13 -3
  10. package/extension/extension_helpers.cpp +38 -35
  11. package/extension/extension_helpers.h +2 -2
  12. package/extension/herb.cpp +183 -64
  13. package/extension/libherb/analyze/action_view/attribute_extraction_helpers.c +290 -0
  14. package/extension/libherb/analyze/action_view/attribute_extraction_helpers.h +36 -0
  15. package/extension/libherb/analyze/action_view/content_tag.c +70 -0
  16. package/extension/libherb/analyze/action_view/link_to.c +143 -0
  17. package/extension/libherb/analyze/action_view/registry.c +60 -0
  18. package/extension/libherb/analyze/action_view/tag.c +64 -0
  19. package/extension/libherb/analyze/action_view/tag_helper_handler.h +41 -0
  20. package/extension/libherb/analyze/action_view/tag_helper_node_builders.c +305 -0
  21. package/extension/libherb/analyze/action_view/tag_helper_node_builders.h +70 -0
  22. package/extension/libherb/analyze/action_view/tag_helpers.c +748 -0
  23. package/extension/libherb/analyze/action_view/tag_helpers.h +38 -0
  24. package/extension/libherb/analyze/action_view/turbo_frame_tag.c +88 -0
  25. package/extension/libherb/analyze/analyze.c +882 -0
  26. package/extension/libherb/{include → analyze}/analyze.h +14 -4
  27. package/extension/libherb/{analyzed_ruby.c → analyze/analyzed_ruby.c} +13 -11
  28. package/extension/libherb/{analyzed_ruby.h → analyze/analyzed_ruby.h} +3 -3
  29. package/extension/libherb/analyze/builders.c +343 -0
  30. package/extension/libherb/analyze/builders.h +27 -0
  31. package/extension/libherb/analyze/conditional_elements.c +594 -0
  32. package/extension/libherb/analyze/conditional_elements.h +9 -0
  33. package/extension/libherb/analyze/conditional_open_tags.c +640 -0
  34. package/extension/libherb/analyze/conditional_open_tags.h +9 -0
  35. package/extension/libherb/analyze/control_type.c +250 -0
  36. package/extension/libherb/analyze/control_type.h +14 -0
  37. package/extension/libherb/{analyze_helpers.c → analyze/helpers.c} +48 -23
  38. package/extension/libherb/{analyze_helpers.h → analyze/helpers.h} +4 -2
  39. package/extension/libherb/analyze/invalid_structures.c +193 -0
  40. package/extension/libherb/analyze/invalid_structures.h +11 -0
  41. package/extension/libherb/{analyze_missing_end.c → analyze/missing_end.c} +33 -22
  42. package/extension/libherb/analyze/parse_errors.c +84 -0
  43. package/extension/libherb/analyze/prism_annotate.c +397 -0
  44. package/extension/libherb/analyze/prism_annotate.h +16 -0
  45. package/extension/libherb/{analyze_transform.c → analyze/transform.c} +17 -3
  46. package/extension/libherb/ast_node.c +17 -7
  47. package/extension/libherb/ast_node.h +11 -5
  48. package/extension/libherb/ast_nodes.c +663 -388
  49. package/extension/libherb/ast_nodes.h +118 -39
  50. package/extension/libherb/ast_pretty_print.c +191 -7
  51. package/extension/libherb/ast_pretty_print.h +6 -1
  52. package/extension/libherb/element_source.h +3 -8
  53. package/extension/libherb/errors.c +1077 -521
  54. package/extension/libherb/errors.h +149 -56
  55. package/extension/libherb/extract.c +145 -49
  56. package/extension/libherb/extract.h +21 -5
  57. package/extension/libherb/herb.c +52 -34
  58. package/extension/libherb/herb.h +18 -6
  59. package/extension/libherb/herb_prism_node.h +13 -0
  60. package/extension/libherb/html_util.c +241 -12
  61. package/extension/libherb/html_util.h +7 -2
  62. package/extension/libherb/include/analyze/action_view/attribute_extraction_helpers.h +36 -0
  63. package/extension/libherb/include/analyze/action_view/tag_helper_handler.h +41 -0
  64. package/extension/libherb/include/analyze/action_view/tag_helper_node_builders.h +70 -0
  65. package/extension/libherb/include/analyze/action_view/tag_helpers.h +38 -0
  66. package/extension/libherb/{analyze.h → include/analyze/analyze.h} +14 -4
  67. package/extension/libherb/include/{analyzed_ruby.h → analyze/analyzed_ruby.h} +3 -3
  68. package/extension/libherb/include/analyze/builders.h +27 -0
  69. package/extension/libherb/include/analyze/conditional_elements.h +9 -0
  70. package/extension/libherb/include/analyze/conditional_open_tags.h +9 -0
  71. package/extension/libherb/include/analyze/control_type.h +14 -0
  72. package/extension/libherb/include/{analyze_helpers.h → analyze/helpers.h} +4 -2
  73. package/extension/libherb/include/analyze/invalid_structures.h +11 -0
  74. package/extension/libherb/include/analyze/prism_annotate.h +16 -0
  75. package/extension/libherb/include/ast_node.h +11 -5
  76. package/extension/libherb/include/ast_nodes.h +118 -39
  77. package/extension/libherb/include/ast_pretty_print.h +6 -1
  78. package/extension/libherb/include/element_source.h +3 -8
  79. package/extension/libherb/include/errors.h +149 -56
  80. package/extension/libherb/include/extract.h +21 -5
  81. package/extension/libherb/include/herb.h +18 -6
  82. package/extension/libherb/include/herb_prism_node.h +13 -0
  83. package/extension/libherb/include/html_util.h +7 -2
  84. package/extension/libherb/include/io.h +3 -1
  85. package/extension/libherb/include/lex_helpers.h +29 -0
  86. package/extension/libherb/include/lexer.h +1 -1
  87. package/extension/libherb/include/lexer_peek_helpers.h +87 -13
  88. package/extension/libherb/include/lexer_struct.h +2 -0
  89. package/extension/libherb/include/location.h +2 -1
  90. package/extension/libherb/include/parser.h +27 -2
  91. package/extension/libherb/include/parser_helpers.h +19 -3
  92. package/extension/libherb/include/pretty_print.h +10 -5
  93. package/extension/libherb/include/prism_context.h +45 -0
  94. package/extension/libherb/include/prism_helpers.h +10 -7
  95. package/extension/libherb/include/prism_serialized.h +12 -0
  96. package/extension/libherb/include/token.h +16 -4
  97. package/extension/libherb/include/token_struct.h +10 -3
  98. package/extension/libherb/include/utf8.h +2 -1
  99. package/extension/libherb/include/util/hb_allocator.h +78 -0
  100. package/extension/libherb/include/util/hb_arena.h +6 -1
  101. package/extension/libherb/include/util/hb_arena_debug.h +12 -1
  102. package/extension/libherb/include/util/hb_array.h +7 -3
  103. package/extension/libherb/include/util/hb_buffer.h +6 -4
  104. package/extension/libherb/include/util/hb_foreach.h +79 -0
  105. package/extension/libherb/include/util/hb_narray.h +8 -4
  106. package/extension/libherb/include/util/hb_string.h +56 -9
  107. package/extension/libherb/include/util.h +6 -3
  108. package/extension/libherb/include/version.h +1 -1
  109. package/extension/libherb/io.c +3 -2
  110. package/extension/libherb/io.h +3 -1
  111. package/extension/libherb/lex_helpers.h +29 -0
  112. package/extension/libherb/lexer.c +42 -30
  113. package/extension/libherb/lexer.h +1 -1
  114. package/extension/libherb/lexer_peek_helpers.c +12 -74
  115. package/extension/libherb/lexer_peek_helpers.h +87 -13
  116. package/extension/libherb/lexer_struct.h +2 -0
  117. package/extension/libherb/location.c +2 -2
  118. package/extension/libherb/location.h +2 -1
  119. package/extension/libherb/main.c +53 -28
  120. package/extension/libherb/parser.c +783 -247
  121. package/extension/libherb/parser.h +27 -2
  122. package/extension/libherb/parser_helpers.c +110 -23
  123. package/extension/libherb/parser_helpers.h +19 -3
  124. package/extension/libherb/parser_match_tags.c +110 -49
  125. package/extension/libherb/pretty_print.c +29 -24
  126. package/extension/libherb/pretty_print.h +10 -5
  127. package/extension/libherb/prism_context.h +45 -0
  128. package/extension/libherb/prism_helpers.c +30 -27
  129. package/extension/libherb/prism_helpers.h +10 -7
  130. package/extension/libherb/prism_serialized.h +12 -0
  131. package/extension/libherb/ruby_parser.c +2 -0
  132. package/extension/libherb/token.c +151 -66
  133. package/extension/libherb/token.h +16 -4
  134. package/extension/libherb/token_matchers.c +0 -1
  135. package/extension/libherb/token_struct.h +10 -3
  136. package/extension/libherb/utf8.c +7 -6
  137. package/extension/libherb/utf8.h +2 -1
  138. package/extension/libherb/util/hb_allocator.c +341 -0
  139. package/extension/libherb/util/hb_allocator.h +78 -0
  140. package/extension/libherb/util/hb_arena.c +81 -56
  141. package/extension/libherb/util/hb_arena.h +6 -1
  142. package/extension/libherb/util/hb_arena_debug.c +32 -17
  143. package/extension/libherb/util/hb_arena_debug.h +12 -1
  144. package/extension/libherb/util/hb_array.c +30 -15
  145. package/extension/libherb/util/hb_array.h +7 -3
  146. package/extension/libherb/util/hb_buffer.c +17 -21
  147. package/extension/libherb/util/hb_buffer.h +6 -4
  148. package/extension/libherb/util/hb_foreach.h +79 -0
  149. package/extension/libherb/util/hb_narray.c +22 -7
  150. package/extension/libherb/util/hb_narray.h +8 -4
  151. package/extension/libherb/util/hb_string.c +49 -35
  152. package/extension/libherb/util/hb_string.h +56 -9
  153. package/extension/libherb/util.c +21 -11
  154. package/extension/libherb/util.h +6 -3
  155. package/extension/libherb/version.h +1 -1
  156. package/extension/libherb/visitor.c +48 -1
  157. package/extension/nodes.cpp +451 -6
  158. package/extension/nodes.h +8 -1
  159. package/package.json +12 -8
  160. package/src/node-backend.ts +11 -1
  161. package/dist/types/index-cjs.d.cts +0 -1
  162. package/extension/libherb/analyze.c +0 -1608
  163. package/extension/libherb/element_source.c +0 -12
  164. package/extension/libherb/include/util/hb_system.h +0 -9
  165. package/extension/libherb/util/hb_system.c +0 -30
  166. package/extension/libherb/util/hb_system.h +0 -9
  167. package/src/index-cjs.cts +0 -22
  168. /package/dist/types/{index-esm.d.mts → index.d.ts} +0 -0
  169. /package/src/{index-esm.mts → index.ts} +0 -0
@@ -1,234 +1,374 @@
1
1
  // NOTE: This file is generated by the templates/template.rb script and should not
2
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.10/templates/src/ast_nodes.c.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.0/templates/src/ast_nodes.c.erb
3
3
 
4
4
  #include <stdio.h>
5
5
  #include <stdbool.h>
6
6
 
7
7
  #include <prism.h>
8
8
 
9
- #include "include/analyzed_ruby.h"
9
+ #include "include/analyze/analyzed_ruby.h"
10
10
  #include "include/ast_node.h"
11
11
  #include "include/ast_nodes.h"
12
12
  #include "include/errors.h"
13
13
  #include "include/token.h"
14
14
  #include "include/util.h"
15
+ #include "include/util/hb_allocator.h"
15
16
  #include "include/util/hb_array.h"
17
+ #include "include/util/hb_string.h"
16
18
 
17
19
 
18
- AST_DOCUMENT_NODE_T* ast_document_node_init(hb_array_T* children, position_T start_position, position_T end_position, hb_array_T* errors) {
19
- AST_DOCUMENT_NODE_T* document_node = malloc(sizeof(AST_DOCUMENT_NODE_T));
20
+ AST_DOCUMENT_NODE_T* ast_document_node_init(hb_array_T* children, herb_prism_context_T* prism_context, herb_prism_node_T prism_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
21
+ AST_DOCUMENT_NODE_T* document_node = hb_allocator_alloc(allocator, sizeof(AST_DOCUMENT_NODE_T));
20
22
 
21
- ast_node_init(&document_node->base, AST_DOCUMENT_NODE, start_position, end_position, errors);
23
+ if (!document_node) { return NULL; }
24
+
25
+ ast_node_init(&document_node->base, AST_DOCUMENT_NODE, start_position, end_position, errors, allocator);
22
26
 
23
27
  document_node->children = children;
28
+ document_node->prism_context = prism_context;
29
+ document_node->prism_node = prism_node;
24
30
 
25
31
  return document_node;
26
32
  }
27
33
 
28
- AST_LITERAL_NODE_T* ast_literal_node_init(const char* content, position_T start_position, position_T end_position, hb_array_T* errors) {
29
- AST_LITERAL_NODE_T* literal_node = malloc(sizeof(AST_LITERAL_NODE_T));
34
+ AST_LITERAL_NODE_T* ast_literal_node_init(hb_string_T content, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
35
+ AST_LITERAL_NODE_T* literal_node = hb_allocator_alloc(allocator, sizeof(AST_LITERAL_NODE_T));
36
+
37
+ if (!literal_node) { return NULL; }
30
38
 
31
- ast_node_init(&literal_node->base, AST_LITERAL_NODE, start_position, end_position, errors);
39
+ ast_node_init(&literal_node->base, AST_LITERAL_NODE, start_position, end_position, errors, allocator);
32
40
 
33
- literal_node->content = herb_strdup(content);
41
+ literal_node->content = hb_string_copy(content, allocator);
34
42
 
35
43
  return literal_node;
36
44
  }
37
45
 
38
- AST_HTML_OPEN_TAG_NODE_T* ast_html_open_tag_node_init(token_T* tag_opening, token_T* tag_name, token_T* tag_closing, hb_array_T* children, bool is_void, position_T start_position, position_T end_position, hb_array_T* errors) {
39
- AST_HTML_OPEN_TAG_NODE_T* html_open_tag_node = malloc(sizeof(AST_HTML_OPEN_TAG_NODE_T));
46
+ AST_HTML_OPEN_TAG_NODE_T* ast_html_open_tag_node_init(token_T* tag_opening, token_T* tag_name, token_T* tag_closing, hb_array_T* children, bool is_void, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
47
+ AST_HTML_OPEN_TAG_NODE_T* html_open_tag_node = hb_allocator_alloc(allocator, sizeof(AST_HTML_OPEN_TAG_NODE_T));
40
48
 
41
- ast_node_init(&html_open_tag_node->base, AST_HTML_OPEN_TAG_NODE, start_position, end_position, errors);
49
+ if (!html_open_tag_node) { return NULL; }
42
50
 
43
- html_open_tag_node->tag_opening = token_copy(tag_opening);
44
- html_open_tag_node->tag_name = token_copy(tag_name);
45
- html_open_tag_node->tag_closing = token_copy(tag_closing);
51
+ ast_node_init(&html_open_tag_node->base, AST_HTML_OPEN_TAG_NODE, start_position, end_position, errors, allocator);
52
+
53
+ html_open_tag_node->tag_opening = token_copy(tag_opening, allocator);
54
+ html_open_tag_node->tag_name = token_copy(tag_name, allocator);
55
+ html_open_tag_node->tag_closing = token_copy(tag_closing, allocator);
46
56
  html_open_tag_node->children = children;
47
57
  html_open_tag_node->is_void = is_void;
48
58
 
49
59
  return html_open_tag_node;
50
60
  }
51
61
 
52
- AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, token_T* tag_name, hb_array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors) {
53
- AST_HTML_CLOSE_TAG_NODE_T* html_close_tag_node = malloc(sizeof(AST_HTML_CLOSE_TAG_NODE_T));
62
+ AST_HTML_CONDITIONAL_OPEN_TAG_NODE_T* ast_html_conditional_open_tag_node_init(AST_NODE_T* conditional, token_T* tag_name, bool is_void, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
63
+ AST_HTML_CONDITIONAL_OPEN_TAG_NODE_T* html_conditional_open_tag_node = hb_allocator_alloc(allocator, sizeof(AST_HTML_CONDITIONAL_OPEN_TAG_NODE_T));
64
+
65
+ if (!html_conditional_open_tag_node) { return NULL; }
54
66
 
55
- ast_node_init(&html_close_tag_node->base, AST_HTML_CLOSE_TAG_NODE, start_position, end_position, errors);
67
+ ast_node_init(&html_conditional_open_tag_node->base, AST_HTML_CONDITIONAL_OPEN_TAG_NODE, start_position, end_position, errors, allocator);
68
+
69
+ html_conditional_open_tag_node->conditional = conditional;
70
+ html_conditional_open_tag_node->tag_name = token_copy(tag_name, allocator);
71
+ html_conditional_open_tag_node->is_void = is_void;
72
+
73
+ return html_conditional_open_tag_node;
74
+ }
56
75
 
57
- html_close_tag_node->tag_opening = token_copy(tag_opening);
58
- html_close_tag_node->tag_name = token_copy(tag_name);
76
+ AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, token_T* tag_name, hb_array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
77
+ AST_HTML_CLOSE_TAG_NODE_T* html_close_tag_node = hb_allocator_alloc(allocator, sizeof(AST_HTML_CLOSE_TAG_NODE_T));
78
+
79
+ if (!html_close_tag_node) { return NULL; }
80
+
81
+ ast_node_init(&html_close_tag_node->base, AST_HTML_CLOSE_TAG_NODE, start_position, end_position, errors, allocator);
82
+
83
+ html_close_tag_node->tag_opening = token_copy(tag_opening, allocator);
84
+ html_close_tag_node->tag_name = token_copy(tag_name, allocator);
59
85
  html_close_tag_node->children = children;
60
- html_close_tag_node->tag_closing = token_copy(tag_closing);
86
+ html_close_tag_node->tag_closing = token_copy(tag_closing, allocator);
61
87
 
62
88
  return html_close_tag_node;
63
89
  }
64
90
 
65
- AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, token_T* tag_name, hb_array_T* body, struct AST_HTML_CLOSE_TAG_NODE_STRUCT* close_tag, bool is_void, element_source_t source, position_T start_position, position_T end_position, hb_array_T* errors) {
66
- AST_HTML_ELEMENT_NODE_T* html_element_node = malloc(sizeof(AST_HTML_ELEMENT_NODE_T));
91
+ AST_HTML_OMITTED_CLOSE_TAG_NODE_T* ast_html_omitted_close_tag_node_init(token_T* tag_name, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
92
+ AST_HTML_OMITTED_CLOSE_TAG_NODE_T* html_omitted_close_tag_node = hb_allocator_alloc(allocator, sizeof(AST_HTML_OMITTED_CLOSE_TAG_NODE_T));
67
93
 
68
- ast_node_init(&html_element_node->base, AST_HTML_ELEMENT_NODE, start_position, end_position, errors);
94
+ if (!html_omitted_close_tag_node) { return NULL; }
95
+
96
+ ast_node_init(&html_omitted_close_tag_node->base, AST_HTML_OMITTED_CLOSE_TAG_NODE, start_position, end_position, errors, allocator);
97
+
98
+ html_omitted_close_tag_node->tag_name = token_copy(tag_name, allocator);
99
+
100
+ return html_omitted_close_tag_node;
101
+ }
102
+
103
+ AST_HTML_VIRTUAL_CLOSE_TAG_NODE_T* ast_html_virtual_close_tag_node_init(token_T* tag_name, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
104
+ AST_HTML_VIRTUAL_CLOSE_TAG_NODE_T* html_virtual_close_tag_node = hb_allocator_alloc(allocator, sizeof(AST_HTML_VIRTUAL_CLOSE_TAG_NODE_T));
105
+
106
+ if (!html_virtual_close_tag_node) { return NULL; }
107
+
108
+ ast_node_init(&html_virtual_close_tag_node->base, AST_HTML_VIRTUAL_CLOSE_TAG_NODE, start_position, end_position, errors, allocator);
109
+
110
+ html_virtual_close_tag_node->tag_name = token_copy(tag_name, allocator);
111
+
112
+ return html_virtual_close_tag_node;
113
+ }
114
+
115
+ AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(AST_NODE_T* open_tag, token_T* tag_name, hb_array_T* body, AST_NODE_T* close_tag, bool is_void, hb_string_T element_source, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
116
+ AST_HTML_ELEMENT_NODE_T* html_element_node = hb_allocator_alloc(allocator, sizeof(AST_HTML_ELEMENT_NODE_T));
117
+
118
+ if (!html_element_node) { return NULL; }
119
+
120
+ ast_node_init(&html_element_node->base, AST_HTML_ELEMENT_NODE, start_position, end_position, errors, allocator);
69
121
 
70
122
  html_element_node->open_tag = open_tag;
71
- html_element_node->tag_name = token_copy(tag_name);
123
+ html_element_node->tag_name = token_copy(tag_name, allocator);
72
124
  html_element_node->body = body;
73
125
  html_element_node->close_tag = close_tag;
74
126
  html_element_node->is_void = is_void;
75
- html_element_node->source = source;
127
+ html_element_node->element_source = element_source;
76
128
 
77
129
  return html_element_node;
78
130
  }
79
131
 
80
- AST_HTML_ATTRIBUTE_VALUE_NODE_T* ast_html_attribute_value_node_init(token_T* open_quote, hb_array_T* children, token_T* close_quote, bool quoted, position_T start_position, position_T end_position, hb_array_T* errors) {
81
- AST_HTML_ATTRIBUTE_VALUE_NODE_T* html_attribute_value_node = malloc(sizeof(AST_HTML_ATTRIBUTE_VALUE_NODE_T));
132
+ AST_HTML_CONDITIONAL_ELEMENT_NODE_T* ast_html_conditional_element_node_init(hb_string_T condition, AST_NODE_T* open_conditional, struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, hb_array_T* body, AST_NODE_T* close_tag, AST_NODE_T* close_conditional, token_T* tag_name, hb_string_T element_source, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
133
+ AST_HTML_CONDITIONAL_ELEMENT_NODE_T* html_conditional_element_node = hb_allocator_alloc(allocator, sizeof(AST_HTML_CONDITIONAL_ELEMENT_NODE_T));
134
+
135
+ if (!html_conditional_element_node) { return NULL; }
136
+
137
+ ast_node_init(&html_conditional_element_node->base, AST_HTML_CONDITIONAL_ELEMENT_NODE, start_position, end_position, errors, allocator);
138
+
139
+ html_conditional_element_node->condition = hb_string_copy(condition, allocator);
140
+ html_conditional_element_node->open_conditional = open_conditional;
141
+ html_conditional_element_node->open_tag = open_tag;
142
+ html_conditional_element_node->body = body;
143
+ html_conditional_element_node->close_tag = close_tag;
144
+ html_conditional_element_node->close_conditional = close_conditional;
145
+ html_conditional_element_node->tag_name = token_copy(tag_name, allocator);
146
+ html_conditional_element_node->element_source = element_source;
147
+
148
+ return html_conditional_element_node;
149
+ }
150
+
151
+ AST_HTML_ATTRIBUTE_VALUE_NODE_T* ast_html_attribute_value_node_init(token_T* open_quote, hb_array_T* children, token_T* close_quote, bool quoted, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
152
+ AST_HTML_ATTRIBUTE_VALUE_NODE_T* html_attribute_value_node = hb_allocator_alloc(allocator, sizeof(AST_HTML_ATTRIBUTE_VALUE_NODE_T));
82
153
 
83
- ast_node_init(&html_attribute_value_node->base, AST_HTML_ATTRIBUTE_VALUE_NODE, start_position, end_position, errors);
154
+ if (!html_attribute_value_node) { return NULL; }
84
155
 
85
- html_attribute_value_node->open_quote = token_copy(open_quote);
156
+ ast_node_init(&html_attribute_value_node->base, AST_HTML_ATTRIBUTE_VALUE_NODE, start_position, end_position, errors, allocator);
157
+
158
+ html_attribute_value_node->open_quote = token_copy(open_quote, allocator);
86
159
  html_attribute_value_node->children = children;
87
- html_attribute_value_node->close_quote = token_copy(close_quote);
160
+ html_attribute_value_node->close_quote = token_copy(close_quote, allocator);
88
161
  html_attribute_value_node->quoted = quoted;
89
162
 
90
163
  return html_attribute_value_node;
91
164
  }
92
165
 
93
- AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(hb_array_T* children, position_T start_position, position_T end_position, hb_array_T* errors) {
94
- AST_HTML_ATTRIBUTE_NAME_NODE_T* html_attribute_name_node = malloc(sizeof(AST_HTML_ATTRIBUTE_NAME_NODE_T));
166
+ AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(hb_array_T* children, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
167
+ AST_HTML_ATTRIBUTE_NAME_NODE_T* html_attribute_name_node = hb_allocator_alloc(allocator, sizeof(AST_HTML_ATTRIBUTE_NAME_NODE_T));
168
+
169
+ if (!html_attribute_name_node) { return NULL; }
95
170
 
96
- ast_node_init(&html_attribute_name_node->base, AST_HTML_ATTRIBUTE_NAME_NODE, start_position, end_position, errors);
171
+ ast_node_init(&html_attribute_name_node->base, AST_HTML_ATTRIBUTE_NAME_NODE, start_position, end_position, errors, allocator);
97
172
 
98
173
  html_attribute_name_node->children = children;
99
174
 
100
175
  return html_attribute_name_node;
101
176
  }
102
177
 
103
- AST_HTML_ATTRIBUTE_NODE_T* ast_html_attribute_node_init(struct AST_HTML_ATTRIBUTE_NAME_NODE_STRUCT* name, token_T* equals, struct AST_HTML_ATTRIBUTE_VALUE_NODE_STRUCT* value, position_T start_position, position_T end_position, hb_array_T* errors) {
104
- AST_HTML_ATTRIBUTE_NODE_T* html_attribute_node = malloc(sizeof(AST_HTML_ATTRIBUTE_NODE_T));
178
+ AST_HTML_ATTRIBUTE_NODE_T* ast_html_attribute_node_init(struct AST_HTML_ATTRIBUTE_NAME_NODE_STRUCT* name, token_T* equals, struct AST_HTML_ATTRIBUTE_VALUE_NODE_STRUCT* value, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
179
+ AST_HTML_ATTRIBUTE_NODE_T* html_attribute_node = hb_allocator_alloc(allocator, sizeof(AST_HTML_ATTRIBUTE_NODE_T));
180
+
181
+ if (!html_attribute_node) { return NULL; }
105
182
 
106
- ast_node_init(&html_attribute_node->base, AST_HTML_ATTRIBUTE_NODE, start_position, end_position, errors);
183
+ ast_node_init(&html_attribute_node->base, AST_HTML_ATTRIBUTE_NODE, start_position, end_position, errors, allocator);
107
184
 
108
185
  html_attribute_node->name = name;
109
- html_attribute_node->equals = token_copy(equals);
186
+ html_attribute_node->equals = token_copy(equals, allocator);
110
187
  html_attribute_node->value = value;
111
188
 
112
189
  return html_attribute_node;
113
190
  }
114
191
 
115
- AST_HTML_TEXT_NODE_T* ast_html_text_node_init(const char* content, position_T start_position, position_T end_position, hb_array_T* errors) {
116
- AST_HTML_TEXT_NODE_T* html_text_node = malloc(sizeof(AST_HTML_TEXT_NODE_T));
192
+ AST_RUBY_LITERAL_NODE_T* ast_ruby_literal_node_init(hb_string_T content, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
193
+ AST_RUBY_LITERAL_NODE_T* ruby_literal_node = hb_allocator_alloc(allocator, sizeof(AST_RUBY_LITERAL_NODE_T));
194
+
195
+ if (!ruby_literal_node) { return NULL; }
196
+
197
+ ast_node_init(&ruby_literal_node->base, AST_RUBY_LITERAL_NODE, start_position, end_position, errors, allocator);
198
+
199
+ ruby_literal_node->content = hb_string_copy(content, allocator);
200
+
201
+ return ruby_literal_node;
202
+ }
203
+
204
+ AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE_T* ast_ruby_html_attributes_splat_node_init(hb_string_T content, hb_string_T prefix, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
205
+ AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE_T* ruby_html_attributes_splat_node = hb_allocator_alloc(allocator, sizeof(AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE_T));
206
+
207
+ if (!ruby_html_attributes_splat_node) { return NULL; }
208
+
209
+ ast_node_init(&ruby_html_attributes_splat_node->base, AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE, start_position, end_position, errors, allocator);
210
+
211
+ ruby_html_attributes_splat_node->content = hb_string_copy(content, allocator);
212
+ ruby_html_attributes_splat_node->prefix = hb_string_copy(prefix, allocator);
213
+
214
+ return ruby_html_attributes_splat_node;
215
+ }
216
+
217
+ AST_ERB_OPEN_TAG_NODE_T* ast_erb_open_tag_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, token_T* tag_name, hb_array_T* children, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
218
+ AST_ERB_OPEN_TAG_NODE_T* erb_open_tag_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_OPEN_TAG_NODE_T));
219
+
220
+ if (!erb_open_tag_node) { return NULL; }
221
+
222
+ ast_node_init(&erb_open_tag_node->base, AST_ERB_OPEN_TAG_NODE, start_position, end_position, errors, allocator);
223
+
224
+ erb_open_tag_node->tag_opening = token_copy(tag_opening, allocator);
225
+ erb_open_tag_node->content = token_copy(content, allocator);
226
+ erb_open_tag_node->tag_closing = token_copy(tag_closing, allocator);
227
+ erb_open_tag_node->tag_name = token_copy(tag_name, allocator);
228
+ erb_open_tag_node->children = children;
229
+
230
+ return erb_open_tag_node;
231
+ }
232
+
233
+ AST_HTML_TEXT_NODE_T* ast_html_text_node_init(hb_string_T content, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
234
+ AST_HTML_TEXT_NODE_T* html_text_node = hb_allocator_alloc(allocator, sizeof(AST_HTML_TEXT_NODE_T));
117
235
 
118
- ast_node_init(&html_text_node->base, AST_HTML_TEXT_NODE, start_position, end_position, errors);
236
+ if (!html_text_node) { return NULL; }
119
237
 
120
- html_text_node->content = herb_strdup(content);
238
+ ast_node_init(&html_text_node->base, AST_HTML_TEXT_NODE, start_position, end_position, errors, allocator);
239
+
240
+ html_text_node->content = hb_string_copy(content, allocator);
121
241
 
122
242
  return html_text_node;
123
243
  }
124
244
 
125
- AST_HTML_COMMENT_NODE_T* ast_html_comment_node_init(token_T* comment_start, hb_array_T* children, token_T* comment_end, position_T start_position, position_T end_position, hb_array_T* errors) {
126
- AST_HTML_COMMENT_NODE_T* html_comment_node = malloc(sizeof(AST_HTML_COMMENT_NODE_T));
245
+ AST_HTML_COMMENT_NODE_T* ast_html_comment_node_init(token_T* comment_start, hb_array_T* children, token_T* comment_end, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
246
+ AST_HTML_COMMENT_NODE_T* html_comment_node = hb_allocator_alloc(allocator, sizeof(AST_HTML_COMMENT_NODE_T));
247
+
248
+ if (!html_comment_node) { return NULL; }
127
249
 
128
- ast_node_init(&html_comment_node->base, AST_HTML_COMMENT_NODE, start_position, end_position, errors);
250
+ ast_node_init(&html_comment_node->base, AST_HTML_COMMENT_NODE, start_position, end_position, errors, allocator);
129
251
 
130
- html_comment_node->comment_start = token_copy(comment_start);
252
+ html_comment_node->comment_start = token_copy(comment_start, allocator);
131
253
  html_comment_node->children = children;
132
- html_comment_node->comment_end = token_copy(comment_end);
254
+ html_comment_node->comment_end = token_copy(comment_end, allocator);
133
255
 
134
256
  return html_comment_node;
135
257
  }
136
258
 
137
- AST_HTML_DOCTYPE_NODE_T* ast_html_doctype_node_init(token_T* tag_opening, hb_array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors) {
138
- AST_HTML_DOCTYPE_NODE_T* html_doctype_node = malloc(sizeof(AST_HTML_DOCTYPE_NODE_T));
259
+ AST_HTML_DOCTYPE_NODE_T* ast_html_doctype_node_init(token_T* tag_opening, hb_array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
260
+ AST_HTML_DOCTYPE_NODE_T* html_doctype_node = hb_allocator_alloc(allocator, sizeof(AST_HTML_DOCTYPE_NODE_T));
139
261
 
140
- ast_node_init(&html_doctype_node->base, AST_HTML_DOCTYPE_NODE, start_position, end_position, errors);
262
+ if (!html_doctype_node) { return NULL; }
141
263
 
142
- html_doctype_node->tag_opening = token_copy(tag_opening);
264
+ ast_node_init(&html_doctype_node->base, AST_HTML_DOCTYPE_NODE, start_position, end_position, errors, allocator);
265
+
266
+ html_doctype_node->tag_opening = token_copy(tag_opening, allocator);
143
267
  html_doctype_node->children = children;
144
- html_doctype_node->tag_closing = token_copy(tag_closing);
268
+ html_doctype_node->tag_closing = token_copy(tag_closing, allocator);
145
269
 
146
270
  return html_doctype_node;
147
271
  }
148
272
 
149
- AST_XML_DECLARATION_NODE_T* ast_xml_declaration_node_init(token_T* tag_opening, hb_array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors) {
150
- AST_XML_DECLARATION_NODE_T* xml_declaration_node = malloc(sizeof(AST_XML_DECLARATION_NODE_T));
273
+ AST_XML_DECLARATION_NODE_T* ast_xml_declaration_node_init(token_T* tag_opening, hb_array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
274
+ AST_XML_DECLARATION_NODE_T* xml_declaration_node = hb_allocator_alloc(allocator, sizeof(AST_XML_DECLARATION_NODE_T));
275
+
276
+ if (!xml_declaration_node) { return NULL; }
151
277
 
152
- ast_node_init(&xml_declaration_node->base, AST_XML_DECLARATION_NODE, start_position, end_position, errors);
278
+ ast_node_init(&xml_declaration_node->base, AST_XML_DECLARATION_NODE, start_position, end_position, errors, allocator);
153
279
 
154
- xml_declaration_node->tag_opening = token_copy(tag_opening);
280
+ xml_declaration_node->tag_opening = token_copy(tag_opening, allocator);
155
281
  xml_declaration_node->children = children;
156
- xml_declaration_node->tag_closing = token_copy(tag_closing);
282
+ xml_declaration_node->tag_closing = token_copy(tag_closing, allocator);
157
283
 
158
284
  return xml_declaration_node;
159
285
  }
160
286
 
161
- AST_CDATA_NODE_T* ast_cdata_node_init(token_T* tag_opening, hb_array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors) {
162
- AST_CDATA_NODE_T* cdata_node = malloc(sizeof(AST_CDATA_NODE_T));
287
+ AST_CDATA_NODE_T* ast_cdata_node_init(token_T* tag_opening, hb_array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
288
+ AST_CDATA_NODE_T* cdata_node = hb_allocator_alloc(allocator, sizeof(AST_CDATA_NODE_T));
163
289
 
164
- ast_node_init(&cdata_node->base, AST_CDATA_NODE, start_position, end_position, errors);
290
+ if (!cdata_node) { return NULL; }
165
291
 
166
- cdata_node->tag_opening = token_copy(tag_opening);
292
+ ast_node_init(&cdata_node->base, AST_CDATA_NODE, start_position, end_position, errors, allocator);
293
+
294
+ cdata_node->tag_opening = token_copy(tag_opening, allocator);
167
295
  cdata_node->children = children;
168
- cdata_node->tag_closing = token_copy(tag_closing);
296
+ cdata_node->tag_closing = token_copy(tag_closing, allocator);
169
297
 
170
298
  return cdata_node;
171
299
  }
172
300
 
173
- AST_WHITESPACE_NODE_T* ast_whitespace_node_init(token_T* value, position_T start_position, position_T end_position, hb_array_T* errors) {
174
- AST_WHITESPACE_NODE_T* whitespace_node = malloc(sizeof(AST_WHITESPACE_NODE_T));
301
+ AST_WHITESPACE_NODE_T* ast_whitespace_node_init(token_T* value, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
302
+ AST_WHITESPACE_NODE_T* whitespace_node = hb_allocator_alloc(allocator, sizeof(AST_WHITESPACE_NODE_T));
303
+
304
+ if (!whitespace_node) { return NULL; }
175
305
 
176
- ast_node_init(&whitespace_node->base, AST_WHITESPACE_NODE, start_position, end_position, errors);
306
+ ast_node_init(&whitespace_node->base, AST_WHITESPACE_NODE, start_position, end_position, errors, allocator);
177
307
 
178
- whitespace_node->value = token_copy(value);
308
+ whitespace_node->value = token_copy(value, allocator);
179
309
 
180
310
  return whitespace_node;
181
311
  }
182
312
 
183
- AST_ERB_CONTENT_NODE_T* ast_erb_content_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, analyzed_ruby_T* analyzed_ruby, bool parsed, bool valid, position_T start_position, position_T end_position, hb_array_T* errors) {
184
- AST_ERB_CONTENT_NODE_T* erb_content_node = malloc(sizeof(AST_ERB_CONTENT_NODE_T));
313
+ AST_ERB_CONTENT_NODE_T* ast_erb_content_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, analyzed_ruby_T* analyzed_ruby, bool parsed, bool valid, herb_prism_node_T prism_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
314
+ AST_ERB_CONTENT_NODE_T* erb_content_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_CONTENT_NODE_T));
315
+
316
+ if (!erb_content_node) { return NULL; }
185
317
 
186
- ast_node_init(&erb_content_node->base, AST_ERB_CONTENT_NODE, start_position, end_position, errors);
318
+ ast_node_init(&erb_content_node->base, AST_ERB_CONTENT_NODE, start_position, end_position, errors, allocator);
187
319
 
188
- erb_content_node->tag_opening = token_copy(tag_opening);
189
- erb_content_node->content = token_copy(content);
190
- erb_content_node->tag_closing = token_copy(tag_closing);
320
+ erb_content_node->tag_opening = token_copy(tag_opening, allocator);
321
+ erb_content_node->content = token_copy(content, allocator);
322
+ erb_content_node->tag_closing = token_copy(tag_closing, allocator);
191
323
  erb_content_node->analyzed_ruby = analyzed_ruby;
192
324
  erb_content_node->parsed = parsed;
193
325
  erb_content_node->valid = valid;
326
+ erb_content_node->prism_node = prism_node;
194
327
 
195
328
  return erb_content_node;
196
329
  }
197
330
 
198
- AST_ERB_END_NODE_T* ast_erb_end_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors) {
199
- AST_ERB_END_NODE_T* erb_end_node = malloc(sizeof(AST_ERB_END_NODE_T));
331
+ AST_ERB_END_NODE_T* ast_erb_end_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
332
+ AST_ERB_END_NODE_T* erb_end_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_END_NODE_T));
200
333
 
201
- ast_node_init(&erb_end_node->base, AST_ERB_END_NODE, start_position, end_position, errors);
334
+ if (!erb_end_node) { return NULL; }
202
335
 
203
- erb_end_node->tag_opening = token_copy(tag_opening);
204
- erb_end_node->content = token_copy(content);
205
- erb_end_node->tag_closing = token_copy(tag_closing);
336
+ ast_node_init(&erb_end_node->base, AST_ERB_END_NODE, start_position, end_position, errors, allocator);
337
+
338
+ erb_end_node->tag_opening = token_copy(tag_opening, allocator);
339
+ erb_end_node->content = token_copy(content, allocator);
340
+ erb_end_node->tag_closing = token_copy(tag_closing, allocator);
206
341
 
207
342
  return erb_end_node;
208
343
  }
209
344
 
210
- AST_ERB_ELSE_NODE_T* ast_erb_else_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) {
211
- AST_ERB_ELSE_NODE_T* erb_else_node = malloc(sizeof(AST_ERB_ELSE_NODE_T));
345
+ AST_ERB_ELSE_NODE_T* ast_erb_else_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, hb_allocator_T* allocator) {
346
+ AST_ERB_ELSE_NODE_T* erb_else_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_ELSE_NODE_T));
347
+
348
+ if (!erb_else_node) { return NULL; }
212
349
 
213
- ast_node_init(&erb_else_node->base, AST_ERB_ELSE_NODE, start_position, end_position, errors);
350
+ ast_node_init(&erb_else_node->base, AST_ERB_ELSE_NODE, start_position, end_position, errors, allocator);
214
351
 
215
- erb_else_node->tag_opening = token_copy(tag_opening);
216
- erb_else_node->content = token_copy(content);
217
- erb_else_node->tag_closing = token_copy(tag_closing);
352
+ erb_else_node->tag_opening = token_copy(tag_opening, allocator);
353
+ erb_else_node->content = token_copy(content, allocator);
354
+ erb_else_node->tag_closing = token_copy(tag_closing, allocator);
218
355
  erb_else_node->statements = statements;
219
356
 
220
357
  return erb_else_node;
221
358
  }
222
359
 
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) {
224
- AST_ERB_IF_NODE_T* erb_if_node = malloc(sizeof(AST_ERB_IF_NODE_T));
360
+ 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, herb_prism_node_T prism_node, hb_array_T* statements, AST_NODE_T* subsequent, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
361
+ AST_ERB_IF_NODE_T* erb_if_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_IF_NODE_T));
362
+
363
+ if (!erb_if_node) { return NULL; }
225
364
 
226
- ast_node_init(&erb_if_node->base, AST_ERB_IF_NODE, start_position, end_position, errors);
365
+ ast_node_init(&erb_if_node->base, AST_ERB_IF_NODE, start_position, end_position, errors, allocator);
227
366
 
228
- erb_if_node->tag_opening = token_copy(tag_opening);
229
- erb_if_node->content = token_copy(content);
230
- erb_if_node->tag_closing = token_copy(tag_closing);
367
+ erb_if_node->tag_opening = token_copy(tag_opening, allocator);
368
+ erb_if_node->content = token_copy(content, allocator);
369
+ erb_if_node->tag_closing = token_copy(tag_closing, allocator);
231
370
  erb_if_node->then_keyword = then_keyword;
371
+ erb_if_node->prism_node = prism_node;
232
372
  erb_if_node->statements = statements;
233
373
  erb_if_node->subsequent = subsequent;
234
374
  erb_if_node->end_node = end_node;
@@ -236,43 +376,51 @@ AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content,
236
376
  return erb_if_node;
237
377
  }
238
378
 
239
- AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* body, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors) {
240
- AST_ERB_BLOCK_NODE_T* erb_block_node = malloc(sizeof(AST_ERB_BLOCK_NODE_T));
379
+ AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, herb_prism_node_T prism_node, hb_array_T* body, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
380
+ AST_ERB_BLOCK_NODE_T* erb_block_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_BLOCK_NODE_T));
241
381
 
242
- ast_node_init(&erb_block_node->base, AST_ERB_BLOCK_NODE, start_position, end_position, errors);
382
+ if (!erb_block_node) { return NULL; }
243
383
 
244
- erb_block_node->tag_opening = token_copy(tag_opening);
245
- erb_block_node->content = token_copy(content);
246
- erb_block_node->tag_closing = token_copy(tag_closing);
384
+ ast_node_init(&erb_block_node->base, AST_ERB_BLOCK_NODE, start_position, end_position, errors, allocator);
385
+
386
+ erb_block_node->tag_opening = token_copy(tag_opening, allocator);
387
+ erb_block_node->content = token_copy(content, allocator);
388
+ erb_block_node->tag_closing = token_copy(tag_closing, allocator);
389
+ erb_block_node->prism_node = prism_node;
247
390
  erb_block_node->body = body;
248
391
  erb_block_node->end_node = end_node;
249
392
 
250
393
  return erb_block_node;
251
394
  }
252
395
 
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) {
254
- AST_ERB_WHEN_NODE_T* erb_when_node = malloc(sizeof(AST_ERB_WHEN_NODE_T));
396
+ 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, hb_allocator_T* allocator) {
397
+ AST_ERB_WHEN_NODE_T* erb_when_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_WHEN_NODE_T));
398
+
399
+ if (!erb_when_node) { return NULL; }
255
400
 
256
- ast_node_init(&erb_when_node->base, AST_ERB_WHEN_NODE, start_position, end_position, errors);
401
+ ast_node_init(&erb_when_node->base, AST_ERB_WHEN_NODE, start_position, end_position, errors, allocator);
257
402
 
258
- erb_when_node->tag_opening = token_copy(tag_opening);
259
- erb_when_node->content = token_copy(content);
260
- erb_when_node->tag_closing = token_copy(tag_closing);
403
+ erb_when_node->tag_opening = token_copy(tag_opening, allocator);
404
+ erb_when_node->content = token_copy(content, allocator);
405
+ erb_when_node->tag_closing = token_copy(tag_closing, allocator);
261
406
  erb_when_node->then_keyword = then_keyword;
262
407
  erb_when_node->statements = statements;
263
408
 
264
409
  return erb_when_node;
265
410
  }
266
411
 
267
- AST_ERB_CASE_NODE_T* ast_erb_case_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* children, hb_array_T* conditions, 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) {
268
- AST_ERB_CASE_NODE_T* erb_case_node = malloc(sizeof(AST_ERB_CASE_NODE_T));
412
+ AST_ERB_CASE_NODE_T* ast_erb_case_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* children, herb_prism_node_T prism_node, hb_array_T* conditions, 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, hb_allocator_T* allocator) {
413
+ AST_ERB_CASE_NODE_T* erb_case_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_CASE_NODE_T));
414
+
415
+ if (!erb_case_node) { return NULL; }
269
416
 
270
- ast_node_init(&erb_case_node->base, AST_ERB_CASE_NODE, start_position, end_position, errors);
417
+ ast_node_init(&erb_case_node->base, AST_ERB_CASE_NODE, start_position, end_position, errors, allocator);
271
418
 
272
- erb_case_node->tag_opening = token_copy(tag_opening);
273
- erb_case_node->content = token_copy(content);
274
- erb_case_node->tag_closing = token_copy(tag_closing);
419
+ erb_case_node->tag_opening = token_copy(tag_opening, allocator);
420
+ erb_case_node->content = token_copy(content, allocator);
421
+ erb_case_node->tag_closing = token_copy(tag_closing, allocator);
275
422
  erb_case_node->children = children;
423
+ erb_case_node->prism_node = prism_node;
276
424
  erb_case_node->conditions = conditions;
277
425
  erb_case_node->else_clause = else_clause;
278
426
  erb_case_node->end_node = end_node;
@@ -280,15 +428,18 @@ AST_ERB_CASE_NODE_T* ast_erb_case_node_init(token_T* tag_opening, token_T* conte
280
428
  return erb_case_node;
281
429
  }
282
430
 
283
- AST_ERB_CASE_MATCH_NODE_T* ast_erb_case_match_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* children, hb_array_T* conditions, 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) {
284
- AST_ERB_CASE_MATCH_NODE_T* erb_case_match_node = malloc(sizeof(AST_ERB_CASE_MATCH_NODE_T));
431
+ AST_ERB_CASE_MATCH_NODE_T* ast_erb_case_match_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* children, herb_prism_node_T prism_node, hb_array_T* conditions, 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, hb_allocator_T* allocator) {
432
+ AST_ERB_CASE_MATCH_NODE_T* erb_case_match_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_CASE_MATCH_NODE_T));
285
433
 
286
- ast_node_init(&erb_case_match_node->base, AST_ERB_CASE_MATCH_NODE, start_position, end_position, errors);
434
+ if (!erb_case_match_node) { return NULL; }
287
435
 
288
- erb_case_match_node->tag_opening = token_copy(tag_opening);
289
- erb_case_match_node->content = token_copy(content);
290
- erb_case_match_node->tag_closing = token_copy(tag_closing);
436
+ ast_node_init(&erb_case_match_node->base, AST_ERB_CASE_MATCH_NODE, start_position, end_position, errors, allocator);
437
+
438
+ erb_case_match_node->tag_opening = token_copy(tag_opening, allocator);
439
+ erb_case_match_node->content = token_copy(content, allocator);
440
+ erb_case_match_node->tag_closing = token_copy(tag_closing, allocator);
291
441
  erb_case_match_node->children = children;
442
+ erb_case_match_node->prism_node = prism_node;
292
443
  erb_case_match_node->conditions = conditions;
293
444
  erb_case_match_node->else_clause = else_clause;
294
445
  erb_case_match_node->end_node = end_node;
@@ -296,83 +447,99 @@ AST_ERB_CASE_MATCH_NODE_T* ast_erb_case_match_node_init(token_T* tag_opening, to
296
447
  return erb_case_match_node;
297
448
  }
298
449
 
299
- AST_ERB_WHILE_NODE_T* ast_erb_while_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors) {
300
- AST_ERB_WHILE_NODE_T* erb_while_node = malloc(sizeof(AST_ERB_WHILE_NODE_T));
450
+ AST_ERB_WHILE_NODE_T* ast_erb_while_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, herb_prism_node_T prism_node, hb_array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
451
+ AST_ERB_WHILE_NODE_T* erb_while_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_WHILE_NODE_T));
452
+
453
+ if (!erb_while_node) { return NULL; }
301
454
 
302
- ast_node_init(&erb_while_node->base, AST_ERB_WHILE_NODE, start_position, end_position, errors);
455
+ ast_node_init(&erb_while_node->base, AST_ERB_WHILE_NODE, start_position, end_position, errors, allocator);
303
456
 
304
- erb_while_node->tag_opening = token_copy(tag_opening);
305
- erb_while_node->content = token_copy(content);
306
- erb_while_node->tag_closing = token_copy(tag_closing);
457
+ erb_while_node->tag_opening = token_copy(tag_opening, allocator);
458
+ erb_while_node->content = token_copy(content, allocator);
459
+ erb_while_node->tag_closing = token_copy(tag_closing, allocator);
460
+ erb_while_node->prism_node = prism_node;
307
461
  erb_while_node->statements = statements;
308
462
  erb_while_node->end_node = end_node;
309
463
 
310
464
  return erb_while_node;
311
465
  }
312
466
 
313
- AST_ERB_UNTIL_NODE_T* ast_erb_until_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors) {
314
- AST_ERB_UNTIL_NODE_T* erb_until_node = malloc(sizeof(AST_ERB_UNTIL_NODE_T));
467
+ AST_ERB_UNTIL_NODE_T* ast_erb_until_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, herb_prism_node_T prism_node, hb_array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
468
+ AST_ERB_UNTIL_NODE_T* erb_until_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_UNTIL_NODE_T));
469
+
470
+ if (!erb_until_node) { return NULL; }
315
471
 
316
- ast_node_init(&erb_until_node->base, AST_ERB_UNTIL_NODE, start_position, end_position, errors);
472
+ ast_node_init(&erb_until_node->base, AST_ERB_UNTIL_NODE, start_position, end_position, errors, allocator);
317
473
 
318
- erb_until_node->tag_opening = token_copy(tag_opening);
319
- erb_until_node->content = token_copy(content);
320
- erb_until_node->tag_closing = token_copy(tag_closing);
474
+ erb_until_node->tag_opening = token_copy(tag_opening, allocator);
475
+ erb_until_node->content = token_copy(content, allocator);
476
+ erb_until_node->tag_closing = token_copy(tag_closing, allocator);
477
+ erb_until_node->prism_node = prism_node;
321
478
  erb_until_node->statements = statements;
322
479
  erb_until_node->end_node = end_node;
323
480
 
324
481
  return erb_until_node;
325
482
  }
326
483
 
327
- AST_ERB_FOR_NODE_T* ast_erb_for_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors) {
328
- AST_ERB_FOR_NODE_T* erb_for_node = malloc(sizeof(AST_ERB_FOR_NODE_T));
484
+ AST_ERB_FOR_NODE_T* ast_erb_for_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, herb_prism_node_T prism_node, hb_array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
485
+ AST_ERB_FOR_NODE_T* erb_for_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_FOR_NODE_T));
329
486
 
330
- ast_node_init(&erb_for_node->base, AST_ERB_FOR_NODE, start_position, end_position, errors);
487
+ if (!erb_for_node) { return NULL; }
331
488
 
332
- erb_for_node->tag_opening = token_copy(tag_opening);
333
- erb_for_node->content = token_copy(content);
334
- erb_for_node->tag_closing = token_copy(tag_closing);
489
+ ast_node_init(&erb_for_node->base, AST_ERB_FOR_NODE, start_position, end_position, errors, allocator);
490
+
491
+ erb_for_node->tag_opening = token_copy(tag_opening, allocator);
492
+ erb_for_node->content = token_copy(content, allocator);
493
+ erb_for_node->tag_closing = token_copy(tag_closing, allocator);
494
+ erb_for_node->prism_node = prism_node;
335
495
  erb_for_node->statements = statements;
336
496
  erb_for_node->end_node = end_node;
337
497
 
338
498
  return erb_for_node;
339
499
  }
340
500
 
341
- AST_ERB_RESCUE_NODE_T* ast_erb_rescue_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, struct AST_ERB_RESCUE_NODE_STRUCT* subsequent, position_T start_position, position_T end_position, hb_array_T* errors) {
342
- AST_ERB_RESCUE_NODE_T* erb_rescue_node = malloc(sizeof(AST_ERB_RESCUE_NODE_T));
501
+ AST_ERB_RESCUE_NODE_T* ast_erb_rescue_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, struct AST_ERB_RESCUE_NODE_STRUCT* subsequent, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
502
+ AST_ERB_RESCUE_NODE_T* erb_rescue_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_RESCUE_NODE_T));
503
+
504
+ if (!erb_rescue_node) { return NULL; }
343
505
 
344
- ast_node_init(&erb_rescue_node->base, AST_ERB_RESCUE_NODE, start_position, end_position, errors);
506
+ ast_node_init(&erb_rescue_node->base, AST_ERB_RESCUE_NODE, start_position, end_position, errors, allocator);
345
507
 
346
- erb_rescue_node->tag_opening = token_copy(tag_opening);
347
- erb_rescue_node->content = token_copy(content);
348
- erb_rescue_node->tag_closing = token_copy(tag_closing);
508
+ erb_rescue_node->tag_opening = token_copy(tag_opening, allocator);
509
+ erb_rescue_node->content = token_copy(content, allocator);
510
+ erb_rescue_node->tag_closing = token_copy(tag_closing, allocator);
349
511
  erb_rescue_node->statements = statements;
350
512
  erb_rescue_node->subsequent = subsequent;
351
513
 
352
514
  return erb_rescue_node;
353
515
  }
354
516
 
355
- AST_ERB_ENSURE_NODE_T* ast_erb_ensure_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) {
356
- AST_ERB_ENSURE_NODE_T* erb_ensure_node = malloc(sizeof(AST_ERB_ENSURE_NODE_T));
517
+ AST_ERB_ENSURE_NODE_T* ast_erb_ensure_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, hb_allocator_T* allocator) {
518
+ AST_ERB_ENSURE_NODE_T* erb_ensure_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_ENSURE_NODE_T));
519
+
520
+ if (!erb_ensure_node) { return NULL; }
357
521
 
358
- ast_node_init(&erb_ensure_node->base, AST_ERB_ENSURE_NODE, start_position, end_position, errors);
522
+ ast_node_init(&erb_ensure_node->base, AST_ERB_ENSURE_NODE, start_position, end_position, errors, allocator);
359
523
 
360
- erb_ensure_node->tag_opening = token_copy(tag_opening);
361
- erb_ensure_node->content = token_copy(content);
362
- erb_ensure_node->tag_closing = token_copy(tag_closing);
524
+ erb_ensure_node->tag_opening = token_copy(tag_opening, allocator);
525
+ erb_ensure_node->content = token_copy(content, allocator);
526
+ erb_ensure_node->tag_closing = token_copy(tag_closing, allocator);
363
527
  erb_ensure_node->statements = statements;
364
528
 
365
529
  return erb_ensure_node;
366
530
  }
367
531
 
368
- AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, struct AST_ERB_RESCUE_NODE_STRUCT* rescue_clause, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_ENSURE_NODE_STRUCT* ensure_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors) {
369
- AST_ERB_BEGIN_NODE_T* erb_begin_node = malloc(sizeof(AST_ERB_BEGIN_NODE_T));
532
+ AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, herb_prism_node_T prism_node, hb_array_T* statements, struct AST_ERB_RESCUE_NODE_STRUCT* rescue_clause, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_ENSURE_NODE_STRUCT* ensure_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
533
+ AST_ERB_BEGIN_NODE_T* erb_begin_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_BEGIN_NODE_T));
370
534
 
371
- ast_node_init(&erb_begin_node->base, AST_ERB_BEGIN_NODE, start_position, end_position, errors);
535
+ if (!erb_begin_node) { return NULL; }
372
536
 
373
- erb_begin_node->tag_opening = token_copy(tag_opening);
374
- erb_begin_node->content = token_copy(content);
375
- erb_begin_node->tag_closing = token_copy(tag_closing);
537
+ ast_node_init(&erb_begin_node->base, AST_ERB_BEGIN_NODE, start_position, end_position, errors, allocator);
538
+
539
+ erb_begin_node->tag_opening = token_copy(tag_opening, allocator);
540
+ erb_begin_node->content = token_copy(content, allocator);
541
+ erb_begin_node->tag_closing = token_copy(tag_closing, allocator);
542
+ erb_begin_node->prism_node = prism_node;
376
543
  erb_begin_node->statements = statements;
377
544
  erb_begin_node->rescue_clause = rescue_clause;
378
545
  erb_begin_node->else_clause = else_clause;
@@ -382,15 +549,18 @@ AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* con
382
549
  return erb_begin_node;
383
550
  }
384
551
 
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) {
386
- AST_ERB_UNLESS_NODE_T* erb_unless_node = malloc(sizeof(AST_ERB_UNLESS_NODE_T));
552
+ 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, herb_prism_node_T prism_node, 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, hb_allocator_T* allocator) {
553
+ AST_ERB_UNLESS_NODE_T* erb_unless_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_UNLESS_NODE_T));
554
+
555
+ if (!erb_unless_node) { return NULL; }
387
556
 
388
- ast_node_init(&erb_unless_node->base, AST_ERB_UNLESS_NODE, start_position, end_position, errors);
557
+ ast_node_init(&erb_unless_node->base, AST_ERB_UNLESS_NODE, start_position, end_position, errors, allocator);
389
558
 
390
- erb_unless_node->tag_opening = token_copy(tag_opening);
391
- erb_unless_node->content = token_copy(content);
392
- erb_unless_node->tag_closing = token_copy(tag_closing);
559
+ erb_unless_node->tag_opening = token_copy(tag_opening, allocator);
560
+ erb_unless_node->content = token_copy(content, allocator);
561
+ erb_unless_node->tag_closing = token_copy(tag_closing, allocator);
393
562
  erb_unless_node->then_keyword = then_keyword;
563
+ erb_unless_node->prism_node = prism_node;
394
564
  erb_unless_node->statements = statements;
395
565
  erb_unless_node->else_clause = else_clause;
396
566
  erb_unless_node->end_node = end_node;
@@ -398,26 +568,30 @@ AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* c
398
568
  return erb_unless_node;
399
569
  }
400
570
 
401
- AST_ERB_YIELD_NODE_T* ast_erb_yield_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors) {
402
- AST_ERB_YIELD_NODE_T* erb_yield_node = malloc(sizeof(AST_ERB_YIELD_NODE_T));
571
+ AST_ERB_YIELD_NODE_T* ast_erb_yield_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
572
+ AST_ERB_YIELD_NODE_T* erb_yield_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_YIELD_NODE_T));
573
+
574
+ if (!erb_yield_node) { return NULL; }
403
575
 
404
- ast_node_init(&erb_yield_node->base, AST_ERB_YIELD_NODE, start_position, end_position, errors);
576
+ ast_node_init(&erb_yield_node->base, AST_ERB_YIELD_NODE, start_position, end_position, errors, allocator);
405
577
 
406
- erb_yield_node->tag_opening = token_copy(tag_opening);
407
- erb_yield_node->content = token_copy(content);
408
- erb_yield_node->tag_closing = token_copy(tag_closing);
578
+ erb_yield_node->tag_opening = token_copy(tag_opening, allocator);
579
+ erb_yield_node->content = token_copy(content, allocator);
580
+ erb_yield_node->tag_closing = token_copy(tag_closing, allocator);
409
581
 
410
582
  return erb_yield_node;
411
583
  }
412
584
 
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) {
414
- AST_ERB_IN_NODE_T* erb_in_node = malloc(sizeof(AST_ERB_IN_NODE_T));
585
+ 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, hb_allocator_T* allocator) {
586
+ AST_ERB_IN_NODE_T* erb_in_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_IN_NODE_T));
415
587
 
416
- ast_node_init(&erb_in_node->base, AST_ERB_IN_NODE, start_position, end_position, errors);
588
+ if (!erb_in_node) { return NULL; }
417
589
 
418
- erb_in_node->tag_opening = token_copy(tag_opening);
419
- erb_in_node->content = token_copy(content);
420
- erb_in_node->tag_closing = token_copy(tag_closing);
590
+ ast_node_init(&erb_in_node->base, AST_ERB_IN_NODE, start_position, end_position, errors, allocator);
591
+
592
+ erb_in_node->tag_opening = token_copy(tag_opening, allocator);
593
+ erb_in_node->content = token_copy(content, allocator);
594
+ erb_in_node->tag_closing = token_copy(tag_closing, allocator);
421
595
  erb_in_node->then_keyword = then_keyword;
422
596
  erb_in_node->statements = statements;
423
597
 
@@ -429,11 +603,18 @@ hb_string_T ast_node_type_to_string(AST_NODE_T* node) {
429
603
  case AST_DOCUMENT_NODE: return hb_string("AST_DOCUMENT_NODE");
430
604
  case AST_LITERAL_NODE: return hb_string("AST_LITERAL_NODE");
431
605
  case AST_HTML_OPEN_TAG_NODE: return hb_string("AST_HTML_OPEN_TAG_NODE");
606
+ case AST_HTML_CONDITIONAL_OPEN_TAG_NODE: return hb_string("AST_HTML_CONDITIONAL_OPEN_TAG_NODE");
432
607
  case AST_HTML_CLOSE_TAG_NODE: return hb_string("AST_HTML_CLOSE_TAG_NODE");
608
+ case AST_HTML_OMITTED_CLOSE_TAG_NODE: return hb_string("AST_HTML_OMITTED_CLOSE_TAG_NODE");
609
+ case AST_HTML_VIRTUAL_CLOSE_TAG_NODE: return hb_string("AST_HTML_VIRTUAL_CLOSE_TAG_NODE");
433
610
  case AST_HTML_ELEMENT_NODE: return hb_string("AST_HTML_ELEMENT_NODE");
611
+ case AST_HTML_CONDITIONAL_ELEMENT_NODE: return hb_string("AST_HTML_CONDITIONAL_ELEMENT_NODE");
434
612
  case AST_HTML_ATTRIBUTE_VALUE_NODE: return hb_string("AST_HTML_ATTRIBUTE_VALUE_NODE");
435
613
  case AST_HTML_ATTRIBUTE_NAME_NODE: return hb_string("AST_HTML_ATTRIBUTE_NAME_NODE");
436
614
  case AST_HTML_ATTRIBUTE_NODE: return hb_string("AST_HTML_ATTRIBUTE_NODE");
615
+ case AST_RUBY_LITERAL_NODE: return hb_string("AST_RUBY_LITERAL_NODE");
616
+ case AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE: return hb_string("AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE");
617
+ case AST_ERB_OPEN_TAG_NODE: return hb_string("AST_ERB_OPEN_TAG_NODE");
437
618
  case AST_HTML_TEXT_NODE: return hb_string("AST_HTML_TEXT_NODE");
438
619
  case AST_HTML_COMMENT_NODE: return hb_string("AST_HTML_COMMENT_NODE");
439
620
  case AST_HTML_DOCTYPE_NODE: return hb_string("AST_HTML_DOCTYPE_NODE");
@@ -467,11 +648,18 @@ hb_string_T ast_node_human_type(AST_NODE_T* node) {
467
648
  case AST_DOCUMENT_NODE: return hb_string("DocumentNode");
468
649
  case AST_LITERAL_NODE: return hb_string("LiteralNode");
469
650
  case AST_HTML_OPEN_TAG_NODE: return hb_string("HTMLOpenTagNode");
651
+ case AST_HTML_CONDITIONAL_OPEN_TAG_NODE: return hb_string("HTMLConditionalOpenTagNode");
470
652
  case AST_HTML_CLOSE_TAG_NODE: return hb_string("HTMLCloseTagNode");
653
+ case AST_HTML_OMITTED_CLOSE_TAG_NODE: return hb_string("HTMLOmittedCloseTagNode");
654
+ case AST_HTML_VIRTUAL_CLOSE_TAG_NODE: return hb_string("HTMLVirtualCloseTagNode");
471
655
  case AST_HTML_ELEMENT_NODE: return hb_string("HTMLElementNode");
656
+ case AST_HTML_CONDITIONAL_ELEMENT_NODE: return hb_string("HTMLConditionalElementNode");
472
657
  case AST_HTML_ATTRIBUTE_VALUE_NODE: return hb_string("HTMLAttributeValueNode");
473
658
  case AST_HTML_ATTRIBUTE_NAME_NODE: return hb_string("HTMLAttributeNameNode");
474
659
  case AST_HTML_ATTRIBUTE_NODE: return hb_string("HTMLAttributeNode");
660
+ case AST_RUBY_LITERAL_NODE: return hb_string("RubyLiteralNode");
661
+ case AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE: return hb_string("RubyHTMLAttributesSplatNode");
662
+ case AST_ERB_OPEN_TAG_NODE: return hb_string("ERBOpenTagNode");
475
663
  case AST_HTML_TEXT_NODE: return hb_string("HTMLTextNode");
476
664
  case AST_HTML_COMMENT_NODE: return hb_string("HTMLCommentNode");
477
665
  case AST_HTML_DOCTYPE_NODE: return hb_string("HTMLDoctypeNode");
@@ -500,519 +688,606 @@ hb_string_T ast_node_human_type(AST_NODE_T* node) {
500
688
  return hb_string("Unknown ast_node_type_T");
501
689
  }
502
690
 
503
- void ast_free_base_node(AST_NODE_T* node) {
691
+ void ast_free_base_node(AST_NODE_T* node, hb_allocator_T* allocator) {
504
692
  if (node == NULL) { return; }
505
693
 
506
694
  if (node->errors) {
507
695
  for (size_t i = 0; i < hb_array_size(node->errors); i++) {
508
696
  ERROR_T* child = hb_array_get(node->errors, i);
509
- if (child != NULL) { error_free(child); }
697
+ if (child != NULL) { error_free(child, allocator); }
510
698
  }
511
699
 
512
700
  hb_array_free(&node->errors);
513
701
  }
514
702
 
515
- free(node);
703
+ hb_allocator_dealloc(allocator, node);
516
704
  }
517
705
 
518
706
 
519
- static void ast_free_document_node(AST_DOCUMENT_NODE_T* document_node) {
707
+ static void ast_free_document_node(AST_DOCUMENT_NODE_T* document_node, hb_allocator_T* allocator) {
520
708
  if (document_node->children != NULL) {
521
709
  for (size_t i = 0; i < hb_array_size(document_node->children); i++) {
522
710
  AST_NODE_T* child = hb_array_get(document_node->children, i);
523
- if (child) { ast_node_free(child); }
711
+ if (child) { ast_node_free(child, allocator); }
524
712
  }
525
713
 
526
714
  hb_array_free(&document_node->children);
527
715
  }
716
+ if (document_node->prism_context != NULL) { herb_prism_context_free(document_node->prism_context); }
717
+ /* prism_node is a borrowed reference into the prism context, not freed here */
528
718
 
529
- ast_free_base_node(&document_node->base);
719
+ ast_free_base_node(&document_node->base, allocator);
530
720
  }
531
721
 
532
- static void ast_free_literal_node(AST_LITERAL_NODE_T* literal_node) {
533
- if (literal_node->content != NULL) { free((char*) literal_node->content); }
722
+ static void ast_free_literal_node(AST_LITERAL_NODE_T* literal_node, hb_allocator_T* allocator) {
723
+ if (literal_node->content.data != NULL) { hb_allocator_dealloc(allocator, literal_node->content.data); }
534
724
 
535
- ast_free_base_node(&literal_node->base);
725
+ ast_free_base_node(&literal_node->base, allocator);
536
726
  }
537
727
 
538
- static void ast_free_html_open_tag_node(AST_HTML_OPEN_TAG_NODE_T* html_open_tag_node) {
539
- if (html_open_tag_node->tag_opening != NULL) { token_free(html_open_tag_node->tag_opening); }
540
- if (html_open_tag_node->tag_name != NULL) { token_free(html_open_tag_node->tag_name); }
541
- if (html_open_tag_node->tag_closing != NULL) { token_free(html_open_tag_node->tag_closing); }
728
+ static void ast_free_html_open_tag_node(AST_HTML_OPEN_TAG_NODE_T* html_open_tag_node, hb_allocator_T* allocator) {
729
+ if (html_open_tag_node->tag_opening != NULL) { token_free(html_open_tag_node->tag_opening, allocator); }
730
+ if (html_open_tag_node->tag_name != NULL) { token_free(html_open_tag_node->tag_name, allocator); }
731
+ if (html_open_tag_node->tag_closing != NULL) { token_free(html_open_tag_node->tag_closing, allocator); }
542
732
  if (html_open_tag_node->children != NULL) {
543
733
  for (size_t i = 0; i < hb_array_size(html_open_tag_node->children); i++) {
544
734
  AST_NODE_T* child = hb_array_get(html_open_tag_node->children, i);
545
- if (child) { ast_node_free(child); }
735
+ if (child) { ast_node_free(child, allocator); }
546
736
  }
547
737
 
548
738
  hb_array_free(&html_open_tag_node->children);
549
739
  }
550
740
 
551
- ast_free_base_node(&html_open_tag_node->base);
741
+ ast_free_base_node(&html_open_tag_node->base, allocator);
742
+ }
743
+
744
+ static void ast_free_html_conditional_open_tag_node(AST_HTML_CONDITIONAL_OPEN_TAG_NODE_T* html_conditional_open_tag_node, hb_allocator_T* allocator) {
745
+ ast_node_free((AST_NODE_T*) html_conditional_open_tag_node->conditional, allocator);
746
+ if (html_conditional_open_tag_node->tag_name != NULL) { token_free(html_conditional_open_tag_node->tag_name, allocator); }
747
+
748
+ ast_free_base_node(&html_conditional_open_tag_node->base, allocator);
552
749
  }
553
750
 
554
- static void ast_free_html_close_tag_node(AST_HTML_CLOSE_TAG_NODE_T* html_close_tag_node) {
555
- if (html_close_tag_node->tag_opening != NULL) { token_free(html_close_tag_node->tag_opening); }
556
- if (html_close_tag_node->tag_name != NULL) { token_free(html_close_tag_node->tag_name); }
751
+ static void ast_free_html_close_tag_node(AST_HTML_CLOSE_TAG_NODE_T* html_close_tag_node, hb_allocator_T* allocator) {
752
+ if (html_close_tag_node->tag_opening != NULL) { token_free(html_close_tag_node->tag_opening, allocator); }
753
+ if (html_close_tag_node->tag_name != NULL) { token_free(html_close_tag_node->tag_name, allocator); }
557
754
  if (html_close_tag_node->children != NULL) {
558
755
  for (size_t i = 0; i < hb_array_size(html_close_tag_node->children); i++) {
559
756
  AST_NODE_T* child = hb_array_get(html_close_tag_node->children, i);
560
- if (child) { ast_node_free(child); }
757
+ if (child) { ast_node_free(child, allocator); }
561
758
  }
562
759
 
563
760
  hb_array_free(&html_close_tag_node->children);
564
761
  }
565
- if (html_close_tag_node->tag_closing != NULL) { token_free(html_close_tag_node->tag_closing); }
762
+ if (html_close_tag_node->tag_closing != NULL) { token_free(html_close_tag_node->tag_closing, allocator); }
763
+
764
+ ast_free_base_node(&html_close_tag_node->base, allocator);
765
+ }
766
+
767
+ static void ast_free_html_omitted_close_tag_node(AST_HTML_OMITTED_CLOSE_TAG_NODE_T* html_omitted_close_tag_node, hb_allocator_T* allocator) {
768
+ if (html_omitted_close_tag_node->tag_name != NULL) { token_free(html_omitted_close_tag_node->tag_name, allocator); }
769
+
770
+ ast_free_base_node(&html_omitted_close_tag_node->base, allocator);
771
+ }
772
+
773
+ static void ast_free_html_virtual_close_tag_node(AST_HTML_VIRTUAL_CLOSE_TAG_NODE_T* html_virtual_close_tag_node, hb_allocator_T* allocator) {
774
+ if (html_virtual_close_tag_node->tag_name != NULL) { token_free(html_virtual_close_tag_node->tag_name, allocator); }
566
775
 
567
- ast_free_base_node(&html_close_tag_node->base);
776
+ ast_free_base_node(&html_virtual_close_tag_node->base, allocator);
568
777
  }
569
778
 
570
- static void ast_free_html_element_node(AST_HTML_ELEMENT_NODE_T* html_element_node) {
571
- ast_node_free((AST_NODE_T*) html_element_node->open_tag);
572
- if (html_element_node->tag_name != NULL) { token_free(html_element_node->tag_name); }
779
+ static void ast_free_html_element_node(AST_HTML_ELEMENT_NODE_T* html_element_node, hb_allocator_T* allocator) {
780
+ ast_node_free((AST_NODE_T*) html_element_node->open_tag, allocator);
781
+ if (html_element_node->tag_name != NULL) { token_free(html_element_node->tag_name, allocator); }
573
782
  if (html_element_node->body != NULL) {
574
783
  for (size_t i = 0; i < hb_array_size(html_element_node->body); i++) {
575
784
  AST_NODE_T* child = hb_array_get(html_element_node->body, i);
576
- if (child) { ast_node_free(child); }
785
+ if (child) { ast_node_free(child, allocator); }
577
786
  }
578
787
 
579
788
  hb_array_free(&html_element_node->body);
580
789
  }
581
- ast_node_free((AST_NODE_T*) html_element_node->close_tag);
790
+ ast_node_free((AST_NODE_T*) html_element_node->close_tag, allocator);
791
+
792
+ ast_free_base_node(&html_element_node->base, allocator);
793
+ }
794
+
795
+ static void ast_free_html_conditional_element_node(AST_HTML_CONDITIONAL_ELEMENT_NODE_T* html_conditional_element_node, hb_allocator_T* allocator) {
796
+ if (html_conditional_element_node->condition.data != NULL) { hb_allocator_dealloc(allocator, html_conditional_element_node->condition.data); }
797
+ ast_node_free((AST_NODE_T*) html_conditional_element_node->open_conditional, allocator);
798
+ /* open_tag is a borrowed reference, not freed here (owned by another field) */
799
+ if (html_conditional_element_node->body != NULL) {
800
+ for (size_t i = 0; i < hb_array_size(html_conditional_element_node->body); i++) {
801
+ AST_NODE_T* child = hb_array_get(html_conditional_element_node->body, i);
802
+ if (child) { ast_node_free(child, allocator); }
803
+ }
804
+
805
+ hb_array_free(&html_conditional_element_node->body);
806
+ }
807
+ /* close_tag is a borrowed reference, not freed here (owned by another field) */
808
+ ast_node_free((AST_NODE_T*) html_conditional_element_node->close_conditional, allocator);
809
+ if (html_conditional_element_node->tag_name != NULL) { token_free(html_conditional_element_node->tag_name, allocator); }
582
810
 
583
- ast_free_base_node(&html_element_node->base);
811
+ ast_free_base_node(&html_conditional_element_node->base, allocator);
584
812
  }
585
813
 
586
- static void ast_free_html_attribute_value_node(AST_HTML_ATTRIBUTE_VALUE_NODE_T* html_attribute_value_node) {
587
- if (html_attribute_value_node->open_quote != NULL) { token_free(html_attribute_value_node->open_quote); }
814
+ static void ast_free_html_attribute_value_node(AST_HTML_ATTRIBUTE_VALUE_NODE_T* html_attribute_value_node, hb_allocator_T* allocator) {
815
+ if (html_attribute_value_node->open_quote != NULL) { token_free(html_attribute_value_node->open_quote, allocator); }
588
816
  if (html_attribute_value_node->children != NULL) {
589
817
  for (size_t i = 0; i < hb_array_size(html_attribute_value_node->children); i++) {
590
818
  AST_NODE_T* child = hb_array_get(html_attribute_value_node->children, i);
591
- if (child) { ast_node_free(child); }
819
+ if (child) { ast_node_free(child, allocator); }
592
820
  }
593
821
 
594
822
  hb_array_free(&html_attribute_value_node->children);
595
823
  }
596
- if (html_attribute_value_node->close_quote != NULL) { token_free(html_attribute_value_node->close_quote); }
824
+ if (html_attribute_value_node->close_quote != NULL) { token_free(html_attribute_value_node->close_quote, allocator); }
597
825
 
598
- ast_free_base_node(&html_attribute_value_node->base);
826
+ ast_free_base_node(&html_attribute_value_node->base, allocator);
599
827
  }
600
828
 
601
- static void ast_free_html_attribute_name_node(AST_HTML_ATTRIBUTE_NAME_NODE_T* html_attribute_name_node) {
829
+ static void ast_free_html_attribute_name_node(AST_HTML_ATTRIBUTE_NAME_NODE_T* html_attribute_name_node, hb_allocator_T* allocator) {
602
830
  if (html_attribute_name_node->children != NULL) {
603
831
  for (size_t i = 0; i < hb_array_size(html_attribute_name_node->children); i++) {
604
832
  AST_NODE_T* child = hb_array_get(html_attribute_name_node->children, i);
605
- if (child) { ast_node_free(child); }
833
+ if (child) { ast_node_free(child, allocator); }
606
834
  }
607
835
 
608
836
  hb_array_free(&html_attribute_name_node->children);
609
837
  }
610
838
 
611
- ast_free_base_node(&html_attribute_name_node->base);
839
+ ast_free_base_node(&html_attribute_name_node->base, allocator);
612
840
  }
613
841
 
614
- static void ast_free_html_attribute_node(AST_HTML_ATTRIBUTE_NODE_T* html_attribute_node) {
615
- ast_node_free((AST_NODE_T*) html_attribute_node->name);
616
- if (html_attribute_node->equals != NULL) { token_free(html_attribute_node->equals); }
617
- ast_node_free((AST_NODE_T*) html_attribute_node->value);
842
+ static void ast_free_html_attribute_node(AST_HTML_ATTRIBUTE_NODE_T* html_attribute_node, hb_allocator_T* allocator) {
843
+ ast_node_free((AST_NODE_T*) html_attribute_node->name, allocator);
844
+ if (html_attribute_node->equals != NULL) { token_free(html_attribute_node->equals, allocator); }
845
+ ast_node_free((AST_NODE_T*) html_attribute_node->value, allocator);
846
+
847
+ ast_free_base_node(&html_attribute_node->base, allocator);
848
+ }
849
+
850
+ static void ast_free_ruby_literal_node(AST_RUBY_LITERAL_NODE_T* ruby_literal_node, hb_allocator_T* allocator) {
851
+ if (ruby_literal_node->content.data != NULL) { hb_allocator_dealloc(allocator, ruby_literal_node->content.data); }
852
+
853
+ ast_free_base_node(&ruby_literal_node->base, allocator);
854
+ }
855
+
856
+ static void ast_free_ruby_html_attributes_splat_node(AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE_T* ruby_html_attributes_splat_node, hb_allocator_T* allocator) {
857
+ if (ruby_html_attributes_splat_node->content.data != NULL) { hb_allocator_dealloc(allocator, ruby_html_attributes_splat_node->content.data); }
858
+ if (ruby_html_attributes_splat_node->prefix.data != NULL) { hb_allocator_dealloc(allocator, ruby_html_attributes_splat_node->prefix.data); }
859
+
860
+ ast_free_base_node(&ruby_html_attributes_splat_node->base, allocator);
861
+ }
862
+
863
+ static void ast_free_erb_open_tag_node(AST_ERB_OPEN_TAG_NODE_T* erb_open_tag_node, hb_allocator_T* allocator) {
864
+ if (erb_open_tag_node->tag_opening != NULL) { token_free(erb_open_tag_node->tag_opening, allocator); }
865
+ if (erb_open_tag_node->content != NULL) { token_free(erb_open_tag_node->content, allocator); }
866
+ if (erb_open_tag_node->tag_closing != NULL) { token_free(erb_open_tag_node->tag_closing, allocator); }
867
+ if (erb_open_tag_node->tag_name != NULL) { token_free(erb_open_tag_node->tag_name, allocator); }
868
+ if (erb_open_tag_node->children != NULL) {
869
+ for (size_t i = 0; i < hb_array_size(erb_open_tag_node->children); i++) {
870
+ AST_NODE_T* child = hb_array_get(erb_open_tag_node->children, i);
871
+ if (child) { ast_node_free(child, allocator); }
872
+ }
873
+
874
+ hb_array_free(&erb_open_tag_node->children);
875
+ }
618
876
 
619
- ast_free_base_node(&html_attribute_node->base);
877
+ ast_free_base_node(&erb_open_tag_node->base, allocator);
620
878
  }
621
879
 
622
- static void ast_free_html_text_node(AST_HTML_TEXT_NODE_T* html_text_node) {
623
- if (html_text_node->content != NULL) { free((char*) html_text_node->content); }
880
+ static void ast_free_html_text_node(AST_HTML_TEXT_NODE_T* html_text_node, hb_allocator_T* allocator) {
881
+ if (html_text_node->content.data != NULL) { hb_allocator_dealloc(allocator, html_text_node->content.data); }
624
882
 
625
- ast_free_base_node(&html_text_node->base);
883
+ ast_free_base_node(&html_text_node->base, allocator);
626
884
  }
627
885
 
628
- static void ast_free_html_comment_node(AST_HTML_COMMENT_NODE_T* html_comment_node) {
629
- if (html_comment_node->comment_start != NULL) { token_free(html_comment_node->comment_start); }
886
+ static void ast_free_html_comment_node(AST_HTML_COMMENT_NODE_T* html_comment_node, hb_allocator_T* allocator) {
887
+ if (html_comment_node->comment_start != NULL) { token_free(html_comment_node->comment_start, allocator); }
630
888
  if (html_comment_node->children != NULL) {
631
889
  for (size_t i = 0; i < hb_array_size(html_comment_node->children); i++) {
632
890
  AST_NODE_T* child = hb_array_get(html_comment_node->children, i);
633
- if (child) { ast_node_free(child); }
891
+ if (child) { ast_node_free(child, allocator); }
634
892
  }
635
893
 
636
894
  hb_array_free(&html_comment_node->children);
637
895
  }
638
- if (html_comment_node->comment_end != NULL) { token_free(html_comment_node->comment_end); }
896
+ if (html_comment_node->comment_end != NULL) { token_free(html_comment_node->comment_end, allocator); }
639
897
 
640
- ast_free_base_node(&html_comment_node->base);
898
+ ast_free_base_node(&html_comment_node->base, allocator);
641
899
  }
642
900
 
643
- static void ast_free_html_doctype_node(AST_HTML_DOCTYPE_NODE_T* html_doctype_node) {
644
- if (html_doctype_node->tag_opening != NULL) { token_free(html_doctype_node->tag_opening); }
901
+ static void ast_free_html_doctype_node(AST_HTML_DOCTYPE_NODE_T* html_doctype_node, hb_allocator_T* allocator) {
902
+ if (html_doctype_node->tag_opening != NULL) { token_free(html_doctype_node->tag_opening, allocator); }
645
903
  if (html_doctype_node->children != NULL) {
646
904
  for (size_t i = 0; i < hb_array_size(html_doctype_node->children); i++) {
647
905
  AST_NODE_T* child = hb_array_get(html_doctype_node->children, i);
648
- if (child) { ast_node_free(child); }
906
+ if (child) { ast_node_free(child, allocator); }
649
907
  }
650
908
 
651
909
  hb_array_free(&html_doctype_node->children);
652
910
  }
653
- if (html_doctype_node->tag_closing != NULL) { token_free(html_doctype_node->tag_closing); }
911
+ if (html_doctype_node->tag_closing != NULL) { token_free(html_doctype_node->tag_closing, allocator); }
654
912
 
655
- ast_free_base_node(&html_doctype_node->base);
913
+ ast_free_base_node(&html_doctype_node->base, allocator);
656
914
  }
657
915
 
658
- static void ast_free_xml_declaration_node(AST_XML_DECLARATION_NODE_T* xml_declaration_node) {
659
- if (xml_declaration_node->tag_opening != NULL) { token_free(xml_declaration_node->tag_opening); }
916
+ static void ast_free_xml_declaration_node(AST_XML_DECLARATION_NODE_T* xml_declaration_node, hb_allocator_T* allocator) {
917
+ if (xml_declaration_node->tag_opening != NULL) { token_free(xml_declaration_node->tag_opening, allocator); }
660
918
  if (xml_declaration_node->children != NULL) {
661
919
  for (size_t i = 0; i < hb_array_size(xml_declaration_node->children); i++) {
662
920
  AST_NODE_T* child = hb_array_get(xml_declaration_node->children, i);
663
- if (child) { ast_node_free(child); }
921
+ if (child) { ast_node_free(child, allocator); }
664
922
  }
665
923
 
666
924
  hb_array_free(&xml_declaration_node->children);
667
925
  }
668
- if (xml_declaration_node->tag_closing != NULL) { token_free(xml_declaration_node->tag_closing); }
926
+ if (xml_declaration_node->tag_closing != NULL) { token_free(xml_declaration_node->tag_closing, allocator); }
669
927
 
670
- ast_free_base_node(&xml_declaration_node->base);
928
+ ast_free_base_node(&xml_declaration_node->base, allocator);
671
929
  }
672
930
 
673
- static void ast_free_cdata_node(AST_CDATA_NODE_T* cdata_node) {
674
- if (cdata_node->tag_opening != NULL) { token_free(cdata_node->tag_opening); }
931
+ static void ast_free_cdata_node(AST_CDATA_NODE_T* cdata_node, hb_allocator_T* allocator) {
932
+ if (cdata_node->tag_opening != NULL) { token_free(cdata_node->tag_opening, allocator); }
675
933
  if (cdata_node->children != NULL) {
676
934
  for (size_t i = 0; i < hb_array_size(cdata_node->children); i++) {
677
935
  AST_NODE_T* child = hb_array_get(cdata_node->children, i);
678
- if (child) { ast_node_free(child); }
936
+ if (child) { ast_node_free(child, allocator); }
679
937
  }
680
938
 
681
939
  hb_array_free(&cdata_node->children);
682
940
  }
683
- if (cdata_node->tag_closing != NULL) { token_free(cdata_node->tag_closing); }
941
+ if (cdata_node->tag_closing != NULL) { token_free(cdata_node->tag_closing, allocator); }
684
942
 
685
- ast_free_base_node(&cdata_node->base);
943
+ ast_free_base_node(&cdata_node->base, allocator);
686
944
  }
687
945
 
688
- static void ast_free_whitespace_node(AST_WHITESPACE_NODE_T* whitespace_node) {
689
- if (whitespace_node->value != NULL) { token_free(whitespace_node->value); }
946
+ static void ast_free_whitespace_node(AST_WHITESPACE_NODE_T* whitespace_node, hb_allocator_T* allocator) {
947
+ if (whitespace_node->value != NULL) { token_free(whitespace_node->value, allocator); }
690
948
 
691
- ast_free_base_node(&whitespace_node->base);
949
+ ast_free_base_node(&whitespace_node->base, allocator);
692
950
  }
693
951
 
694
- static void ast_free_erb_content_node(AST_ERB_CONTENT_NODE_T* erb_content_node) {
695
- if (erb_content_node->tag_opening != NULL) { token_free(erb_content_node->tag_opening); }
696
- if (erb_content_node->content != NULL) { token_free(erb_content_node->content); }
697
- if (erb_content_node->tag_closing != NULL) { token_free(erb_content_node->tag_closing); }
952
+ static void ast_free_erb_content_node(AST_ERB_CONTENT_NODE_T* erb_content_node, hb_allocator_T* allocator) {
953
+ if (erb_content_node->tag_opening != NULL) { token_free(erb_content_node->tag_opening, allocator); }
954
+ if (erb_content_node->content != NULL) { token_free(erb_content_node->content, allocator); }
955
+ if (erb_content_node->tag_closing != NULL) { token_free(erb_content_node->tag_closing, allocator); }
698
956
  if (erb_content_node->analyzed_ruby != NULL) {
699
957
  free_analyzed_ruby(erb_content_node->analyzed_ruby);
700
958
  }
959
+ /* prism_node is a borrowed reference into the prism context, not freed here */
701
960
 
702
- ast_free_base_node(&erb_content_node->base);
961
+ ast_free_base_node(&erb_content_node->base, allocator);
703
962
  }
704
963
 
705
- static void ast_free_erb_end_node(AST_ERB_END_NODE_T* erb_end_node) {
706
- if (erb_end_node->tag_opening != NULL) { token_free(erb_end_node->tag_opening); }
707
- if (erb_end_node->content != NULL) { token_free(erb_end_node->content); }
708
- if (erb_end_node->tag_closing != NULL) { token_free(erb_end_node->tag_closing); }
964
+ static void ast_free_erb_end_node(AST_ERB_END_NODE_T* erb_end_node, hb_allocator_T* allocator) {
965
+ if (erb_end_node->tag_opening != NULL) { token_free(erb_end_node->tag_opening, allocator); }
966
+ if (erb_end_node->content != NULL) { token_free(erb_end_node->content, allocator); }
967
+ if (erb_end_node->tag_closing != NULL) { token_free(erb_end_node->tag_closing, allocator); }
709
968
 
710
- ast_free_base_node(&erb_end_node->base);
969
+ ast_free_base_node(&erb_end_node->base, allocator);
711
970
  }
712
971
 
713
- static void ast_free_erb_else_node(AST_ERB_ELSE_NODE_T* erb_else_node) {
714
- if (erb_else_node->tag_opening != NULL) { token_free(erb_else_node->tag_opening); }
715
- if (erb_else_node->content != NULL) { token_free(erb_else_node->content); }
716
- if (erb_else_node->tag_closing != NULL) { token_free(erb_else_node->tag_closing); }
972
+ static void ast_free_erb_else_node(AST_ERB_ELSE_NODE_T* erb_else_node, hb_allocator_T* allocator) {
973
+ if (erb_else_node->tag_opening != NULL) { token_free(erb_else_node->tag_opening, allocator); }
974
+ if (erb_else_node->content != NULL) { token_free(erb_else_node->content, allocator); }
975
+ if (erb_else_node->tag_closing != NULL) { token_free(erb_else_node->tag_closing, allocator); }
717
976
  if (erb_else_node->statements != NULL) {
718
977
  for (size_t i = 0; i < hb_array_size(erb_else_node->statements); i++) {
719
978
  AST_NODE_T* child = hb_array_get(erb_else_node->statements, i);
720
- if (child) { ast_node_free(child); }
979
+ if (child) { ast_node_free(child, allocator); }
721
980
  }
722
981
 
723
982
  hb_array_free(&erb_else_node->statements);
724
983
  }
725
984
 
726
- ast_free_base_node(&erb_else_node->base);
985
+ ast_free_base_node(&erb_else_node->base, allocator);
727
986
  }
728
987
 
729
- static void ast_free_erb_if_node(AST_ERB_IF_NODE_T* erb_if_node) {
730
- if (erb_if_node->tag_opening != NULL) { token_free(erb_if_node->tag_opening); }
731
- if (erb_if_node->content != NULL) { token_free(erb_if_node->content); }
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); }
988
+ static void ast_free_erb_if_node(AST_ERB_IF_NODE_T* erb_if_node, hb_allocator_T* allocator) {
989
+ if (erb_if_node->tag_opening != NULL) { token_free(erb_if_node->tag_opening, allocator); }
990
+ if (erb_if_node->content != NULL) { token_free(erb_if_node->content, allocator); }
991
+ if (erb_if_node->tag_closing != NULL) { token_free(erb_if_node->tag_closing, allocator); }
992
+ if (erb_if_node->then_keyword != NULL) { hb_allocator_dealloc(allocator, erb_if_node->then_keyword); }
993
+ /* prism_node is a borrowed reference into the prism context, not freed here */
734
994
  if (erb_if_node->statements != NULL) {
735
995
  for (size_t i = 0; i < hb_array_size(erb_if_node->statements); i++) {
736
996
  AST_NODE_T* child = hb_array_get(erb_if_node->statements, i);
737
- if (child) { ast_node_free(child); }
997
+ if (child) { ast_node_free(child, allocator); }
738
998
  }
739
999
 
740
1000
  hb_array_free(&erb_if_node->statements);
741
1001
  }
742
- ast_node_free((AST_NODE_T*) erb_if_node->subsequent);
743
- ast_node_free((AST_NODE_T*) erb_if_node->end_node);
1002
+ ast_node_free((AST_NODE_T*) erb_if_node->subsequent, allocator);
1003
+ ast_node_free((AST_NODE_T*) erb_if_node->end_node, allocator);
744
1004
 
745
- ast_free_base_node(&erb_if_node->base);
1005
+ ast_free_base_node(&erb_if_node->base, allocator);
746
1006
  }
747
1007
 
748
- static void ast_free_erb_block_node(AST_ERB_BLOCK_NODE_T* erb_block_node) {
749
- if (erb_block_node->tag_opening != NULL) { token_free(erb_block_node->tag_opening); }
750
- if (erb_block_node->content != NULL) { token_free(erb_block_node->content); }
751
- if (erb_block_node->tag_closing != NULL) { token_free(erb_block_node->tag_closing); }
1008
+ static void ast_free_erb_block_node(AST_ERB_BLOCK_NODE_T* erb_block_node, hb_allocator_T* allocator) {
1009
+ if (erb_block_node->tag_opening != NULL) { token_free(erb_block_node->tag_opening, allocator); }
1010
+ if (erb_block_node->content != NULL) { token_free(erb_block_node->content, allocator); }
1011
+ if (erb_block_node->tag_closing != NULL) { token_free(erb_block_node->tag_closing, allocator); }
1012
+ /* prism_node is a borrowed reference into the prism context, not freed here */
752
1013
  if (erb_block_node->body != NULL) {
753
1014
  for (size_t i = 0; i < hb_array_size(erb_block_node->body); i++) {
754
1015
  AST_NODE_T* child = hb_array_get(erb_block_node->body, i);
755
- if (child) { ast_node_free(child); }
1016
+ if (child) { ast_node_free(child, allocator); }
756
1017
  }
757
1018
 
758
1019
  hb_array_free(&erb_block_node->body);
759
1020
  }
760
- ast_node_free((AST_NODE_T*) erb_block_node->end_node);
1021
+ ast_node_free((AST_NODE_T*) erb_block_node->end_node, allocator);
761
1022
 
762
- ast_free_base_node(&erb_block_node->base);
1023
+ ast_free_base_node(&erb_block_node->base, allocator);
763
1024
  }
764
1025
 
765
- static void ast_free_erb_when_node(AST_ERB_WHEN_NODE_T* erb_when_node) {
766
- if (erb_when_node->tag_opening != NULL) { token_free(erb_when_node->tag_opening); }
767
- if (erb_when_node->content != NULL) { token_free(erb_when_node->content); }
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); }
1026
+ static void ast_free_erb_when_node(AST_ERB_WHEN_NODE_T* erb_when_node, hb_allocator_T* allocator) {
1027
+ if (erb_when_node->tag_opening != NULL) { token_free(erb_when_node->tag_opening, allocator); }
1028
+ if (erb_when_node->content != NULL) { token_free(erb_when_node->content, allocator); }
1029
+ if (erb_when_node->tag_closing != NULL) { token_free(erb_when_node->tag_closing, allocator); }
1030
+ if (erb_when_node->then_keyword != NULL) { hb_allocator_dealloc(allocator, erb_when_node->then_keyword); }
770
1031
  if (erb_when_node->statements != NULL) {
771
1032
  for (size_t i = 0; i < hb_array_size(erb_when_node->statements); i++) {
772
1033
  AST_NODE_T* child = hb_array_get(erb_when_node->statements, i);
773
- if (child) { ast_node_free(child); }
1034
+ if (child) { ast_node_free(child, allocator); }
774
1035
  }
775
1036
 
776
1037
  hb_array_free(&erb_when_node->statements);
777
1038
  }
778
1039
 
779
- ast_free_base_node(&erb_when_node->base);
1040
+ ast_free_base_node(&erb_when_node->base, allocator);
780
1041
  }
781
1042
 
782
- static void ast_free_erb_case_node(AST_ERB_CASE_NODE_T* erb_case_node) {
783
- if (erb_case_node->tag_opening != NULL) { token_free(erb_case_node->tag_opening); }
784
- if (erb_case_node->content != NULL) { token_free(erb_case_node->content); }
785
- if (erb_case_node->tag_closing != NULL) { token_free(erb_case_node->tag_closing); }
1043
+ static void ast_free_erb_case_node(AST_ERB_CASE_NODE_T* erb_case_node, hb_allocator_T* allocator) {
1044
+ if (erb_case_node->tag_opening != NULL) { token_free(erb_case_node->tag_opening, allocator); }
1045
+ if (erb_case_node->content != NULL) { token_free(erb_case_node->content, allocator); }
1046
+ if (erb_case_node->tag_closing != NULL) { token_free(erb_case_node->tag_closing, allocator); }
786
1047
  if (erb_case_node->children != NULL) {
787
1048
  for (size_t i = 0; i < hb_array_size(erb_case_node->children); i++) {
788
1049
  AST_NODE_T* child = hb_array_get(erb_case_node->children, i);
789
- if (child) { ast_node_free(child); }
1050
+ if (child) { ast_node_free(child, allocator); }
790
1051
  }
791
1052
 
792
1053
  hb_array_free(&erb_case_node->children);
793
1054
  }
1055
+ /* prism_node is a borrowed reference into the prism context, not freed here */
794
1056
  if (erb_case_node->conditions != NULL) {
795
1057
  for (size_t i = 0; i < hb_array_size(erb_case_node->conditions); i++) {
796
1058
  AST_NODE_T* child = hb_array_get(erb_case_node->conditions, i);
797
- if (child) { ast_node_free(child); }
1059
+ if (child) { ast_node_free(child, allocator); }
798
1060
  }
799
1061
 
800
1062
  hb_array_free(&erb_case_node->conditions);
801
1063
  }
802
- ast_node_free((AST_NODE_T*) erb_case_node->else_clause);
803
- ast_node_free((AST_NODE_T*) erb_case_node->end_node);
1064
+ ast_node_free((AST_NODE_T*) erb_case_node->else_clause, allocator);
1065
+ ast_node_free((AST_NODE_T*) erb_case_node->end_node, allocator);
804
1066
 
805
- ast_free_base_node(&erb_case_node->base);
1067
+ ast_free_base_node(&erb_case_node->base, allocator);
806
1068
  }
807
1069
 
808
- static void ast_free_erb_case_match_node(AST_ERB_CASE_MATCH_NODE_T* erb_case_match_node) {
809
- if (erb_case_match_node->tag_opening != NULL) { token_free(erb_case_match_node->tag_opening); }
810
- if (erb_case_match_node->content != NULL) { token_free(erb_case_match_node->content); }
811
- if (erb_case_match_node->tag_closing != NULL) { token_free(erb_case_match_node->tag_closing); }
1070
+ static void ast_free_erb_case_match_node(AST_ERB_CASE_MATCH_NODE_T* erb_case_match_node, hb_allocator_T* allocator) {
1071
+ if (erb_case_match_node->tag_opening != NULL) { token_free(erb_case_match_node->tag_opening, allocator); }
1072
+ if (erb_case_match_node->content != NULL) { token_free(erb_case_match_node->content, allocator); }
1073
+ if (erb_case_match_node->tag_closing != NULL) { token_free(erb_case_match_node->tag_closing, allocator); }
812
1074
  if (erb_case_match_node->children != NULL) {
813
1075
  for (size_t i = 0; i < hb_array_size(erb_case_match_node->children); i++) {
814
1076
  AST_NODE_T* child = hb_array_get(erb_case_match_node->children, i);
815
- if (child) { ast_node_free(child); }
1077
+ if (child) { ast_node_free(child, allocator); }
816
1078
  }
817
1079
 
818
1080
  hb_array_free(&erb_case_match_node->children);
819
1081
  }
1082
+ /* prism_node is a borrowed reference into the prism context, not freed here */
820
1083
  if (erb_case_match_node->conditions != NULL) {
821
1084
  for (size_t i = 0; i < hb_array_size(erb_case_match_node->conditions); i++) {
822
1085
  AST_NODE_T* child = hb_array_get(erb_case_match_node->conditions, i);
823
- if (child) { ast_node_free(child); }
1086
+ if (child) { ast_node_free(child, allocator); }
824
1087
  }
825
1088
 
826
1089
  hb_array_free(&erb_case_match_node->conditions);
827
1090
  }
828
- ast_node_free((AST_NODE_T*) erb_case_match_node->else_clause);
829
- ast_node_free((AST_NODE_T*) erb_case_match_node->end_node);
1091
+ ast_node_free((AST_NODE_T*) erb_case_match_node->else_clause, allocator);
1092
+ ast_node_free((AST_NODE_T*) erb_case_match_node->end_node, allocator);
830
1093
 
831
- ast_free_base_node(&erb_case_match_node->base);
1094
+ ast_free_base_node(&erb_case_match_node->base, allocator);
832
1095
  }
833
1096
 
834
- static void ast_free_erb_while_node(AST_ERB_WHILE_NODE_T* erb_while_node) {
835
- if (erb_while_node->tag_opening != NULL) { token_free(erb_while_node->tag_opening); }
836
- if (erb_while_node->content != NULL) { token_free(erb_while_node->content); }
837
- if (erb_while_node->tag_closing != NULL) { token_free(erb_while_node->tag_closing); }
1097
+ static void ast_free_erb_while_node(AST_ERB_WHILE_NODE_T* erb_while_node, hb_allocator_T* allocator) {
1098
+ if (erb_while_node->tag_opening != NULL) { token_free(erb_while_node->tag_opening, allocator); }
1099
+ if (erb_while_node->content != NULL) { token_free(erb_while_node->content, allocator); }
1100
+ if (erb_while_node->tag_closing != NULL) { token_free(erb_while_node->tag_closing, allocator); }
1101
+ /* prism_node is a borrowed reference into the prism context, not freed here */
838
1102
  if (erb_while_node->statements != NULL) {
839
1103
  for (size_t i = 0; i < hb_array_size(erb_while_node->statements); i++) {
840
1104
  AST_NODE_T* child = hb_array_get(erb_while_node->statements, i);
841
- if (child) { ast_node_free(child); }
1105
+ if (child) { ast_node_free(child, allocator); }
842
1106
  }
843
1107
 
844
1108
  hb_array_free(&erb_while_node->statements);
845
1109
  }
846
- ast_node_free((AST_NODE_T*) erb_while_node->end_node);
1110
+ ast_node_free((AST_NODE_T*) erb_while_node->end_node, allocator);
847
1111
 
848
- ast_free_base_node(&erb_while_node->base);
1112
+ ast_free_base_node(&erb_while_node->base, allocator);
849
1113
  }
850
1114
 
851
- static void ast_free_erb_until_node(AST_ERB_UNTIL_NODE_T* erb_until_node) {
852
- if (erb_until_node->tag_opening != NULL) { token_free(erb_until_node->tag_opening); }
853
- if (erb_until_node->content != NULL) { token_free(erb_until_node->content); }
854
- if (erb_until_node->tag_closing != NULL) { token_free(erb_until_node->tag_closing); }
1115
+ static void ast_free_erb_until_node(AST_ERB_UNTIL_NODE_T* erb_until_node, hb_allocator_T* allocator) {
1116
+ if (erb_until_node->tag_opening != NULL) { token_free(erb_until_node->tag_opening, allocator); }
1117
+ if (erb_until_node->content != NULL) { token_free(erb_until_node->content, allocator); }
1118
+ if (erb_until_node->tag_closing != NULL) { token_free(erb_until_node->tag_closing, allocator); }
1119
+ /* prism_node is a borrowed reference into the prism context, not freed here */
855
1120
  if (erb_until_node->statements != NULL) {
856
1121
  for (size_t i = 0; i < hb_array_size(erb_until_node->statements); i++) {
857
1122
  AST_NODE_T* child = hb_array_get(erb_until_node->statements, i);
858
- if (child) { ast_node_free(child); }
1123
+ if (child) { ast_node_free(child, allocator); }
859
1124
  }
860
1125
 
861
1126
  hb_array_free(&erb_until_node->statements);
862
1127
  }
863
- ast_node_free((AST_NODE_T*) erb_until_node->end_node);
1128
+ ast_node_free((AST_NODE_T*) erb_until_node->end_node, allocator);
864
1129
 
865
- ast_free_base_node(&erb_until_node->base);
1130
+ ast_free_base_node(&erb_until_node->base, allocator);
866
1131
  }
867
1132
 
868
- static void ast_free_erb_for_node(AST_ERB_FOR_NODE_T* erb_for_node) {
869
- if (erb_for_node->tag_opening != NULL) { token_free(erb_for_node->tag_opening); }
870
- if (erb_for_node->content != NULL) { token_free(erb_for_node->content); }
871
- if (erb_for_node->tag_closing != NULL) { token_free(erb_for_node->tag_closing); }
1133
+ static void ast_free_erb_for_node(AST_ERB_FOR_NODE_T* erb_for_node, hb_allocator_T* allocator) {
1134
+ if (erb_for_node->tag_opening != NULL) { token_free(erb_for_node->tag_opening, allocator); }
1135
+ if (erb_for_node->content != NULL) { token_free(erb_for_node->content, allocator); }
1136
+ if (erb_for_node->tag_closing != NULL) { token_free(erb_for_node->tag_closing, allocator); }
1137
+ /* prism_node is a borrowed reference into the prism context, not freed here */
872
1138
  if (erb_for_node->statements != NULL) {
873
1139
  for (size_t i = 0; i < hb_array_size(erb_for_node->statements); i++) {
874
1140
  AST_NODE_T* child = hb_array_get(erb_for_node->statements, i);
875
- if (child) { ast_node_free(child); }
1141
+ if (child) { ast_node_free(child, allocator); }
876
1142
  }
877
1143
 
878
1144
  hb_array_free(&erb_for_node->statements);
879
1145
  }
880
- ast_node_free((AST_NODE_T*) erb_for_node->end_node);
1146
+ ast_node_free((AST_NODE_T*) erb_for_node->end_node, allocator);
881
1147
 
882
- ast_free_base_node(&erb_for_node->base);
1148
+ ast_free_base_node(&erb_for_node->base, allocator);
883
1149
  }
884
1150
 
885
- static void ast_free_erb_rescue_node(AST_ERB_RESCUE_NODE_T* erb_rescue_node) {
886
- if (erb_rescue_node->tag_opening != NULL) { token_free(erb_rescue_node->tag_opening); }
887
- if (erb_rescue_node->content != NULL) { token_free(erb_rescue_node->content); }
888
- if (erb_rescue_node->tag_closing != NULL) { token_free(erb_rescue_node->tag_closing); }
1151
+ static void ast_free_erb_rescue_node(AST_ERB_RESCUE_NODE_T* erb_rescue_node, hb_allocator_T* allocator) {
1152
+ if (erb_rescue_node->tag_opening != NULL) { token_free(erb_rescue_node->tag_opening, allocator); }
1153
+ if (erb_rescue_node->content != NULL) { token_free(erb_rescue_node->content, allocator); }
1154
+ if (erb_rescue_node->tag_closing != NULL) { token_free(erb_rescue_node->tag_closing, allocator); }
889
1155
  if (erb_rescue_node->statements != NULL) {
890
1156
  for (size_t i = 0; i < hb_array_size(erb_rescue_node->statements); i++) {
891
1157
  AST_NODE_T* child = hb_array_get(erb_rescue_node->statements, i);
892
- if (child) { ast_node_free(child); }
1158
+ if (child) { ast_node_free(child, allocator); }
893
1159
  }
894
1160
 
895
1161
  hb_array_free(&erb_rescue_node->statements);
896
1162
  }
897
- ast_node_free((AST_NODE_T*) erb_rescue_node->subsequent);
1163
+ ast_node_free((AST_NODE_T*) erb_rescue_node->subsequent, allocator);
898
1164
 
899
- ast_free_base_node(&erb_rescue_node->base);
1165
+ ast_free_base_node(&erb_rescue_node->base, allocator);
900
1166
  }
901
1167
 
902
- static void ast_free_erb_ensure_node(AST_ERB_ENSURE_NODE_T* erb_ensure_node) {
903
- if (erb_ensure_node->tag_opening != NULL) { token_free(erb_ensure_node->tag_opening); }
904
- if (erb_ensure_node->content != NULL) { token_free(erb_ensure_node->content); }
905
- if (erb_ensure_node->tag_closing != NULL) { token_free(erb_ensure_node->tag_closing); }
1168
+ static void ast_free_erb_ensure_node(AST_ERB_ENSURE_NODE_T* erb_ensure_node, hb_allocator_T* allocator) {
1169
+ if (erb_ensure_node->tag_opening != NULL) { token_free(erb_ensure_node->tag_opening, allocator); }
1170
+ if (erb_ensure_node->content != NULL) { token_free(erb_ensure_node->content, allocator); }
1171
+ if (erb_ensure_node->tag_closing != NULL) { token_free(erb_ensure_node->tag_closing, allocator); }
906
1172
  if (erb_ensure_node->statements != NULL) {
907
1173
  for (size_t i = 0; i < hb_array_size(erb_ensure_node->statements); i++) {
908
1174
  AST_NODE_T* child = hb_array_get(erb_ensure_node->statements, i);
909
- if (child) { ast_node_free(child); }
1175
+ if (child) { ast_node_free(child, allocator); }
910
1176
  }
911
1177
 
912
1178
  hb_array_free(&erb_ensure_node->statements);
913
1179
  }
914
1180
 
915
- ast_free_base_node(&erb_ensure_node->base);
1181
+ ast_free_base_node(&erb_ensure_node->base, allocator);
916
1182
  }
917
1183
 
918
- static void ast_free_erb_begin_node(AST_ERB_BEGIN_NODE_T* erb_begin_node) {
919
- if (erb_begin_node->tag_opening != NULL) { token_free(erb_begin_node->tag_opening); }
920
- if (erb_begin_node->content != NULL) { token_free(erb_begin_node->content); }
921
- if (erb_begin_node->tag_closing != NULL) { token_free(erb_begin_node->tag_closing); }
1184
+ static void ast_free_erb_begin_node(AST_ERB_BEGIN_NODE_T* erb_begin_node, hb_allocator_T* allocator) {
1185
+ if (erb_begin_node->tag_opening != NULL) { token_free(erb_begin_node->tag_opening, allocator); }
1186
+ if (erb_begin_node->content != NULL) { token_free(erb_begin_node->content, allocator); }
1187
+ if (erb_begin_node->tag_closing != NULL) { token_free(erb_begin_node->tag_closing, allocator); }
1188
+ /* prism_node is a borrowed reference into the prism context, not freed here */
922
1189
  if (erb_begin_node->statements != NULL) {
923
1190
  for (size_t i = 0; i < hb_array_size(erb_begin_node->statements); i++) {
924
1191
  AST_NODE_T* child = hb_array_get(erb_begin_node->statements, i);
925
- if (child) { ast_node_free(child); }
1192
+ if (child) { ast_node_free(child, allocator); }
926
1193
  }
927
1194
 
928
1195
  hb_array_free(&erb_begin_node->statements);
929
1196
  }
930
- ast_node_free((AST_NODE_T*) erb_begin_node->rescue_clause);
931
- ast_node_free((AST_NODE_T*) erb_begin_node->else_clause);
932
- ast_node_free((AST_NODE_T*) erb_begin_node->ensure_clause);
933
- ast_node_free((AST_NODE_T*) erb_begin_node->end_node);
1197
+ ast_node_free((AST_NODE_T*) erb_begin_node->rescue_clause, allocator);
1198
+ ast_node_free((AST_NODE_T*) erb_begin_node->else_clause, allocator);
1199
+ ast_node_free((AST_NODE_T*) erb_begin_node->ensure_clause, allocator);
1200
+ ast_node_free((AST_NODE_T*) erb_begin_node->end_node, allocator);
934
1201
 
935
- ast_free_base_node(&erb_begin_node->base);
1202
+ ast_free_base_node(&erb_begin_node->base, allocator);
936
1203
  }
937
1204
 
938
- static void ast_free_erb_unless_node(AST_ERB_UNLESS_NODE_T* erb_unless_node) {
939
- if (erb_unless_node->tag_opening != NULL) { token_free(erb_unless_node->tag_opening); }
940
- if (erb_unless_node->content != NULL) { token_free(erb_unless_node->content); }
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); }
1205
+ static void ast_free_erb_unless_node(AST_ERB_UNLESS_NODE_T* erb_unless_node, hb_allocator_T* allocator) {
1206
+ if (erb_unless_node->tag_opening != NULL) { token_free(erb_unless_node->tag_opening, allocator); }
1207
+ if (erb_unless_node->content != NULL) { token_free(erb_unless_node->content, allocator); }
1208
+ if (erb_unless_node->tag_closing != NULL) { token_free(erb_unless_node->tag_closing, allocator); }
1209
+ if (erb_unless_node->then_keyword != NULL) { hb_allocator_dealloc(allocator, erb_unless_node->then_keyword); }
1210
+ /* prism_node is a borrowed reference into the prism context, not freed here */
943
1211
  if (erb_unless_node->statements != NULL) {
944
1212
  for (size_t i = 0; i < hb_array_size(erb_unless_node->statements); i++) {
945
1213
  AST_NODE_T* child = hb_array_get(erb_unless_node->statements, i);
946
- if (child) { ast_node_free(child); }
1214
+ if (child) { ast_node_free(child, allocator); }
947
1215
  }
948
1216
 
949
1217
  hb_array_free(&erb_unless_node->statements);
950
1218
  }
951
- ast_node_free((AST_NODE_T*) erb_unless_node->else_clause);
952
- ast_node_free((AST_NODE_T*) erb_unless_node->end_node);
1219
+ ast_node_free((AST_NODE_T*) erb_unless_node->else_clause, allocator);
1220
+ ast_node_free((AST_NODE_T*) erb_unless_node->end_node, allocator);
953
1221
 
954
- ast_free_base_node(&erb_unless_node->base);
1222
+ ast_free_base_node(&erb_unless_node->base, allocator);
955
1223
  }
956
1224
 
957
- static void ast_free_erb_yield_node(AST_ERB_YIELD_NODE_T* erb_yield_node) {
958
- if (erb_yield_node->tag_opening != NULL) { token_free(erb_yield_node->tag_opening); }
959
- if (erb_yield_node->content != NULL) { token_free(erb_yield_node->content); }
960
- if (erb_yield_node->tag_closing != NULL) { token_free(erb_yield_node->tag_closing); }
1225
+ static void ast_free_erb_yield_node(AST_ERB_YIELD_NODE_T* erb_yield_node, hb_allocator_T* allocator) {
1226
+ if (erb_yield_node->tag_opening != NULL) { token_free(erb_yield_node->tag_opening, allocator); }
1227
+ if (erb_yield_node->content != NULL) { token_free(erb_yield_node->content, allocator); }
1228
+ if (erb_yield_node->tag_closing != NULL) { token_free(erb_yield_node->tag_closing, allocator); }
961
1229
 
962
- ast_free_base_node(&erb_yield_node->base);
1230
+ ast_free_base_node(&erb_yield_node->base, allocator);
963
1231
  }
964
1232
 
965
- static void ast_free_erb_in_node(AST_ERB_IN_NODE_T* erb_in_node) {
966
- if (erb_in_node->tag_opening != NULL) { token_free(erb_in_node->tag_opening); }
967
- if (erb_in_node->content != NULL) { token_free(erb_in_node->content); }
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); }
1233
+ static void ast_free_erb_in_node(AST_ERB_IN_NODE_T* erb_in_node, hb_allocator_T* allocator) {
1234
+ if (erb_in_node->tag_opening != NULL) { token_free(erb_in_node->tag_opening, allocator); }
1235
+ if (erb_in_node->content != NULL) { token_free(erb_in_node->content, allocator); }
1236
+ if (erb_in_node->tag_closing != NULL) { token_free(erb_in_node->tag_closing, allocator); }
1237
+ if (erb_in_node->then_keyword != NULL) { hb_allocator_dealloc(allocator, erb_in_node->then_keyword); }
970
1238
  if (erb_in_node->statements != NULL) {
971
1239
  for (size_t i = 0; i < hb_array_size(erb_in_node->statements); i++) {
972
1240
  AST_NODE_T* child = hb_array_get(erb_in_node->statements, i);
973
- if (child) { ast_node_free(child); }
1241
+ if (child) { ast_node_free(child, allocator); }
974
1242
  }
975
1243
 
976
1244
  hb_array_free(&erb_in_node->statements);
977
1245
  }
978
1246
 
979
- ast_free_base_node(&erb_in_node->base);
1247
+ ast_free_base_node(&erb_in_node->base, allocator);
980
1248
  }
981
1249
 
982
- void ast_node_free(AST_NODE_T* node) {
1250
+ void ast_node_free(AST_NODE_T* node, hb_allocator_T* allocator) {
983
1251
  if (!node) { return; }
984
1252
 
985
1253
  switch (node->type) {
986
- case AST_DOCUMENT_NODE: ast_free_document_node((AST_DOCUMENT_NODE_T*) node); break;
987
- case AST_LITERAL_NODE: ast_free_literal_node((AST_LITERAL_NODE_T*) node); break;
988
- case AST_HTML_OPEN_TAG_NODE: ast_free_html_open_tag_node((AST_HTML_OPEN_TAG_NODE_T*) node); break;
989
- case AST_HTML_CLOSE_TAG_NODE: ast_free_html_close_tag_node((AST_HTML_CLOSE_TAG_NODE_T*) node); break;
990
- case AST_HTML_ELEMENT_NODE: ast_free_html_element_node((AST_HTML_ELEMENT_NODE_T*) node); break;
991
- case AST_HTML_ATTRIBUTE_VALUE_NODE: ast_free_html_attribute_value_node((AST_HTML_ATTRIBUTE_VALUE_NODE_T*) node); break;
992
- case AST_HTML_ATTRIBUTE_NAME_NODE: ast_free_html_attribute_name_node((AST_HTML_ATTRIBUTE_NAME_NODE_T*) node); break;
993
- case AST_HTML_ATTRIBUTE_NODE: ast_free_html_attribute_node((AST_HTML_ATTRIBUTE_NODE_T*) node); break;
994
- case AST_HTML_TEXT_NODE: ast_free_html_text_node((AST_HTML_TEXT_NODE_T*) node); break;
995
- case AST_HTML_COMMENT_NODE: ast_free_html_comment_node((AST_HTML_COMMENT_NODE_T*) node); break;
996
- case AST_HTML_DOCTYPE_NODE: ast_free_html_doctype_node((AST_HTML_DOCTYPE_NODE_T*) node); break;
997
- case AST_XML_DECLARATION_NODE: ast_free_xml_declaration_node((AST_XML_DECLARATION_NODE_T*) node); break;
998
- case AST_CDATA_NODE: ast_free_cdata_node((AST_CDATA_NODE_T*) node); break;
999
- case AST_WHITESPACE_NODE: ast_free_whitespace_node((AST_WHITESPACE_NODE_T*) node); break;
1000
- case AST_ERB_CONTENT_NODE: ast_free_erb_content_node((AST_ERB_CONTENT_NODE_T*) node); break;
1001
- case AST_ERB_END_NODE: ast_free_erb_end_node((AST_ERB_END_NODE_T*) node); break;
1002
- case AST_ERB_ELSE_NODE: ast_free_erb_else_node((AST_ERB_ELSE_NODE_T*) node); break;
1003
- case AST_ERB_IF_NODE: ast_free_erb_if_node((AST_ERB_IF_NODE_T*) node); break;
1004
- case AST_ERB_BLOCK_NODE: ast_free_erb_block_node((AST_ERB_BLOCK_NODE_T*) node); break;
1005
- case AST_ERB_WHEN_NODE: ast_free_erb_when_node((AST_ERB_WHEN_NODE_T*) node); break;
1006
- case AST_ERB_CASE_NODE: ast_free_erb_case_node((AST_ERB_CASE_NODE_T*) node); break;
1007
- case AST_ERB_CASE_MATCH_NODE: ast_free_erb_case_match_node((AST_ERB_CASE_MATCH_NODE_T*) node); break;
1008
- case AST_ERB_WHILE_NODE: ast_free_erb_while_node((AST_ERB_WHILE_NODE_T*) node); break;
1009
- case AST_ERB_UNTIL_NODE: ast_free_erb_until_node((AST_ERB_UNTIL_NODE_T*) node); break;
1010
- case AST_ERB_FOR_NODE: ast_free_erb_for_node((AST_ERB_FOR_NODE_T*) node); break;
1011
- case AST_ERB_RESCUE_NODE: ast_free_erb_rescue_node((AST_ERB_RESCUE_NODE_T*) node); break;
1012
- case AST_ERB_ENSURE_NODE: ast_free_erb_ensure_node((AST_ERB_ENSURE_NODE_T*) node); break;
1013
- case AST_ERB_BEGIN_NODE: ast_free_erb_begin_node((AST_ERB_BEGIN_NODE_T*) node); break;
1014
- case AST_ERB_UNLESS_NODE: ast_free_erb_unless_node((AST_ERB_UNLESS_NODE_T*) node); break;
1015
- case AST_ERB_YIELD_NODE: ast_free_erb_yield_node((AST_ERB_YIELD_NODE_T*) node); break;
1016
- case AST_ERB_IN_NODE: ast_free_erb_in_node((AST_ERB_IN_NODE_T*) node); break;
1254
+ case AST_DOCUMENT_NODE: ast_free_document_node((AST_DOCUMENT_NODE_T*) node, allocator); break;
1255
+ case AST_LITERAL_NODE: ast_free_literal_node((AST_LITERAL_NODE_T*) node, allocator); break;
1256
+ case AST_HTML_OPEN_TAG_NODE: ast_free_html_open_tag_node((AST_HTML_OPEN_TAG_NODE_T*) node, allocator); break;
1257
+ case AST_HTML_CONDITIONAL_OPEN_TAG_NODE: ast_free_html_conditional_open_tag_node((AST_HTML_CONDITIONAL_OPEN_TAG_NODE_T*) node, allocator); break;
1258
+ case AST_HTML_CLOSE_TAG_NODE: ast_free_html_close_tag_node((AST_HTML_CLOSE_TAG_NODE_T*) node, allocator); break;
1259
+ case AST_HTML_OMITTED_CLOSE_TAG_NODE: ast_free_html_omitted_close_tag_node((AST_HTML_OMITTED_CLOSE_TAG_NODE_T*) node, allocator); break;
1260
+ case AST_HTML_VIRTUAL_CLOSE_TAG_NODE: ast_free_html_virtual_close_tag_node((AST_HTML_VIRTUAL_CLOSE_TAG_NODE_T*) node, allocator); break;
1261
+ case AST_HTML_ELEMENT_NODE: ast_free_html_element_node((AST_HTML_ELEMENT_NODE_T*) node, allocator); break;
1262
+ case AST_HTML_CONDITIONAL_ELEMENT_NODE: ast_free_html_conditional_element_node((AST_HTML_CONDITIONAL_ELEMENT_NODE_T*) node, allocator); break;
1263
+ case AST_HTML_ATTRIBUTE_VALUE_NODE: ast_free_html_attribute_value_node((AST_HTML_ATTRIBUTE_VALUE_NODE_T*) node, allocator); break;
1264
+ case AST_HTML_ATTRIBUTE_NAME_NODE: ast_free_html_attribute_name_node((AST_HTML_ATTRIBUTE_NAME_NODE_T*) node, allocator); break;
1265
+ case AST_HTML_ATTRIBUTE_NODE: ast_free_html_attribute_node((AST_HTML_ATTRIBUTE_NODE_T*) node, allocator); break;
1266
+ case AST_RUBY_LITERAL_NODE: ast_free_ruby_literal_node((AST_RUBY_LITERAL_NODE_T*) node, allocator); break;
1267
+ case AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE: ast_free_ruby_html_attributes_splat_node((AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE_T*) node, allocator); break;
1268
+ case AST_ERB_OPEN_TAG_NODE: ast_free_erb_open_tag_node((AST_ERB_OPEN_TAG_NODE_T*) node, allocator); break;
1269
+ case AST_HTML_TEXT_NODE: ast_free_html_text_node((AST_HTML_TEXT_NODE_T*) node, allocator); break;
1270
+ case AST_HTML_COMMENT_NODE: ast_free_html_comment_node((AST_HTML_COMMENT_NODE_T*) node, allocator); break;
1271
+ case AST_HTML_DOCTYPE_NODE: ast_free_html_doctype_node((AST_HTML_DOCTYPE_NODE_T*) node, allocator); break;
1272
+ case AST_XML_DECLARATION_NODE: ast_free_xml_declaration_node((AST_XML_DECLARATION_NODE_T*) node, allocator); break;
1273
+ case AST_CDATA_NODE: ast_free_cdata_node((AST_CDATA_NODE_T*) node, allocator); break;
1274
+ case AST_WHITESPACE_NODE: ast_free_whitespace_node((AST_WHITESPACE_NODE_T*) node, allocator); break;
1275
+ case AST_ERB_CONTENT_NODE: ast_free_erb_content_node((AST_ERB_CONTENT_NODE_T*) node, allocator); break;
1276
+ case AST_ERB_END_NODE: ast_free_erb_end_node((AST_ERB_END_NODE_T*) node, allocator); break;
1277
+ case AST_ERB_ELSE_NODE: ast_free_erb_else_node((AST_ERB_ELSE_NODE_T*) node, allocator); break;
1278
+ case AST_ERB_IF_NODE: ast_free_erb_if_node((AST_ERB_IF_NODE_T*) node, allocator); break;
1279
+ case AST_ERB_BLOCK_NODE: ast_free_erb_block_node((AST_ERB_BLOCK_NODE_T*) node, allocator); break;
1280
+ case AST_ERB_WHEN_NODE: ast_free_erb_when_node((AST_ERB_WHEN_NODE_T*) node, allocator); break;
1281
+ case AST_ERB_CASE_NODE: ast_free_erb_case_node((AST_ERB_CASE_NODE_T*) node, allocator); break;
1282
+ case AST_ERB_CASE_MATCH_NODE: ast_free_erb_case_match_node((AST_ERB_CASE_MATCH_NODE_T*) node, allocator); break;
1283
+ case AST_ERB_WHILE_NODE: ast_free_erb_while_node((AST_ERB_WHILE_NODE_T*) node, allocator); break;
1284
+ case AST_ERB_UNTIL_NODE: ast_free_erb_until_node((AST_ERB_UNTIL_NODE_T*) node, allocator); break;
1285
+ case AST_ERB_FOR_NODE: ast_free_erb_for_node((AST_ERB_FOR_NODE_T*) node, allocator); break;
1286
+ case AST_ERB_RESCUE_NODE: ast_free_erb_rescue_node((AST_ERB_RESCUE_NODE_T*) node, allocator); break;
1287
+ case AST_ERB_ENSURE_NODE: ast_free_erb_ensure_node((AST_ERB_ENSURE_NODE_T*) node, allocator); break;
1288
+ case AST_ERB_BEGIN_NODE: ast_free_erb_begin_node((AST_ERB_BEGIN_NODE_T*) node, allocator); break;
1289
+ case AST_ERB_UNLESS_NODE: ast_free_erb_unless_node((AST_ERB_UNLESS_NODE_T*) node, allocator); break;
1290
+ case AST_ERB_YIELD_NODE: ast_free_erb_yield_node((AST_ERB_YIELD_NODE_T*) node, allocator); break;
1291
+ case AST_ERB_IN_NODE: ast_free_erb_in_node((AST_ERB_IN_NODE_T*) node, allocator); break;
1017
1292
  }
1018
1293
  }