herb 0.7.4-x86-linux-gnu → 0.7.5-x86-linux-gnu

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/config.yml +14 -14
  3. data/ext/herb/extension_helpers.c +9 -15
  4. data/ext/herb/extension_helpers.h +3 -3
  5. data/ext/herb/nodes.c +1 -1
  6. data/lib/herb/3.0/herb.so +0 -0
  7. data/lib/herb/3.1/herb.so +0 -0
  8. data/lib/herb/3.2/herb.so +0 -0
  9. data/lib/herb/3.3/herb.so +0 -0
  10. data/lib/herb/3.4/herb.so +0 -0
  11. data/lib/herb/engine.rb +10 -6
  12. data/lib/herb/version.rb +1 -1
  13. data/src/analyze.c +43 -80
  14. data/src/ast_node.c +10 -13
  15. data/src/ast_nodes.c +31 -33
  16. data/src/buffer.c +10 -1
  17. data/src/errors.c +35 -35
  18. data/src/include/ast_node.h +3 -3
  19. data/src/include/ast_nodes.h +32 -32
  20. data/src/include/errors.h +21 -21
  21. data/src/include/lexer_peek_helpers.h +8 -6
  22. data/src/include/lexer_struct.h +10 -9
  23. data/src/include/location.h +10 -13
  24. data/src/include/parser_helpers.h +1 -1
  25. data/src/include/position.h +3 -14
  26. data/src/include/pretty_print.h +1 -1
  27. data/src/include/prism_helpers.h +1 -1
  28. data/src/include/range.h +4 -13
  29. data/src/include/token.h +0 -3
  30. data/src/include/token_struct.h +2 -2
  31. data/src/include/version.h +1 -1
  32. data/src/lexer.c +3 -2
  33. data/src/lexer_peek_helpers.c +10 -4
  34. data/src/location.c +9 -37
  35. data/src/parser.c +98 -119
  36. data/src/parser_helpers.c +15 -15
  37. data/src/pretty_print.c +7 -12
  38. data/src/prism_helpers.c +7 -7
  39. data/src/range.c +2 -35
  40. data/src/token.c +25 -29
  41. data/templates/javascript/packages/core/src/visitor.ts.erb +29 -1
  42. data/templates/src/ast_nodes.c.erb +1 -3
  43. data/templates/src/errors.c.erb +5 -7
  44. data/templates/src/include/ast_nodes.h.erb +2 -2
  45. data/templates/src/include/errors.h.erb +3 -3
  46. metadata +2 -3
  47. data/src/position.c +0 -33
data/src/ast_nodes.c CHANGED
@@ -15,7 +15,7 @@
15
15
  #include "include/util.h"
16
16
 
17
17
 
18
- AST_DOCUMENT_NODE_T* ast_document_node_init(array_T* children, position_T* start_position, position_T* end_position, array_T* errors) {
18
+ AST_DOCUMENT_NODE_T* ast_document_node_init(array_T* children, position_T start_position, position_T end_position, array_T* errors) {
19
19
  AST_DOCUMENT_NODE_T* document_node = malloc(sizeof(AST_DOCUMENT_NODE_T));
20
20
 
21
21
  ast_node_init(&document_node->base, AST_DOCUMENT_NODE, start_position, end_position, errors);
@@ -25,7 +25,7 @@ AST_DOCUMENT_NODE_T* ast_document_node_init(array_T* children, position_T* start
25
25
  return document_node;
26
26
  }
27
27
 
28
- AST_LITERAL_NODE_T* ast_literal_node_init(const char* content, position_T* start_position, position_T* end_position, array_T* errors) {
28
+ AST_LITERAL_NODE_T* ast_literal_node_init(const char* content, position_T start_position, position_T end_position, array_T* errors) {
29
29
  AST_LITERAL_NODE_T* literal_node = malloc(sizeof(AST_LITERAL_NODE_T));
30
30
 
31
31
  ast_node_init(&literal_node->base, AST_LITERAL_NODE, start_position, end_position, errors);
@@ -35,7 +35,7 @@ AST_LITERAL_NODE_T* ast_literal_node_init(const char* content, position_T* start
35
35
  return literal_node;
36
36
  }
37
37
 
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, array_T* children, bool is_void, position_T* start_position, position_T* end_position, array_T* errors) {
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, array_T* children, bool is_void, position_T start_position, position_T end_position, array_T* errors) {
39
39
  AST_HTML_OPEN_TAG_NODE_T* html_open_tag_node = malloc(sizeof(AST_HTML_OPEN_TAG_NODE_T));
40
40
 
41
41
  ast_node_init(&html_open_tag_node->base, AST_HTML_OPEN_TAG_NODE, start_position, end_position, errors);
@@ -49,7 +49,7 @@ AST_HTML_OPEN_TAG_NODE_T* ast_html_open_tag_node_init(token_T* tag_opening, toke
49
49
  return html_open_tag_node;
50
50
  }
51
51
 
52
- AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, token_T* tag_name, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors) {
52
+ AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, token_T* tag_name, array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, array_T* errors) {
53
53
  AST_HTML_CLOSE_TAG_NODE_T* html_close_tag_node = malloc(sizeof(AST_HTML_CLOSE_TAG_NODE_T));
54
54
 
55
55
  ast_node_init(&html_close_tag_node->base, AST_HTML_CLOSE_TAG_NODE, start_position, end_position, errors);
@@ -62,7 +62,7 @@ AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, to
62
62
  return html_close_tag_node;
63
63
  }
64
64
 
65
- AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, token_T* tag_name, 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, array_T* errors) {
65
+ AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, token_T* tag_name, 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, array_T* errors) {
66
66
  AST_HTML_ELEMENT_NODE_T* html_element_node = malloc(sizeof(AST_HTML_ELEMENT_NODE_T));
67
67
 
68
68
  ast_node_init(&html_element_node->base, AST_HTML_ELEMENT_NODE, start_position, end_position, errors);
@@ -77,7 +77,7 @@ AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NOD
77
77
  return html_element_node;
78
78
  }
79
79
 
80
- AST_HTML_ATTRIBUTE_VALUE_NODE_T* ast_html_attribute_value_node_init(token_T* open_quote, array_T* children, token_T* close_quote, bool quoted, position_T* start_position, position_T* end_position, array_T* errors) {
80
+ AST_HTML_ATTRIBUTE_VALUE_NODE_T* ast_html_attribute_value_node_init(token_T* open_quote, array_T* children, token_T* close_quote, bool quoted, position_T start_position, position_T end_position, array_T* errors) {
81
81
  AST_HTML_ATTRIBUTE_VALUE_NODE_T* html_attribute_value_node = malloc(sizeof(AST_HTML_ATTRIBUTE_VALUE_NODE_T));
82
82
 
83
83
  ast_node_init(&html_attribute_value_node->base, AST_HTML_ATTRIBUTE_VALUE_NODE, start_position, end_position, errors);
@@ -90,7 +90,7 @@ AST_HTML_ATTRIBUTE_VALUE_NODE_T* ast_html_attribute_value_node_init(token_T* ope
90
90
  return html_attribute_value_node;
91
91
  }
92
92
 
93
- AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(array_T* children, position_T* start_position, position_T* end_position, array_T* errors) {
93
+ AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(array_T* children, position_T start_position, position_T end_position, array_T* errors) {
94
94
  AST_HTML_ATTRIBUTE_NAME_NODE_T* html_attribute_name_node = malloc(sizeof(AST_HTML_ATTRIBUTE_NAME_NODE_T));
95
95
 
96
96
  ast_node_init(&html_attribute_name_node->base, AST_HTML_ATTRIBUTE_NAME_NODE, start_position, end_position, errors);
@@ -100,7 +100,7 @@ AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(array_T* child
100
100
  return html_attribute_name_node;
101
101
  }
102
102
 
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, array_T* errors) {
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, array_T* errors) {
104
104
  AST_HTML_ATTRIBUTE_NODE_T* html_attribute_node = malloc(sizeof(AST_HTML_ATTRIBUTE_NODE_T));
105
105
 
106
106
  ast_node_init(&html_attribute_node->base, AST_HTML_ATTRIBUTE_NODE, start_position, end_position, errors);
@@ -112,7 +112,7 @@ AST_HTML_ATTRIBUTE_NODE_T* ast_html_attribute_node_init(struct AST_HTML_ATTRIBUT
112
112
  return html_attribute_node;
113
113
  }
114
114
 
115
- AST_HTML_TEXT_NODE_T* ast_html_text_node_init(const char* content, position_T* start_position, position_T* end_position, array_T* errors) {
115
+ AST_HTML_TEXT_NODE_T* ast_html_text_node_init(const char* content, position_T start_position, position_T end_position, array_T* errors) {
116
116
  AST_HTML_TEXT_NODE_T* html_text_node = malloc(sizeof(AST_HTML_TEXT_NODE_T));
117
117
 
118
118
  ast_node_init(&html_text_node->base, AST_HTML_TEXT_NODE, start_position, end_position, errors);
@@ -122,7 +122,7 @@ AST_HTML_TEXT_NODE_T* ast_html_text_node_init(const char* content, position_T* s
122
122
  return html_text_node;
123
123
  }
124
124
 
125
- AST_HTML_COMMENT_NODE_T* ast_html_comment_node_init(token_T* comment_start, array_T* children, token_T* comment_end, position_T* start_position, position_T* end_position, array_T* errors) {
125
+ AST_HTML_COMMENT_NODE_T* ast_html_comment_node_init(token_T* comment_start, array_T* children, token_T* comment_end, position_T start_position, position_T end_position, array_T* errors) {
126
126
  AST_HTML_COMMENT_NODE_T* html_comment_node = malloc(sizeof(AST_HTML_COMMENT_NODE_T));
127
127
 
128
128
  ast_node_init(&html_comment_node->base, AST_HTML_COMMENT_NODE, start_position, end_position, errors);
@@ -134,7 +134,7 @@ AST_HTML_COMMENT_NODE_T* ast_html_comment_node_init(token_T* comment_start, arra
134
134
  return html_comment_node;
135
135
  }
136
136
 
137
- AST_HTML_DOCTYPE_NODE_T* ast_html_doctype_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors) {
137
+ AST_HTML_DOCTYPE_NODE_T* ast_html_doctype_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, array_T* errors) {
138
138
  AST_HTML_DOCTYPE_NODE_T* html_doctype_node = malloc(sizeof(AST_HTML_DOCTYPE_NODE_T));
139
139
 
140
140
  ast_node_init(&html_doctype_node->base, AST_HTML_DOCTYPE_NODE, start_position, end_position, errors);
@@ -146,7 +146,7 @@ AST_HTML_DOCTYPE_NODE_T* ast_html_doctype_node_init(token_T* tag_opening, array_
146
146
  return html_doctype_node;
147
147
  }
148
148
 
149
- AST_XML_DECLARATION_NODE_T* ast_xml_declaration_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors) {
149
+ AST_XML_DECLARATION_NODE_T* ast_xml_declaration_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, array_T* errors) {
150
150
  AST_XML_DECLARATION_NODE_T* xml_declaration_node = malloc(sizeof(AST_XML_DECLARATION_NODE_T));
151
151
 
152
152
  ast_node_init(&xml_declaration_node->base, AST_XML_DECLARATION_NODE, start_position, end_position, errors);
@@ -158,7 +158,7 @@ AST_XML_DECLARATION_NODE_T* ast_xml_declaration_node_init(token_T* tag_opening,
158
158
  return xml_declaration_node;
159
159
  }
160
160
 
161
- AST_CDATA_NODE_T* ast_cdata_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors) {
161
+ AST_CDATA_NODE_T* ast_cdata_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, array_T* errors) {
162
162
  AST_CDATA_NODE_T* cdata_node = malloc(sizeof(AST_CDATA_NODE_T));
163
163
 
164
164
  ast_node_init(&cdata_node->base, AST_CDATA_NODE, start_position, end_position, errors);
@@ -170,7 +170,7 @@ AST_CDATA_NODE_T* ast_cdata_node_init(token_T* tag_opening, array_T* children, t
170
170
  return cdata_node;
171
171
  }
172
172
 
173
- AST_WHITESPACE_NODE_T* ast_whitespace_node_init(token_T* value, position_T* start_position, position_T* end_position, array_T* errors) {
173
+ AST_WHITESPACE_NODE_T* ast_whitespace_node_init(token_T* value, position_T start_position, position_T end_position, array_T* errors) {
174
174
  AST_WHITESPACE_NODE_T* whitespace_node = malloc(sizeof(AST_WHITESPACE_NODE_T));
175
175
 
176
176
  ast_node_init(&whitespace_node->base, AST_WHITESPACE_NODE, start_position, end_position, errors);
@@ -180,7 +180,7 @@ AST_WHITESPACE_NODE_T* ast_whitespace_node_init(token_T* value, position_T* star
180
180
  return whitespace_node;
181
181
  }
182
182
 
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, array_T* errors) {
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, array_T* errors) {
184
184
  AST_ERB_CONTENT_NODE_T* erb_content_node = malloc(sizeof(AST_ERB_CONTENT_NODE_T));
185
185
 
186
186
  ast_node_init(&erb_content_node->base, AST_ERB_CONTENT_NODE, start_position, end_position, errors);
@@ -195,7 +195,7 @@ AST_ERB_CONTENT_NODE_T* ast_erb_content_node_init(token_T* tag_opening, token_T*
195
195
  return erb_content_node;
196
196
  }
197
197
 
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, array_T* errors) {
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, array_T* errors) {
199
199
  AST_ERB_END_NODE_T* erb_end_node = malloc(sizeof(AST_ERB_END_NODE_T));
200
200
 
201
201
  ast_node_init(&erb_end_node->base, AST_ERB_END_NODE, start_position, end_position, errors);
@@ -207,7 +207,7 @@ AST_ERB_END_NODE_T* ast_erb_end_node_init(token_T* tag_opening, token_T* content
207
207
  return erb_end_node;
208
208
  }
209
209
 
210
- AST_ERB_ELSE_NODE_T* ast_erb_else_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T* start_position, position_T* end_position, array_T* errors) {
210
+ AST_ERB_ELSE_NODE_T* ast_erb_else_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T start_position, position_T end_position, array_T* errors) {
211
211
  AST_ERB_ELSE_NODE_T* erb_else_node = malloc(sizeof(AST_ERB_ELSE_NODE_T));
212
212
 
213
213
  ast_node_init(&erb_else_node->base, AST_ERB_ELSE_NODE, start_position, end_position, errors);
@@ -220,7 +220,7 @@ AST_ERB_ELSE_NODE_T* ast_erb_else_node_init(token_T* tag_opening, token_T* conte
220
220
  return erb_else_node;
221
221
  }
222
222
 
223
- AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_NODE_STRUCT* subsequent, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors) {
223
+ AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_NODE_STRUCT* subsequent, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, array_T* errors) {
224
224
  AST_ERB_IF_NODE_T* erb_if_node = malloc(sizeof(AST_ERB_IF_NODE_T));
225
225
 
226
226
  ast_node_init(&erb_if_node->base, AST_ERB_IF_NODE, start_position, end_position, errors);
@@ -235,7 +235,7 @@ AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content,
235
235
  return erb_if_node;
236
236
  }
237
237
 
238
- AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* body, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors) {
238
+ AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* body, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, array_T* errors) {
239
239
  AST_ERB_BLOCK_NODE_T* erb_block_node = malloc(sizeof(AST_ERB_BLOCK_NODE_T));
240
240
 
241
241
  ast_node_init(&erb_block_node->base, AST_ERB_BLOCK_NODE, start_position, end_position, errors);
@@ -249,7 +249,7 @@ AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* con
249
249
  return erb_block_node;
250
250
  }
251
251
 
252
- AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T* start_position, position_T* end_position, array_T* errors) {
252
+ AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T start_position, position_T end_position, array_T* errors) {
253
253
  AST_ERB_WHEN_NODE_T* erb_when_node = malloc(sizeof(AST_ERB_WHEN_NODE_T));
254
254
 
255
255
  ast_node_init(&erb_when_node->base, AST_ERB_WHEN_NODE, start_position, end_position, errors);
@@ -262,7 +262,7 @@ AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* conte
262
262
  return erb_when_node;
263
263
  }
264
264
 
265
- AST_ERB_CASE_NODE_T* ast_erb_case_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* children, 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, array_T* errors) {
265
+ AST_ERB_CASE_NODE_T* ast_erb_case_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* children, 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, array_T* errors) {
266
266
  AST_ERB_CASE_NODE_T* erb_case_node = malloc(sizeof(AST_ERB_CASE_NODE_T));
267
267
 
268
268
  ast_node_init(&erb_case_node->base, AST_ERB_CASE_NODE, start_position, end_position, errors);
@@ -278,7 +278,7 @@ AST_ERB_CASE_NODE_T* ast_erb_case_node_init(token_T* tag_opening, token_T* conte
278
278
  return erb_case_node;
279
279
  }
280
280
 
281
- AST_ERB_CASE_MATCH_NODE_T* ast_erb_case_match_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* children, 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, array_T* errors) {
281
+ AST_ERB_CASE_MATCH_NODE_T* ast_erb_case_match_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* children, 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, array_T* errors) {
282
282
  AST_ERB_CASE_MATCH_NODE_T* erb_case_match_node = malloc(sizeof(AST_ERB_CASE_MATCH_NODE_T));
283
283
 
284
284
  ast_node_init(&erb_case_match_node->base, AST_ERB_CASE_MATCH_NODE, start_position, end_position, errors);
@@ -294,7 +294,7 @@ AST_ERB_CASE_MATCH_NODE_T* ast_erb_case_match_node_init(token_T* tag_opening, to
294
294
  return erb_case_match_node;
295
295
  }
296
296
 
297
- AST_ERB_WHILE_NODE_T* ast_erb_while_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors) {
297
+ AST_ERB_WHILE_NODE_T* ast_erb_while_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, array_T* errors) {
298
298
  AST_ERB_WHILE_NODE_T* erb_while_node = malloc(sizeof(AST_ERB_WHILE_NODE_T));
299
299
 
300
300
  ast_node_init(&erb_while_node->base, AST_ERB_WHILE_NODE, start_position, end_position, errors);
@@ -308,7 +308,7 @@ AST_ERB_WHILE_NODE_T* ast_erb_while_node_init(token_T* tag_opening, token_T* con
308
308
  return erb_while_node;
309
309
  }
310
310
 
311
- AST_ERB_UNTIL_NODE_T* ast_erb_until_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors) {
311
+ AST_ERB_UNTIL_NODE_T* ast_erb_until_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, array_T* errors) {
312
312
  AST_ERB_UNTIL_NODE_T* erb_until_node = malloc(sizeof(AST_ERB_UNTIL_NODE_T));
313
313
 
314
314
  ast_node_init(&erb_until_node->base, AST_ERB_UNTIL_NODE, start_position, end_position, errors);
@@ -322,7 +322,7 @@ AST_ERB_UNTIL_NODE_T* ast_erb_until_node_init(token_T* tag_opening, token_T* con
322
322
  return erb_until_node;
323
323
  }
324
324
 
325
- AST_ERB_FOR_NODE_T* ast_erb_for_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors) {
325
+ AST_ERB_FOR_NODE_T* ast_erb_for_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, array_T* errors) {
326
326
  AST_ERB_FOR_NODE_T* erb_for_node = malloc(sizeof(AST_ERB_FOR_NODE_T));
327
327
 
328
328
  ast_node_init(&erb_for_node->base, AST_ERB_FOR_NODE, start_position, end_position, errors);
@@ -336,7 +336,7 @@ AST_ERB_FOR_NODE_T* ast_erb_for_node_init(token_T* tag_opening, token_T* content
336
336
  return erb_for_node;
337
337
  }
338
338
 
339
- AST_ERB_RESCUE_NODE_T* ast_erb_rescue_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_RESCUE_NODE_STRUCT* subsequent, position_T* start_position, position_T* end_position, array_T* errors) {
339
+ AST_ERB_RESCUE_NODE_T* ast_erb_rescue_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_RESCUE_NODE_STRUCT* subsequent, position_T start_position, position_T end_position, array_T* errors) {
340
340
  AST_ERB_RESCUE_NODE_T* erb_rescue_node = malloc(sizeof(AST_ERB_RESCUE_NODE_T));
341
341
 
342
342
  ast_node_init(&erb_rescue_node->base, AST_ERB_RESCUE_NODE, start_position, end_position, errors);
@@ -350,7 +350,7 @@ AST_ERB_RESCUE_NODE_T* ast_erb_rescue_node_init(token_T* tag_opening, token_T* c
350
350
  return erb_rescue_node;
351
351
  }
352
352
 
353
- AST_ERB_ENSURE_NODE_T* ast_erb_ensure_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T* start_position, position_T* end_position, array_T* errors) {
353
+ AST_ERB_ENSURE_NODE_T* ast_erb_ensure_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T start_position, position_T end_position, array_T* errors) {
354
354
  AST_ERB_ENSURE_NODE_T* erb_ensure_node = malloc(sizeof(AST_ERB_ENSURE_NODE_T));
355
355
 
356
356
  ast_node_init(&erb_ensure_node->base, AST_ERB_ENSURE_NODE, start_position, end_position, errors);
@@ -363,7 +363,7 @@ AST_ERB_ENSURE_NODE_T* ast_erb_ensure_node_init(token_T* tag_opening, token_T* c
363
363
  return erb_ensure_node;
364
364
  }
365
365
 
366
- AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, 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, array_T* errors) {
366
+ AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, 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, array_T* errors) {
367
367
  AST_ERB_BEGIN_NODE_T* erb_begin_node = malloc(sizeof(AST_ERB_BEGIN_NODE_T));
368
368
 
369
369
  ast_node_init(&erb_begin_node->base, AST_ERB_BEGIN_NODE, start_position, end_position, errors);
@@ -380,7 +380,7 @@ AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* con
380
380
  return erb_begin_node;
381
381
  }
382
382
 
383
- AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, 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, array_T* errors) {
383
+ AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, 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, array_T* errors) {
384
384
  AST_ERB_UNLESS_NODE_T* erb_unless_node = malloc(sizeof(AST_ERB_UNLESS_NODE_T));
385
385
 
386
386
  ast_node_init(&erb_unless_node->base, AST_ERB_UNLESS_NODE, start_position, end_position, errors);
@@ -395,7 +395,7 @@ AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* c
395
395
  return erb_unless_node;
396
396
  }
397
397
 
398
- 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, array_T* errors) {
398
+ 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, array_T* errors) {
399
399
  AST_ERB_YIELD_NODE_T* erb_yield_node = malloc(sizeof(AST_ERB_YIELD_NODE_T));
400
400
 
401
401
  ast_node_init(&erb_yield_node->base, AST_ERB_YIELD_NODE, start_position, end_position, errors);
@@ -407,7 +407,7 @@ AST_ERB_YIELD_NODE_T* ast_erb_yield_node_init(token_T* tag_opening, token_T* con
407
407
  return erb_yield_node;
408
408
  }
409
409
 
410
- AST_ERB_IN_NODE_T* ast_erb_in_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T* start_position, position_T* end_position, array_T* errors) {
410
+ AST_ERB_IN_NODE_T* ast_erb_in_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T start_position, position_T end_position, array_T* errors) {
411
411
  AST_ERB_IN_NODE_T* erb_in_node = malloc(sizeof(AST_ERB_IN_NODE_T));
412
412
 
413
413
  ast_node_init(&erb_in_node->base, AST_ERB_IN_NODE, start_position, end_position, errors);
@@ -508,8 +508,6 @@ void ast_free_base_node(AST_NODE_T* node) {
508
508
  array_free(&node->errors);
509
509
  }
510
510
 
511
- if (node->location) { location_free(node->location); }
512
-
513
511
  free(node);
514
512
  }
515
513
 
data/src/buffer.c CHANGED
@@ -114,7 +114,16 @@ bool buffer_expand_capacity(buffer_T* buffer) {
114
114
  bool buffer_expand_if_needed(buffer_T* buffer, const size_t required_length) {
115
115
  if (buffer_has_capacity(buffer, required_length)) { return true; }
116
116
 
117
- return buffer_resize(buffer, buffer->capacity + (required_length * 2));
117
+ bool should_double_capacity = required_length < buffer->capacity;
118
+ size_t new_capacity = 0;
119
+
120
+ if (should_double_capacity) {
121
+ new_capacity = buffer->capacity * 2;
122
+ } else {
123
+ new_capacity = buffer->capacity + (required_length * 2);
124
+ }
125
+
126
+ return buffer_resize(buffer, new_capacity);
118
127
  }
119
128
 
120
129
  /**
data/src/errors.c CHANGED
@@ -20,14 +20,15 @@ size_t error_sizeof(void) {
20
20
  return sizeof(struct ERROR_STRUCT);
21
21
  }
22
22
 
23
- void error_init(ERROR_T* error, const error_type_T type, position_T* start, position_T* end) {
23
+ void error_init(ERROR_T* error, const error_type_T type, position_T start, position_T end) {
24
24
  if (!error) { return; }
25
25
 
26
26
  error->type = type;
27
- error->location = location_init(position_copy(start), position_copy(end));
27
+ error->location.start = start;
28
+ error->location.end = end;
28
29
  }
29
30
 
30
- UNEXPECTED_ERROR_T* unexpected_error_init(const char* description, const char* expected, const char* found, position_T* start, position_T* end) {
31
+ UNEXPECTED_ERROR_T* unexpected_error_init(const char* description, const char* expected, const char* found, position_T start, position_T end) {
31
32
  UNEXPECTED_ERROR_T* unexpected_error = malloc(sizeof(UNEXPECTED_ERROR_T));
32
33
 
33
34
  error_init(&unexpected_error->base, UNEXPECTED_ERROR, start, end);
@@ -71,11 +72,11 @@ UNEXPECTED_ERROR_T* unexpected_error_init(const char* description, const char* e
71
72
  return unexpected_error;
72
73
  }
73
74
 
74
- void append_unexpected_error(const char* description, const char* expected, const char* found, position_T* start, position_T* end, array_T* errors) {
75
+ void append_unexpected_error(const char* description, const char* expected, const char* found, position_T start, position_T end, array_T* errors) {
75
76
  array_append(errors, unexpected_error_init(description, expected, found, start, end));
76
77
  }
77
78
 
78
- UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error_init(token_type_T expected_type, token_T* found, position_T* start, position_T* end) {
79
+ UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error_init(token_type_T expected_type, token_T* found, position_T start, position_T end) {
79
80
  UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error = malloc(sizeof(UNEXPECTED_TOKEN_ERROR_T));
80
81
 
81
82
  error_init(&unexpected_token_error->base, UNEXPECTED_TOKEN_ERROR, start, end);
@@ -100,8 +101,8 @@ UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error_init(token_type_T expected_type
100
101
  message_template,
101
102
  truncated_argument_0,
102
103
  truncated_argument_1,
103
- found->location->start->line,
104
- found->location->start->column
104
+ found->location.start.line,
105
+ found->location.start.column
105
106
  );
106
107
 
107
108
  unexpected_token_error->base.message = herb_strdup(message);
@@ -115,11 +116,11 @@ UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error_init(token_type_T expected_type
115
116
  return unexpected_token_error;
116
117
  }
117
118
 
118
- void append_unexpected_token_error(token_type_T expected_type, token_T* found, position_T* start, position_T* end, array_T* errors) {
119
+ void append_unexpected_token_error(token_type_T expected_type, token_T* found, position_T start, position_T end, array_T* errors) {
119
120
  array_append(errors, unexpected_token_error_init(expected_type, found, start, end));
120
121
  }
121
122
 
122
- MISSING_OPENING_TAG_ERROR_T* missing_opening_tag_error_init(token_T* closing_tag, position_T* start, position_T* end) {
123
+ MISSING_OPENING_TAG_ERROR_T* missing_opening_tag_error_init(token_T* closing_tag, position_T start, position_T end) {
123
124
  MISSING_OPENING_TAG_ERROR_T* missing_opening_tag_error = malloc(sizeof(MISSING_OPENING_TAG_ERROR_T));
124
125
 
125
126
  error_init(&missing_opening_tag_error->base, MISSING_OPENING_TAG_ERROR, start, end);
@@ -139,8 +140,8 @@ MISSING_OPENING_TAG_ERROR_T* missing_opening_tag_error_init(token_T* closing_tag
139
140
  message_size,
140
141
  message_template,
141
142
  truncated_argument_0,
142
- closing_tag->location->start->line,
143
- closing_tag->location->start->column
143
+ closing_tag->location.start.line,
144
+ closing_tag->location.start.column
144
145
  );
145
146
 
146
147
  missing_opening_tag_error->base.message = herb_strdup(message);
@@ -153,11 +154,11 @@ MISSING_OPENING_TAG_ERROR_T* missing_opening_tag_error_init(token_T* closing_tag
153
154
  return missing_opening_tag_error;
154
155
  }
155
156
 
156
- void append_missing_opening_tag_error(token_T* closing_tag, position_T* start, position_T* end, array_T* errors) {
157
+ void append_missing_opening_tag_error(token_T* closing_tag, position_T start, position_T end, array_T* errors) {
157
158
  array_append(errors, missing_opening_tag_error_init(closing_tag, start, end));
158
159
  }
159
160
 
160
- MISSING_CLOSING_TAG_ERROR_T* missing_closing_tag_error_init(token_T* opening_tag, position_T* start, position_T* end) {
161
+ MISSING_CLOSING_TAG_ERROR_T* missing_closing_tag_error_init(token_T* opening_tag, position_T start, position_T end) {
161
162
  MISSING_CLOSING_TAG_ERROR_T* missing_closing_tag_error = malloc(sizeof(MISSING_CLOSING_TAG_ERROR_T));
162
163
 
163
164
  error_init(&missing_closing_tag_error->base, MISSING_CLOSING_TAG_ERROR, start, end);
@@ -181,8 +182,8 @@ MISSING_CLOSING_TAG_ERROR_T* missing_closing_tag_error_init(token_T* opening_tag
181
182
  message_size,
182
183
  message_template,
183
184
  truncated_argument_0,
184
- opening_tag->location->start->line,
185
- opening_tag->location->start->column,
185
+ opening_tag->location.start.line,
186
+ opening_tag->location.start.column,
186
187
  truncated_argument_3
187
188
  );
188
189
 
@@ -196,11 +197,11 @@ MISSING_CLOSING_TAG_ERROR_T* missing_closing_tag_error_init(token_T* opening_tag
196
197
  return missing_closing_tag_error;
197
198
  }
198
199
 
199
- void append_missing_closing_tag_error(token_T* opening_tag, position_T* start, position_T* end, array_T* errors) {
200
+ void append_missing_closing_tag_error(token_T* opening_tag, position_T start, position_T end, array_T* errors) {
200
201
  array_append(errors, missing_closing_tag_error_init(opening_tag, start, end));
201
202
  }
202
203
 
203
- TAG_NAMES_MISMATCH_ERROR_T* tag_names_mismatch_error_init(token_T* opening_tag, token_T* closing_tag, position_T* start, position_T* end) {
204
+ TAG_NAMES_MISMATCH_ERROR_T* tag_names_mismatch_error_init(token_T* opening_tag, token_T* closing_tag, position_T start, position_T end) {
204
205
  TAG_NAMES_MISMATCH_ERROR_T* tag_names_mismatch_error = malloc(sizeof(TAG_NAMES_MISMATCH_ERROR_T));
205
206
 
206
207
  error_init(&tag_names_mismatch_error->base, TAG_NAMES_MISMATCH_ERROR, start, end);
@@ -224,11 +225,11 @@ TAG_NAMES_MISMATCH_ERROR_T* tag_names_mismatch_error_init(token_T* opening_tag,
224
225
  message_size,
225
226
  message_template,
226
227
  truncated_argument_0,
227
- opening_tag->location->start->line,
228
- opening_tag->location->start->column,
228
+ opening_tag->location.start.line,
229
+ opening_tag->location.start.column,
229
230
  truncated_argument_3,
230
- closing_tag->location->start->line,
231
- closing_tag->location->start->column
231
+ closing_tag->location.start.line,
232
+ closing_tag->location.start.column
232
233
  );
233
234
 
234
235
  tag_names_mismatch_error->base.message = herb_strdup(message);
@@ -242,11 +243,11 @@ TAG_NAMES_MISMATCH_ERROR_T* tag_names_mismatch_error_init(token_T* opening_tag,
242
243
  return tag_names_mismatch_error;
243
244
  }
244
245
 
245
- void append_tag_names_mismatch_error(token_T* opening_tag, token_T* closing_tag, position_T* start, position_T* end, array_T* errors) {
246
+ void append_tag_names_mismatch_error(token_T* opening_tag, token_T* closing_tag, position_T start, position_T end, array_T* errors) {
246
247
  array_append(errors, tag_names_mismatch_error_init(opening_tag, closing_tag, start, end));
247
248
  }
248
249
 
249
- QUOTES_MISMATCH_ERROR_T* quotes_mismatch_error_init(token_T* opening_quote, token_T* closing_quote, position_T* start, position_T* end) {
250
+ QUOTES_MISMATCH_ERROR_T* quotes_mismatch_error_init(token_T* opening_quote, token_T* closing_quote, position_T start, position_T end) {
250
251
  QUOTES_MISMATCH_ERROR_T* quotes_mismatch_error = malloc(sizeof(QUOTES_MISMATCH_ERROR_T));
251
252
 
252
253
  error_init(&quotes_mismatch_error->base, QUOTES_MISMATCH_ERROR, start, end);
@@ -271,8 +272,8 @@ QUOTES_MISMATCH_ERROR_T* quotes_mismatch_error_init(token_T* opening_quote, toke
271
272
  message_template,
272
273
  truncated_argument_0,
273
274
  truncated_argument_1,
274
- closing_quote->location->start->line,
275
- closing_quote->location->start->column
275
+ closing_quote->location.start.line,
276
+ closing_quote->location.start.column
276
277
  );
277
278
 
278
279
  quotes_mismatch_error->base.message = herb_strdup(message);
@@ -286,11 +287,11 @@ QUOTES_MISMATCH_ERROR_T* quotes_mismatch_error_init(token_T* opening_quote, toke
286
287
  return quotes_mismatch_error;
287
288
  }
288
289
 
289
- void append_quotes_mismatch_error(token_T* opening_quote, token_T* closing_quote, position_T* start, position_T* end, array_T* errors) {
290
+ void append_quotes_mismatch_error(token_T* opening_quote, token_T* closing_quote, position_T start, position_T end, array_T* errors) {
290
291
  array_append(errors, quotes_mismatch_error_init(opening_quote, closing_quote, start, end));
291
292
  }
292
293
 
293
- VOID_ELEMENT_CLOSING_TAG_ERROR_T* void_element_closing_tag_error_init(token_T* tag_name, const char* expected, const char* found, position_T* start, position_T* end) {
294
+ VOID_ELEMENT_CLOSING_TAG_ERROR_T* void_element_closing_tag_error_init(token_T* tag_name, const char* expected, const char* found, position_T start, position_T end) {
294
295
  VOID_ELEMENT_CLOSING_TAG_ERROR_T* void_element_closing_tag_error = malloc(sizeof(VOID_ELEMENT_CLOSING_TAG_ERROR_T));
295
296
 
296
297
  error_init(&void_element_closing_tag_error->base, VOID_ELEMENT_CLOSING_TAG_ERROR, start, end);
@@ -339,11 +340,11 @@ VOID_ELEMENT_CLOSING_TAG_ERROR_T* void_element_closing_tag_error_init(token_T* t
339
340
  return void_element_closing_tag_error;
340
341
  }
341
342
 
342
- void append_void_element_closing_tag_error(token_T* tag_name, const char* expected, const char* found, position_T* start, position_T* end, array_T* errors) {
343
+ void append_void_element_closing_tag_error(token_T* tag_name, const char* expected, const char* found, position_T start, position_T end, array_T* errors) {
343
344
  array_append(errors, void_element_closing_tag_error_init(tag_name, expected, found, start, end));
344
345
  }
345
346
 
346
- UNCLOSED_ELEMENT_ERROR_T* unclosed_element_error_init(token_T* opening_tag, position_T* start, position_T* end) {
347
+ UNCLOSED_ELEMENT_ERROR_T* unclosed_element_error_init(token_T* opening_tag, position_T start, position_T end) {
347
348
  UNCLOSED_ELEMENT_ERROR_T* unclosed_element_error = malloc(sizeof(UNCLOSED_ELEMENT_ERROR_T));
348
349
 
349
350
  error_init(&unclosed_element_error->base, UNCLOSED_ELEMENT_ERROR, start, end);
@@ -363,8 +364,8 @@ UNCLOSED_ELEMENT_ERROR_T* unclosed_element_error_init(token_T* opening_tag, posi
363
364
  message_size,
364
365
  message_template,
365
366
  truncated_argument_0,
366
- opening_tag->location->start->line,
367
- opening_tag->location->start->column
367
+ opening_tag->location.start.line,
368
+ opening_tag->location.start.column
368
369
  );
369
370
 
370
371
  unclosed_element_error->base.message = herb_strdup(message);
@@ -377,11 +378,11 @@ UNCLOSED_ELEMENT_ERROR_T* unclosed_element_error_init(token_T* opening_tag, posi
377
378
  return unclosed_element_error;
378
379
  }
379
380
 
380
- void append_unclosed_element_error(token_T* opening_tag, position_T* start, position_T* end, array_T* errors) {
381
+ void append_unclosed_element_error(token_T* opening_tag, position_T start, position_T end, array_T* errors) {
381
382
  array_append(errors, unclosed_element_error_init(opening_tag, start, end));
382
383
  }
383
384
 
384
- RUBY_PARSE_ERROR_T* ruby_parse_error_init(const char* error_message, const char* diagnostic_id, const char* level, position_T* start, position_T* end) {
385
+ RUBY_PARSE_ERROR_T* ruby_parse_error_init(const char* error_message, const char* diagnostic_id, const char* level, position_T start, position_T end) {
385
386
  RUBY_PARSE_ERROR_T* ruby_parse_error = malloc(sizeof(RUBY_PARSE_ERROR_T));
386
387
 
387
388
  error_init(&ruby_parse_error->base, RUBY_PARSE_ERROR, start, end);
@@ -420,7 +421,7 @@ RUBY_PARSE_ERROR_T* ruby_parse_error_init(const char* error_message, const char*
420
421
  return ruby_parse_error;
421
422
  }
422
423
 
423
- void append_ruby_parse_error(const char* error_message, const char* diagnostic_id, const char* level, position_T* start, position_T* end, array_T* errors) {
424
+ void append_ruby_parse_error(const char* error_message, const char* diagnostic_id, const char* level, position_T start, position_T end, array_T* errors) {
424
425
  array_append(errors, ruby_parse_error_init(error_message, diagnostic_id, level, start, end));
425
426
  }
426
427
 
@@ -459,7 +460,6 @@ const char* error_human_type(ERROR_T* error) {
459
460
  void error_free_base_error(ERROR_T* error) {
460
461
  if (error == NULL) { return; }
461
462
 
462
- if (error->location != NULL) { location_free(error->location); }
463
463
  if (error->message != NULL) { free(error->message); }
464
464
 
465
465
  free(error);
@@ -6,7 +6,7 @@
6
6
  #include "position.h"
7
7
  #include "token_struct.h"
8
8
 
9
- void ast_node_init(AST_NODE_T* node, ast_node_type_T type, position_T* start, position_T* end, array_T* errors);
9
+ void ast_node_init(AST_NODE_T* node, ast_node_type_T type, position_T start, position_T end, array_T* errors);
10
10
  void ast_node_free(AST_NODE_T* node);
11
11
 
12
12
  AST_LITERAL_NODE_T* ast_literal_node_init_from_token(const token_T* token);
@@ -18,8 +18,8 @@ ast_node_type_T ast_node_type(const AST_NODE_T* node);
18
18
 
19
19
  char* ast_node_name(AST_NODE_T* node);
20
20
 
21
- void ast_node_set_start(AST_NODE_T* node, position_T* position);
22
- void ast_node_set_end(AST_NODE_T* node, position_T* position);
21
+ void ast_node_set_start(AST_NODE_T* node, position_T position);
22
+ void ast_node_set_end(AST_NODE_T* node, position_T position);
23
23
 
24
24
  size_t ast_node_errors_count(const AST_NODE_T* node);
25
25
  array_T* ast_node_errors(const AST_NODE_T* node);
@@ -51,7 +51,7 @@ typedef enum {
51
51
 
52
52
  typedef struct AST_NODE_STRUCT {
53
53
  ast_node_type_T type;
54
- location_T* location;
54
+ location_T location;
55
55
  // maybe a range too?
56
56
  array_T* errors;
57
57
  } AST_NODE_T;
@@ -307,37 +307,37 @@ typedef struct AST_ERB_IN_NODE_STRUCT {
307
307
  array_T* statements;
308
308
  } AST_ERB_IN_NODE_T;
309
309
 
310
- AST_DOCUMENT_NODE_T* ast_document_node_init(array_T* children, position_T* start_position, position_T* end_position, array_T* errors);
311
- AST_LITERAL_NODE_T* ast_literal_node_init(const char* content, position_T* start_position, position_T* end_position, array_T* errors);
312
- AST_HTML_OPEN_TAG_NODE_T* ast_html_open_tag_node_init(token_T* tag_opening, token_T* tag_name, token_T* tag_closing, array_T* children, bool is_void, position_T* start_position, position_T* end_position, array_T* errors);
313
- AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, token_T* tag_name, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors);
314
- AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, token_T* tag_name, 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, array_T* errors);
315
- AST_HTML_ATTRIBUTE_VALUE_NODE_T* ast_html_attribute_value_node_init(token_T* open_quote, array_T* children, token_T* close_quote, bool quoted, position_T* start_position, position_T* end_position, array_T* errors);
316
- AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(array_T* children, position_T* start_position, position_T* end_position, array_T* errors);
317
- 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, array_T* errors);
318
- AST_HTML_TEXT_NODE_T* ast_html_text_node_init(const char* content, position_T* start_position, position_T* end_position, array_T* errors);
319
- AST_HTML_COMMENT_NODE_T* ast_html_comment_node_init(token_T* comment_start, array_T* children, token_T* comment_end, position_T* start_position, position_T* end_position, array_T* errors);
320
- AST_HTML_DOCTYPE_NODE_T* ast_html_doctype_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors);
321
- AST_XML_DECLARATION_NODE_T* ast_xml_declaration_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors);
322
- AST_CDATA_NODE_T* ast_cdata_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors);
323
- AST_WHITESPACE_NODE_T* ast_whitespace_node_init(token_T* value, position_T* start_position, position_T* end_position, array_T* errors);
324
- 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, array_T* errors);
325
- 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, array_T* errors);
326
- AST_ERB_ELSE_NODE_T* ast_erb_else_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T* start_position, position_T* end_position, array_T* errors);
327
- AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_NODE_STRUCT* subsequent, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors);
328
- AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* body, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors);
329
- AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T* start_position, position_T* end_position, array_T* errors);
330
- AST_ERB_CASE_NODE_T* ast_erb_case_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* children, 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, array_T* errors);
331
- AST_ERB_CASE_MATCH_NODE_T* ast_erb_case_match_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* children, 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, array_T* errors);
332
- AST_ERB_WHILE_NODE_T* ast_erb_while_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors);
333
- AST_ERB_UNTIL_NODE_T* ast_erb_until_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors);
334
- AST_ERB_FOR_NODE_T* ast_erb_for_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T* start_position, position_T* end_position, array_T* errors);
335
- AST_ERB_RESCUE_NODE_T* ast_erb_rescue_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_RESCUE_NODE_STRUCT* subsequent, position_T* start_position, position_T* end_position, array_T* errors);
336
- AST_ERB_ENSURE_NODE_T* ast_erb_ensure_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T* start_position, position_T* end_position, array_T* errors);
337
- AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, 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, array_T* errors);
338
- AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, 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, array_T* errors);
339
- 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, array_T* errors);
340
- AST_ERB_IN_NODE_T* ast_erb_in_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T* start_position, position_T* end_position, array_T* errors);
310
+ AST_DOCUMENT_NODE_T* ast_document_node_init(array_T* children, position_T start_position, position_T end_position, array_T* errors);
311
+ AST_LITERAL_NODE_T* ast_literal_node_init(const char* content, position_T start_position, position_T end_position, array_T* errors);
312
+ AST_HTML_OPEN_TAG_NODE_T* ast_html_open_tag_node_init(token_T* tag_opening, token_T* tag_name, token_T* tag_closing, array_T* children, bool is_void, position_T start_position, position_T end_position, array_T* errors);
313
+ AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, token_T* tag_name, array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, array_T* errors);
314
+ AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, token_T* tag_name, 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, array_T* errors);
315
+ AST_HTML_ATTRIBUTE_VALUE_NODE_T* ast_html_attribute_value_node_init(token_T* open_quote, array_T* children, token_T* close_quote, bool quoted, position_T start_position, position_T end_position, array_T* errors);
316
+ AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(array_T* children, position_T start_position, position_T end_position, array_T* errors);
317
+ 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, array_T* errors);
318
+ AST_HTML_TEXT_NODE_T* ast_html_text_node_init(const char* content, position_T start_position, position_T end_position, array_T* errors);
319
+ AST_HTML_COMMENT_NODE_T* ast_html_comment_node_init(token_T* comment_start, array_T* children, token_T* comment_end, position_T start_position, position_T end_position, array_T* errors);
320
+ AST_HTML_DOCTYPE_NODE_T* ast_html_doctype_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, array_T* errors);
321
+ AST_XML_DECLARATION_NODE_T* ast_xml_declaration_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, array_T* errors);
322
+ AST_CDATA_NODE_T* ast_cdata_node_init(token_T* tag_opening, array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, array_T* errors);
323
+ AST_WHITESPACE_NODE_T* ast_whitespace_node_init(token_T* value, position_T start_position, position_T end_position, array_T* errors);
324
+ 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, array_T* errors);
325
+ 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, array_T* errors);
326
+ AST_ERB_ELSE_NODE_T* ast_erb_else_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T start_position, position_T end_position, array_T* errors);
327
+ AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_NODE_STRUCT* subsequent, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, array_T* errors);
328
+ AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* body, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, array_T* errors);
329
+ AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T start_position, position_T end_position, array_T* errors);
330
+ AST_ERB_CASE_NODE_T* ast_erb_case_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* children, 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, array_T* errors);
331
+ AST_ERB_CASE_MATCH_NODE_T* ast_erb_case_match_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* children, 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, array_T* errors);
332
+ AST_ERB_WHILE_NODE_T* ast_erb_while_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, array_T* errors);
333
+ AST_ERB_UNTIL_NODE_T* ast_erb_until_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, array_T* errors);
334
+ AST_ERB_FOR_NODE_T* ast_erb_for_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, array_T* errors);
335
+ AST_ERB_RESCUE_NODE_T* ast_erb_rescue_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, struct AST_ERB_RESCUE_NODE_STRUCT* subsequent, position_T start_position, position_T end_position, array_T* errors);
336
+ AST_ERB_ENSURE_NODE_T* ast_erb_ensure_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T start_position, position_T end_position, array_T* errors);
337
+ AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, 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, array_T* errors);
338
+ AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, 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, array_T* errors);
339
+ 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, array_T* errors);
340
+ AST_ERB_IN_NODE_T* ast_erb_in_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, array_T* statements, position_T start_position, position_T end_position, array_T* errors);
341
341
 
342
342
  const char* ast_node_type_to_string(AST_NODE_T* node);
343
343
  const char* ast_node_human_type(AST_NODE_T* node);