herb 0.7.4-aarch64-linux-gnu → 0.8.0-aarch64-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 (176) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +8 -5
  3. data/config.yml +40 -20
  4. data/ext/herb/error_helpers.c +57 -3
  5. data/ext/herb/error_helpers.h +1 -1
  6. data/ext/herb/extconf.rb +1 -0
  7. data/ext/herb/extension.c +10 -24
  8. data/ext/herb/extension_helpers.c +12 -18
  9. data/ext/herb/extension_helpers.h +4 -4
  10. data/ext/herb/nodes.c +72 -37
  11. data/herb.gemspec +0 -2
  12. data/lib/herb/3.0/herb.so +0 -0
  13. data/lib/herb/3.1/herb.so +0 -0
  14. data/lib/herb/3.2/herb.so +0 -0
  15. data/lib/herb/3.3/herb.so +0 -0
  16. data/lib/herb/3.4/herb.so +0 -0
  17. data/lib/herb/ast/helpers.rb +11 -0
  18. data/lib/herb/ast/node.rb +15 -6
  19. data/lib/herb/ast/nodes.rb +609 -392
  20. data/lib/herb/cli.rb +31 -0
  21. data/lib/herb/colors.rb +82 -0
  22. data/lib/herb/engine/compiler.rb +140 -14
  23. data/lib/herb/engine/debug_visitor.rb +1 -5
  24. data/lib/herb/engine/parser_error_overlay.rb +1 -1
  25. data/lib/herb/engine.rb +18 -20
  26. data/lib/herb/errors.rb +166 -56
  27. data/lib/herb/location.rb +2 -2
  28. data/lib/herb/project.rb +86 -21
  29. data/lib/herb/token.rb +14 -2
  30. data/lib/herb/version.rb +1 -1
  31. data/lib/herb.rb +1 -0
  32. data/sig/herb/ast/helpers.rbs +3 -0
  33. data/sig/herb/ast/node.rbs +12 -5
  34. data/sig/herb/ast/nodes.rbs +124 -62
  35. data/sig/herb/colors.rbs +35 -0
  36. data/sig/herb/engine/compiler.rbs +23 -1
  37. data/sig/herb/errors.rbs +74 -20
  38. data/sig/herb/token.rbs +8 -0
  39. data/sig/herb_c_extension.rbs +1 -1
  40. data/sig/serialized_ast_errors.rbs +8 -0
  41. data/src/analyze.c +461 -249
  42. data/src/analyze_helpers.c +5 -0
  43. data/src/analyze_missing_end.c +147 -0
  44. data/src/analyze_transform.c +196 -0
  45. data/src/analyzed_ruby.c +23 -2
  46. data/src/ast_node.c +14 -17
  47. data/src/ast_nodes.c +179 -181
  48. data/src/ast_pretty_print.c +232 -232
  49. data/src/element_source.c +7 -6
  50. data/src/errors.c +272 -152
  51. data/src/extract.c +92 -34
  52. data/src/herb.c +37 -49
  53. data/src/html_util.c +34 -96
  54. data/src/include/analyze.h +10 -2
  55. data/src/include/analyze_helpers.h +3 -0
  56. data/src/include/analyzed_ruby.h +4 -2
  57. data/src/include/ast_node.h +4 -4
  58. data/src/include/ast_nodes.h +68 -67
  59. data/src/include/ast_pretty_print.h +2 -2
  60. data/src/include/element_source.h +3 -1
  61. data/src/include/errors.h +42 -26
  62. data/src/include/extract.h +4 -4
  63. data/src/include/herb.h +6 -7
  64. data/src/include/html_util.h +4 -5
  65. data/src/include/lexer.h +1 -3
  66. data/src/include/lexer_peek_helpers.h +21 -19
  67. data/src/include/lexer_struct.h +12 -10
  68. data/src/include/location.h +10 -13
  69. data/src/include/macros.h +4 -0
  70. data/src/include/parser.h +12 -6
  71. data/src/include/parser_helpers.h +26 -16
  72. data/src/include/position.h +3 -14
  73. data/src/include/pretty_print.h +38 -28
  74. data/src/include/prism_helpers.h +1 -1
  75. data/src/include/range.h +4 -13
  76. data/src/include/token.h +5 -11
  77. data/src/include/token_struct.h +2 -2
  78. data/src/include/utf8.h +3 -2
  79. data/src/include/util/hb_arena.h +31 -0
  80. data/src/include/util/hb_arena_debug.h +8 -0
  81. data/src/include/util/hb_array.h +33 -0
  82. data/src/include/util/hb_buffer.h +34 -0
  83. data/src/include/util/hb_string.h +29 -0
  84. data/src/include/util/hb_system.h +9 -0
  85. data/src/include/util.h +3 -14
  86. data/src/include/version.h +1 -1
  87. data/src/include/visitor.h +1 -1
  88. data/src/io.c +7 -4
  89. data/src/lexer.c +62 -88
  90. data/src/lexer_peek_helpers.c +42 -38
  91. data/src/location.c +9 -37
  92. data/src/main.c +19 -23
  93. data/src/parser.c +373 -313
  94. data/src/parser_helpers.c +60 -54
  95. data/src/parser_match_tags.c +316 -0
  96. data/src/pretty_print.c +88 -117
  97. data/src/prism_helpers.c +7 -7
  98. data/src/range.c +2 -35
  99. data/src/token.c +36 -87
  100. data/src/utf8.c +4 -4
  101. data/src/util/hb_arena.c +179 -0
  102. data/src/util/hb_arena_debug.c +237 -0
  103. data/src/{array.c → util/hb_array.c} +26 -27
  104. data/src/util/hb_buffer.c +203 -0
  105. data/src/util/hb_string.c +85 -0
  106. data/src/util/hb_system.c +30 -0
  107. data/src/util.c +29 -99
  108. data/src/visitor.c +54 -54
  109. data/templates/ext/herb/error_helpers.c.erb +3 -3
  110. data/templates/ext/herb/error_helpers.h.erb +1 -1
  111. data/templates/ext/herb/nodes.c.erb +11 -6
  112. data/templates/java/error_helpers.c.erb +75 -0
  113. data/templates/java/error_helpers.h.erb +20 -0
  114. data/templates/java/nodes.c.erb +97 -0
  115. data/templates/java/nodes.h.erb +23 -0
  116. data/templates/java/org/herb/ast/Errors.java.erb +121 -0
  117. data/templates/java/org/herb/ast/NodeVisitor.java.erb +14 -0
  118. data/templates/java/org/herb/ast/Nodes.java.erb +220 -0
  119. data/templates/java/org/herb/ast/Visitor.java.erb +56 -0
  120. data/templates/javascript/packages/core/src/visitor.ts.erb +29 -1
  121. data/templates/javascript/packages/node/extension/error_helpers.cpp.erb +8 -8
  122. data/templates/javascript/packages/node/extension/error_helpers.h.erb +1 -1
  123. data/templates/javascript/packages/node/extension/nodes.cpp.erb +9 -9
  124. data/templates/javascript/packages/node/extension/nodes.h.erb +1 -1
  125. data/templates/lib/herb/ast/nodes.rb.erb +28 -16
  126. data/templates/lib/herb/errors.rb.erb +17 -12
  127. data/templates/rust/src/ast/nodes.rs.erb +220 -0
  128. data/templates/rust/src/errors.rs.erb +216 -0
  129. data/templates/rust/src/nodes.rs.erb +374 -0
  130. data/templates/src/analyze_missing_end.c.erb +36 -0
  131. data/templates/src/analyze_transform.c.erb +24 -0
  132. data/templates/src/ast_nodes.c.erb +14 -16
  133. data/templates/src/ast_pretty_print.c.erb +36 -36
  134. data/templates/src/errors.c.erb +36 -38
  135. data/templates/src/include/ast_nodes.h.erb +11 -10
  136. data/templates/src/include/ast_pretty_print.h.erb +2 -2
  137. data/templates/src/include/errors.h.erb +9 -9
  138. data/templates/src/parser_match_tags.c.erb +38 -0
  139. data/templates/src/visitor.c.erb +4 -4
  140. data/templates/template.rb +22 -3
  141. data/templates/wasm/error_helpers.cpp.erb +9 -9
  142. data/templates/wasm/error_helpers.h.erb +1 -1
  143. data/templates/wasm/nodes.cpp.erb +9 -9
  144. data/templates/wasm/nodes.h.erb +1 -1
  145. data/vendor/prism/Rakefile +4 -1
  146. data/vendor/prism/config.yml +2 -1
  147. data/vendor/prism/include/prism/ast.h +31 -1
  148. data/vendor/prism/include/prism/diagnostic.h +1 -0
  149. data/vendor/prism/include/prism/version.h +3 -3
  150. data/vendor/prism/src/diagnostic.c +3 -1
  151. data/vendor/prism/src/prism.c +130 -71
  152. data/vendor/prism/src/util/pm_string.c +6 -8
  153. data/vendor/prism/templates/include/prism/ast.h.erb +2 -0
  154. data/vendor/prism/templates/java/org/prism/Loader.java.erb +2 -2
  155. data/vendor/prism/templates/javascript/src/deserialize.js.erb +2 -2
  156. data/vendor/prism/templates/lib/prism/serialize.rb.erb +2 -2
  157. data/vendor/prism/templates/sig/prism.rbs.erb +4 -0
  158. data/vendor/prism/templates/src/diagnostic.c.erb +1 -0
  159. metadata +34 -21
  160. data/lib/herb/libherb/array.rb +0 -51
  161. data/lib/herb/libherb/ast_node.rb +0 -50
  162. data/lib/herb/libherb/buffer.rb +0 -56
  163. data/lib/herb/libherb/extract_result.rb +0 -20
  164. data/lib/herb/libherb/lex_result.rb +0 -32
  165. data/lib/herb/libherb/libherb.rb +0 -52
  166. data/lib/herb/libherb/parse_result.rb +0 -20
  167. data/lib/herb/libherb/token.rb +0 -46
  168. data/lib/herb/libherb.rb +0 -35
  169. data/src/buffer.c +0 -232
  170. data/src/include/array.h +0 -33
  171. data/src/include/buffer.h +0 -39
  172. data/src/include/json.h +0 -28
  173. data/src/include/memory.h +0 -12
  174. data/src/json.c +0 -205
  175. data/src/memory.c +0 -53
  176. data/src/position.c +0 -33
@@ -7,13 +7,14 @@
7
7
  #include <stdbool.h>
8
8
  #include <prism.h>
9
9
 
10
- #include "array.h"
11
- #include "buffer.h"
12
- #include "position.h"
13
- #include "location.h"
14
- #include "token_struct.h"
15
10
  #include "analyzed_ruby.h"
16
11
  #include "element_source.h"
12
+ #include "location.h"
13
+ #include "position.h"
14
+ #include "token_struct.h"
15
+ #include "util/hb_array.h"
16
+ #include "util/hb_buffer.h"
17
+ #include "util/hb_string.h"
17
18
 
18
19
  typedef enum {
19
20
  AST_DOCUMENT_NODE,
@@ -51,15 +52,15 @@ typedef enum {
51
52
 
52
53
  typedef struct AST_NODE_STRUCT {
53
54
  ast_node_type_T type;
54
- location_T* location;
55
+ location_T location;
55
56
  // maybe a range too?
56
- array_T* errors;
57
+ hb_array_T* errors;
57
58
  } AST_NODE_T;
58
59
 
59
60
 
60
61
  typedef struct AST_DOCUMENT_NODE_STRUCT {
61
62
  AST_NODE_T base;
62
- array_T* children;
63
+ hb_array_T* children;
63
64
  } AST_DOCUMENT_NODE_T;
64
65
 
65
66
  typedef struct AST_LITERAL_NODE_STRUCT {
@@ -72,7 +73,7 @@ typedef struct AST_HTML_OPEN_TAG_NODE_STRUCT {
72
73
  token_T* tag_opening;
73
74
  token_T* tag_name;
74
75
  token_T* tag_closing;
75
- array_T* children;
76
+ hb_array_T* children;
76
77
  bool is_void;
77
78
  } AST_HTML_OPEN_TAG_NODE_T;
78
79
 
@@ -80,7 +81,7 @@ typedef struct AST_HTML_CLOSE_TAG_NODE_STRUCT {
80
81
  AST_NODE_T base;
81
82
  token_T* tag_opening;
82
83
  token_T* tag_name;
83
- array_T* children;
84
+ hb_array_T* children;
84
85
  token_T* tag_closing;
85
86
  } AST_HTML_CLOSE_TAG_NODE_T;
86
87
 
@@ -88,7 +89,7 @@ typedef struct AST_HTML_ELEMENT_NODE_STRUCT {
88
89
  AST_NODE_T base;
89
90
  struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag;
90
91
  token_T* tag_name;
91
- array_T* body;
92
+ hb_array_T* body;
92
93
  struct AST_HTML_CLOSE_TAG_NODE_STRUCT* close_tag;
93
94
  bool is_void;
94
95
  element_source_t source;
@@ -97,14 +98,14 @@ typedef struct AST_HTML_ELEMENT_NODE_STRUCT {
97
98
  typedef struct AST_HTML_ATTRIBUTE_VALUE_NODE_STRUCT {
98
99
  AST_NODE_T base;
99
100
  token_T* open_quote;
100
- array_T* children;
101
+ hb_array_T* children;
101
102
  token_T* close_quote;
102
103
  bool quoted;
103
104
  } AST_HTML_ATTRIBUTE_VALUE_NODE_T;
104
105
 
105
106
  typedef struct AST_HTML_ATTRIBUTE_NAME_NODE_STRUCT {
106
107
  AST_NODE_T base;
107
- array_T* children;
108
+ hb_array_T* children;
108
109
  } AST_HTML_ATTRIBUTE_NAME_NODE_T;
109
110
 
110
111
  typedef struct AST_HTML_ATTRIBUTE_NODE_STRUCT {
@@ -122,28 +123,28 @@ typedef struct AST_HTML_TEXT_NODE_STRUCT {
122
123
  typedef struct AST_HTML_COMMENT_NODE_STRUCT {
123
124
  AST_NODE_T base;
124
125
  token_T* comment_start;
125
- array_T* children;
126
+ hb_array_T* children;
126
127
  token_T* comment_end;
127
128
  } AST_HTML_COMMENT_NODE_T;
128
129
 
129
130
  typedef struct AST_HTML_DOCTYPE_NODE_STRUCT {
130
131
  AST_NODE_T base;
131
132
  token_T* tag_opening;
132
- array_T* children;
133
+ hb_array_T* children;
133
134
  token_T* tag_closing;
134
135
  } AST_HTML_DOCTYPE_NODE_T;
135
136
 
136
137
  typedef struct AST_XML_DECLARATION_NODE_STRUCT {
137
138
  AST_NODE_T base;
138
139
  token_T* tag_opening;
139
- array_T* children;
140
+ hb_array_T* children;
140
141
  token_T* tag_closing;
141
142
  } AST_XML_DECLARATION_NODE_T;
142
143
 
143
144
  typedef struct AST_CDATA_NODE_STRUCT {
144
145
  AST_NODE_T base;
145
146
  token_T* tag_opening;
146
- array_T* children;
147
+ hb_array_T* children;
147
148
  token_T* tag_closing;
148
149
  } AST_CDATA_NODE_T;
149
150
 
@@ -174,7 +175,7 @@ typedef struct AST_ERB_ELSE_NODE_STRUCT {
174
175
  token_T* tag_opening;
175
176
  token_T* content;
176
177
  token_T* tag_closing;
177
- array_T* statements;
178
+ hb_array_T* statements;
178
179
  } AST_ERB_ELSE_NODE_T;
179
180
 
180
181
  typedef struct AST_ERB_IF_NODE_STRUCT {
@@ -182,7 +183,7 @@ typedef struct AST_ERB_IF_NODE_STRUCT {
182
183
  token_T* tag_opening;
183
184
  token_T* content;
184
185
  token_T* tag_closing;
185
- array_T* statements;
186
+ hb_array_T* statements;
186
187
  struct AST_NODE_STRUCT* subsequent;
187
188
  struct AST_ERB_END_NODE_STRUCT* end_node;
188
189
  } AST_ERB_IF_NODE_T;
@@ -192,7 +193,7 @@ typedef struct AST_ERB_BLOCK_NODE_STRUCT {
192
193
  token_T* tag_opening;
193
194
  token_T* content;
194
195
  token_T* tag_closing;
195
- array_T* body;
196
+ hb_array_T* body;
196
197
  struct AST_ERB_END_NODE_STRUCT* end_node;
197
198
  } AST_ERB_BLOCK_NODE_T;
198
199
 
@@ -201,7 +202,7 @@ typedef struct AST_ERB_WHEN_NODE_STRUCT {
201
202
  token_T* tag_opening;
202
203
  token_T* content;
203
204
  token_T* tag_closing;
204
- array_T* statements;
205
+ hb_array_T* statements;
205
206
  } AST_ERB_WHEN_NODE_T;
206
207
 
207
208
  typedef struct AST_ERB_CASE_NODE_STRUCT {
@@ -209,8 +210,8 @@ typedef struct AST_ERB_CASE_NODE_STRUCT {
209
210
  token_T* tag_opening;
210
211
  token_T* content;
211
212
  token_T* tag_closing;
212
- array_T* children;
213
- array_T* conditions;
213
+ hb_array_T* children;
214
+ hb_array_T* conditions;
214
215
  struct AST_ERB_ELSE_NODE_STRUCT* else_clause;
215
216
  struct AST_ERB_END_NODE_STRUCT* end_node;
216
217
  } AST_ERB_CASE_NODE_T;
@@ -220,8 +221,8 @@ typedef struct AST_ERB_CASE_MATCH_NODE_STRUCT {
220
221
  token_T* tag_opening;
221
222
  token_T* content;
222
223
  token_T* tag_closing;
223
- array_T* children;
224
- array_T* conditions;
224
+ hb_array_T* children;
225
+ hb_array_T* conditions;
225
226
  struct AST_ERB_ELSE_NODE_STRUCT* else_clause;
226
227
  struct AST_ERB_END_NODE_STRUCT* end_node;
227
228
  } AST_ERB_CASE_MATCH_NODE_T;
@@ -231,7 +232,7 @@ typedef struct AST_ERB_WHILE_NODE_STRUCT {
231
232
  token_T* tag_opening;
232
233
  token_T* content;
233
234
  token_T* tag_closing;
234
- array_T* statements;
235
+ hb_array_T* statements;
235
236
  struct AST_ERB_END_NODE_STRUCT* end_node;
236
237
  } AST_ERB_WHILE_NODE_T;
237
238
 
@@ -240,7 +241,7 @@ typedef struct AST_ERB_UNTIL_NODE_STRUCT {
240
241
  token_T* tag_opening;
241
242
  token_T* content;
242
243
  token_T* tag_closing;
243
- array_T* statements;
244
+ hb_array_T* statements;
244
245
  struct AST_ERB_END_NODE_STRUCT* end_node;
245
246
  } AST_ERB_UNTIL_NODE_T;
246
247
 
@@ -249,7 +250,7 @@ typedef struct AST_ERB_FOR_NODE_STRUCT {
249
250
  token_T* tag_opening;
250
251
  token_T* content;
251
252
  token_T* tag_closing;
252
- array_T* statements;
253
+ hb_array_T* statements;
253
254
  struct AST_ERB_END_NODE_STRUCT* end_node;
254
255
  } AST_ERB_FOR_NODE_T;
255
256
 
@@ -258,7 +259,7 @@ typedef struct AST_ERB_RESCUE_NODE_STRUCT {
258
259
  token_T* tag_opening;
259
260
  token_T* content;
260
261
  token_T* tag_closing;
261
- array_T* statements;
262
+ hb_array_T* statements;
262
263
  struct AST_ERB_RESCUE_NODE_STRUCT* subsequent;
263
264
  } AST_ERB_RESCUE_NODE_T;
264
265
 
@@ -267,7 +268,7 @@ typedef struct AST_ERB_ENSURE_NODE_STRUCT {
267
268
  token_T* tag_opening;
268
269
  token_T* content;
269
270
  token_T* tag_closing;
270
- array_T* statements;
271
+ hb_array_T* statements;
271
272
  } AST_ERB_ENSURE_NODE_T;
272
273
 
273
274
  typedef struct AST_ERB_BEGIN_NODE_STRUCT {
@@ -275,7 +276,7 @@ typedef struct AST_ERB_BEGIN_NODE_STRUCT {
275
276
  token_T* tag_opening;
276
277
  token_T* content;
277
278
  token_T* tag_closing;
278
- array_T* statements;
279
+ hb_array_T* statements;
279
280
  struct AST_ERB_RESCUE_NODE_STRUCT* rescue_clause;
280
281
  struct AST_ERB_ELSE_NODE_STRUCT* else_clause;
281
282
  struct AST_ERB_ENSURE_NODE_STRUCT* ensure_clause;
@@ -287,7 +288,7 @@ typedef struct AST_ERB_UNLESS_NODE_STRUCT {
287
288
  token_T* tag_opening;
288
289
  token_T* content;
289
290
  token_T* tag_closing;
290
- array_T* statements;
291
+ hb_array_T* statements;
291
292
  struct AST_ERB_ELSE_NODE_STRUCT* else_clause;
292
293
  struct AST_ERB_END_NODE_STRUCT* end_node;
293
294
  } AST_ERB_UNLESS_NODE_T;
@@ -304,42 +305,42 @@ typedef struct AST_ERB_IN_NODE_STRUCT {
304
305
  token_T* tag_opening;
305
306
  token_T* content;
306
307
  token_T* tag_closing;
307
- array_T* statements;
308
+ hb_array_T* statements;
308
309
  } AST_ERB_IN_NODE_T;
309
310
 
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
-
342
- const char* ast_node_type_to_string(AST_NODE_T* node);
343
- const char* ast_node_human_type(AST_NODE_T* node);
311
+ AST_DOCUMENT_NODE_T* ast_document_node_init(hb_array_T* children, position_T start_position, position_T end_position, hb_array_T* errors);
312
+ AST_LITERAL_NODE_T* ast_literal_node_init(const char* content, position_T start_position, position_T end_position, hb_array_T* errors);
313
+ 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);
314
+ 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);
315
+ 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);
316
+ 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);
317
+ 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);
318
+ 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);
319
+ 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);
320
+ 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);
321
+ 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);
322
+ 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);
323
+ 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);
324
+ AST_WHITESPACE_NODE_T* ast_whitespace_node_init(token_T* value, position_T start_position, position_T end_position, hb_array_T* errors);
325
+ 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);
326
+ 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);
327
+ 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);
328
+ AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, struct AST_NODE_STRUCT* subsequent, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors);
329
+ 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);
330
+ AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors);
331
+ 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);
332
+ 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);
333
+ 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);
334
+ 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);
335
+ 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);
336
+ 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);
337
+ 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);
338
+ 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);
339
+ AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors);
340
+ 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);
341
+ AST_ERB_IN_NODE_T* ast_erb_in_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors);
342
+
343
+ hb_string_T ast_node_type_to_string(AST_NODE_T* node);
344
+ hb_string_T ast_node_human_type(AST_NODE_T* node);
344
345
 
345
346
  #endif
@@ -5,13 +5,13 @@
5
5
  #define HERB_AST_PRETTY_PRINT_H
6
6
 
7
7
  #include "ast_nodes.h"
8
- #include "buffer.h"
8
+ #include "util/hb_buffer.h"
9
9
 
10
10
  void ast_pretty_print_node(
11
11
  AST_NODE_T* node,
12
12
  size_t indent,
13
13
  size_t relative_indent,
14
- buffer_T* buffer
14
+ hb_buffer_T* buffer
15
15
  );
16
16
 
17
17
  #endif
@@ -1,6 +1,8 @@
1
1
  #ifndef HERB_ELEMENT_SOURCE_H
2
2
  #define HERB_ELEMENT_SOURCE_H
3
3
 
4
+ #include "util/hb_string.h"
5
+
4
6
  typedef enum {
5
7
  ELEMENT_SOURCE_HTML,
6
8
  ELEMENT_SOURCE_ACTIONVIEW,
@@ -8,6 +10,6 @@ typedef enum {
8
10
  ELEMENT_SOURCE_SLIM
9
11
  } element_source_t;
10
12
 
11
- const char* element_source_to_string(element_source_t source);
13
+ hb_string_T element_source_to_string(element_source_t source);
12
14
 
13
15
  #endif
data/src/include/errors.h CHANGED
@@ -4,12 +4,12 @@
4
4
  #ifndef HERB_ERRORS_H
5
5
  #define HERB_ERRORS_H
6
6
 
7
- #include "array.h"
8
- #include "buffer.h"
9
7
  #include "errors.h"
10
8
  #include "location.h"
11
9
  #include "position.h"
12
10
  #include "token.h"
11
+ #include "util/hb_array.h"
12
+ #include "util/hb_buffer.h"
13
13
 
14
14
  typedef enum {
15
15
  UNEXPECTED_ERROR,
@@ -21,11 +21,13 @@ typedef enum {
21
21
  VOID_ELEMENT_CLOSING_TAG_ERROR,
22
22
  UNCLOSED_ELEMENT_ERROR,
23
23
  RUBY_PARSE_ERROR,
24
+ ERB_CONTROL_FLOW_SCOPE_ERROR,
25
+ MISSINGERB_END_TAG_ERROR,
24
26
  } error_type_T;
25
27
 
26
28
  typedef struct ERROR_STRUCT {
27
29
  error_type_T type;
28
- location_T* location;
30
+ location_T location;
29
31
  char* message;
30
32
  } ERROR_T;
31
33
 
@@ -84,26 +86,40 @@ typedef struct {
84
86
  const char* level;
85
87
  } RUBY_PARSE_ERROR_T;
86
88
 
87
- UNEXPECTED_ERROR_T* unexpected_error_init(const char* description, const char* expected, const char* found, position_T* start, position_T* end);
88
- void append_unexpected_error(const char* description, const char* expected, const char* found, position_T* start, position_T* end, array_T* errors);
89
- UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error_init(token_type_T expected_type, token_T* found, position_T* start, position_T* end);
90
- void append_unexpected_token_error(token_type_T expected_type, token_T* found, position_T* start, position_T* end, array_T* errors);
91
- MISSING_OPENING_TAG_ERROR_T* missing_opening_tag_error_init(token_T* closing_tag, position_T* start, position_T* end);
92
- void append_missing_opening_tag_error(token_T* closing_tag, position_T* start, position_T* end, array_T* errors);
93
- MISSING_CLOSING_TAG_ERROR_T* missing_closing_tag_error_init(token_T* opening_tag, position_T* start, position_T* end);
94
- void append_missing_closing_tag_error(token_T* opening_tag, position_T* start, position_T* end, array_T* errors);
95
- TAG_NAMES_MISMATCH_ERROR_T* tag_names_mismatch_error_init(token_T* opening_tag, token_T* closing_tag, position_T* start, position_T* end);
96
- void append_tag_names_mismatch_error(token_T* opening_tag, token_T* closing_tag, position_T* start, position_T* end, array_T* errors);
97
- QUOTES_MISMATCH_ERROR_T* quotes_mismatch_error_init(token_T* opening_quote, token_T* closing_quote, position_T* start, position_T* end);
98
- void append_quotes_mismatch_error(token_T* opening_quote, token_T* closing_quote, position_T* start, position_T* end, array_T* errors);
99
- 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);
100
- 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);
101
- UNCLOSED_ELEMENT_ERROR_T* unclosed_element_error_init(token_T* opening_tag, position_T* start, position_T* end);
102
- void append_unclosed_element_error(token_T* opening_tag, position_T* start, position_T* end, array_T* errors);
103
- 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);
104
- 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);
105
-
106
- void error_init(ERROR_T* error, error_type_T type, position_T* start, position_T* end);
89
+ typedef struct {
90
+ ERROR_T base;
91
+ const char* keyword;
92
+ } ERB_CONTROL_FLOW_SCOPE_ERROR_T;
93
+
94
+ typedef struct {
95
+ ERROR_T base;
96
+ const char* keyword;
97
+ } MISSINGERB_END_TAG_ERROR_T;
98
+
99
+ UNEXPECTED_ERROR_T* unexpected_error_init(const char* description, const char* expected, const char* found, position_T start, position_T end);
100
+ void append_unexpected_error(const char* description, const char* expected, const char* found, position_T start, position_T end, hb_array_T* errors);
101
+ UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error_init(token_type_T expected_type, token_T* found, position_T start, position_T end);
102
+ void append_unexpected_token_error(token_type_T expected_type, token_T* found, position_T start, position_T end, hb_array_T* errors);
103
+ MISSING_OPENING_TAG_ERROR_T* missing_opening_tag_error_init(token_T* closing_tag, position_T start, position_T end);
104
+ void append_missing_opening_tag_error(token_T* closing_tag, position_T start, position_T end, hb_array_T* errors);
105
+ MISSING_CLOSING_TAG_ERROR_T* missing_closing_tag_error_init(token_T* opening_tag, position_T start, position_T end);
106
+ void append_missing_closing_tag_error(token_T* opening_tag, position_T start, position_T end, hb_array_T* errors);
107
+ TAG_NAMES_MISMATCH_ERROR_T* tag_names_mismatch_error_init(token_T* opening_tag, token_T* closing_tag, position_T start, position_T end);
108
+ void append_tag_names_mismatch_error(token_T* opening_tag, token_T* closing_tag, position_T start, position_T end, hb_array_T* errors);
109
+ QUOTES_MISMATCH_ERROR_T* quotes_mismatch_error_init(token_T* opening_quote, token_T* closing_quote, position_T start, position_T end);
110
+ void append_quotes_mismatch_error(token_T* opening_quote, token_T* closing_quote, position_T start, position_T end, hb_array_T* errors);
111
+ 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);
112
+ void append_void_element_closing_tag_error(token_T* tag_name, const char* expected, const char* found, position_T start, position_T end, hb_array_T* errors);
113
+ UNCLOSED_ELEMENT_ERROR_T* unclosed_element_error_init(token_T* opening_tag, position_T start, position_T end);
114
+ void append_unclosed_element_error(token_T* opening_tag, position_T start, position_T end, hb_array_T* errors);
115
+ 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);
116
+ void append_ruby_parse_error(const char* error_message, const char* diagnostic_id, const char* level, position_T start, position_T end, hb_array_T* errors);
117
+ ERB_CONTROL_FLOW_SCOPE_ERROR_T* erb_control_flow_scope_error_init(const char* keyword, position_T start, position_T end);
118
+ void append_erb_control_flow_scope_error(const char* keyword, position_T start, position_T end, hb_array_T* errors);
119
+ MISSINGERB_END_TAG_ERROR_T* missingerb_end_tag_error_init(const char* keyword, position_T start, position_T end);
120
+ void append_missingerb_end_tag_error(const char* keyword, position_T start, position_T end, hb_array_T* errors);
121
+
122
+ void error_init(ERROR_T* error, error_type_T type, position_T start, position_T end);
107
123
 
108
124
  size_t error_sizeof(void);
109
125
  error_type_T error_type(ERROR_T* error);
@@ -115,11 +131,11 @@ const char* error_human_type(ERROR_T* error);
115
131
 
116
132
  void error_free(ERROR_T* error);
117
133
 
118
- void error_pretty_print(ERROR_T* error, size_t indent, size_t relative_indent, buffer_T* buffer);
134
+ void error_pretty_print(ERROR_T* error, size_t indent, size_t relative_indent, hb_buffer_T* buffer);
119
135
 
120
136
  void error_pretty_print_array(
121
- const char* name, array_T* array, size_t indent, size_t relative_indent, bool last_property,
122
- buffer_T* buffer
137
+ const char* name, hb_array_T* array, size_t indent, size_t relative_indent, bool last_property,
138
+ hb_buffer_T* buffer
123
139
  );
124
140
 
125
141
  #endif
@@ -1,18 +1,18 @@
1
1
  #ifndef HERB_EXTRACT_H
2
2
  #define HERB_EXTRACT_H
3
3
 
4
- #include "buffer.h"
4
+ #include "util/hb_buffer.h"
5
5
 
6
6
  typedef enum {
7
7
  HERB_EXTRACT_LANGUAGE_RUBY,
8
8
  HERB_EXTRACT_LANGUAGE_HTML,
9
9
  } herb_extract_language_T;
10
10
 
11
- void herb_extract_ruby_to_buffer(const char* source, buffer_T* output);
12
- void herb_extract_html_to_buffer(const char* source, buffer_T* output);
11
+ void herb_extract_ruby_to_buffer(const char* source, hb_buffer_T* output);
12
+ void herb_extract_html_to_buffer(const char* source, hb_buffer_T* output);
13
13
 
14
14
  char* herb_extract_ruby_with_semicolons(const char* source);
15
- void herb_extract_ruby_to_buffer_with_semicolons(const char* source, buffer_T* output);
15
+ void herb_extract_ruby_to_buffer_with_semicolons(const char* source, hb_buffer_T* output);
16
16
 
17
17
  char* herb_extract(const char* source, herb_extract_language_T language);
18
18
  char* herb_extract_from_file(const char* path, herb_extract_language_T language);
data/src/include/herb.h CHANGED
@@ -1,11 +1,11 @@
1
1
  #ifndef HERB_H
2
2
  #define HERB_H
3
3
 
4
- #include "array.h"
5
4
  #include "ast_node.h"
6
- #include "buffer.h"
7
5
  #include "extract.h"
8
6
  #include "parser.h"
7
+ #include "util/hb_array.h"
8
+ #include "util/hb_buffer.h"
9
9
 
10
10
  #include <stdint.h>
11
11
 
@@ -13,18 +13,17 @@
13
13
  extern "C" {
14
14
  #endif
15
15
 
16
- void herb_lex_to_buffer(const char* source, buffer_T* output);
17
- void herb_lex_json_to_buffer(const char* source, buffer_T* output);
16
+ void herb_lex_to_buffer(const char* source, hb_buffer_T* output);
18
17
 
19
- array_T* herb_lex(const char* source);
20
- array_T* herb_lex_file(const char* path);
18
+ hb_array_T* herb_lex(const char* source);
19
+ hb_array_T* herb_lex_file(const char* path);
21
20
 
22
21
  AST_DOCUMENT_NODE_T* herb_parse(const char* source, parser_options_T* options);
23
22
 
24
23
  const char* herb_version(void);
25
24
  const char* herb_prism_version(void);
26
25
 
27
- void herb_free_tokens(array_T** tokens);
26
+ void herb_free_tokens(hb_array_T** tokens);
28
27
 
29
28
  #ifdef __cplusplus
30
29
  }
@@ -1,13 +1,12 @@
1
1
  #ifndef HERB_HTML_UTIL_H
2
2
  #define HERB_HTML_UTIL_H
3
3
 
4
+ #include "util/hb_string.h"
4
5
  #include <stdbool.h>
5
6
 
6
- bool is_void_element(const char* tag_name);
7
- bool is_html4_void_element(const char* tag_name);
7
+ bool is_void_element(hb_string_T tag_name);
8
8
 
9
- char* html_opening_tag_string(const char* tag_name);
10
- char* html_closing_tag_string(const char* tag_name);
11
- char* html_self_closing_tag_string(const char* tag_name);
9
+ hb_string_T html_closing_tag_string(hb_string_T tag_name);
10
+ hb_string_T html_self_closing_tag_string(hb_string_T tag_name);
12
11
 
13
12
  #endif
data/src/include/lexer.h CHANGED
@@ -4,10 +4,8 @@
4
4
  #include "lexer_struct.h"
5
5
  #include "token_struct.h"
6
6
 
7
- lexer_T* lexer_init(const char* source);
7
+ void lexer_init(lexer_T* lexer, const char* source);
8
8
  token_T* lexer_next_token(lexer_T* lexer);
9
9
  token_T* lexer_error(lexer_T* lexer, const char* message);
10
10
 
11
- void lexer_free(lexer_T* lexer);
12
-
13
11
  #endif
@@ -5,38 +5,40 @@
5
5
  #include "token_struct.h"
6
6
 
7
7
  #include <stdbool.h>
8
+ #include <stdint.h>
8
9
  #include <stdio.h>
9
10
  #include <stdlib.h>
10
11
 
11
12
  typedef struct {
12
- size_t position;
13
- size_t line;
14
- size_t column;
15
- size_t previous_position;
16
- size_t previous_line;
17
- size_t previous_column;
13
+ uint32_t position;
14
+ uint32_t line;
15
+ uint32_t column;
16
+ uint32_t previous_position;
17
+ uint32_t previous_line;
18
+ uint32_t previous_column;
18
19
  char current_character;
19
20
  lexer_state_T state;
20
21
  } lexer_state_snapshot_T;
21
22
 
22
- char lexer_peek(const lexer_T* lexer, int offset);
23
- bool lexer_peek_for_doctype(const lexer_T* lexer, int offset);
24
- bool lexer_peek_for_xml_declaration(const lexer_T* lexer, int offset);
25
- bool lexer_peek_for_cdata_start(const lexer_T* lexer, int offset);
26
- bool lexer_peek_for_cdata_end(const lexer_T* lexer, int offset);
23
+ char lexer_peek(const lexer_T* lexer, uint32_t offset);
24
+ bool lexer_peek_for_doctype(const lexer_T* lexer, uint32_t offset);
25
+ bool lexer_peek_for_xml_declaration(const lexer_T* lexer, uint32_t offset);
26
+ bool lexer_peek_for_cdata_start(const lexer_T* lexer, uint32_t offset);
27
+ bool lexer_peek_for_cdata_end(const lexer_T* lexer, uint32_t offset);
27
28
 
28
- bool lexer_peek_for_html_comment_start(const lexer_T* lexer, int offset);
29
- bool lexer_peek_for_html_comment_end(const lexer_T* lexer, int offset);
29
+ bool lexer_peek_for_html_comment_start(const lexer_T* lexer, uint32_t offset);
30
+ bool lexer_peek_for_html_comment_end(const lexer_T* lexer, uint32_t offset);
30
31
 
31
- bool lexer_peek_erb_close_tag(const lexer_T* lexer, int offset);
32
- bool lexer_peek_erb_dash_close_tag(const lexer_T* lexer, int offset);
33
- bool lexer_peek_erb_percent_close_tag(const lexer_T* lexer, int offset);
34
- bool lexer_peek_erb_end(const lexer_T* lexer, int offset);
32
+ bool lexer_peek_erb_close_tag(const lexer_T* lexer, uint32_t offset);
33
+ bool lexer_peek_erb_dash_close_tag(const lexer_T* lexer, uint32_t offset);
34
+ bool lexer_peek_erb_percent_close_tag(const lexer_T* lexer, uint32_t offset);
35
+ bool lexer_peek_erb_equals_close_tag(const lexer_T* lexer, uint32_t offset);
36
+ bool lexer_peek_erb_end(const lexer_T* lexer, uint32_t offset);
35
37
 
36
- char lexer_backtrack(const lexer_T* lexer, int offset);
38
+ char lexer_backtrack(const lexer_T* lexer, uint32_t offset);
37
39
 
38
40
  bool lexer_peek_for_token_type_after_whitespace(lexer_T* lexer, token_type_T token_type);
39
- bool lexer_peek_for_close_tag_start(const lexer_T* lexer, int offset);
41
+ bool lexer_peek_for_close_tag_start(const lexer_T* lexer, uint32_t offset);
40
42
 
41
43
  lexer_state_snapshot_T lexer_save_state(lexer_T* lexer);
42
44
  void lexer_restore_state(lexer_T* lexer, lexer_state_snapshot_T snapshot);