herb 0.8.10-arm-linux-gnu → 0.9.0-arm-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 (209) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +11 -3
  3. data/README.md +64 -34
  4. data/Rakefile +48 -40
  5. data/config.yml +317 -34
  6. data/ext/herb/error_helpers.c +367 -140
  7. data/ext/herb/error_helpers.h +1 -0
  8. data/ext/herb/extconf.rb +67 -28
  9. data/ext/herb/extension.c +317 -51
  10. data/ext/herb/extension.h +1 -0
  11. data/ext/herb/extension_helpers.c +23 -14
  12. data/ext/herb/extension_helpers.h +2 -2
  13. data/ext/herb/nodes.c +537 -270
  14. data/ext/herb/nodes.h +1 -0
  15. data/herb.gemspec +3 -2
  16. data/lib/herb/3.0/herb.so +0 -0
  17. data/lib/herb/3.1/herb.so +0 -0
  18. data/lib/herb/3.2/herb.so +0 -0
  19. data/lib/herb/3.3/herb.so +0 -0
  20. data/lib/herb/3.4/herb.so +0 -0
  21. data/lib/herb/4.0/herb.so +0 -0
  22. data/lib/herb/ast/helpers.rb +3 -3
  23. data/lib/herb/ast/node.rb +15 -2
  24. data/lib/herb/ast/nodes.rb +1132 -157
  25. data/lib/herb/bootstrap.rb +87 -0
  26. data/lib/herb/cli.rb +341 -31
  27. data/lib/herb/configuration.rb +248 -0
  28. data/lib/herb/defaults.yml +32 -0
  29. data/lib/herb/engine/compiler.rb +78 -11
  30. data/lib/herb/engine/debug_visitor.rb +13 -3
  31. data/lib/herb/engine/error_formatter.rb +13 -9
  32. data/lib/herb/engine/parser_error_overlay.rb +10 -6
  33. data/lib/herb/engine/validator.rb +8 -3
  34. data/lib/herb/engine/validators/nesting_validator.rb +2 -2
  35. data/lib/herb/engine.rb +82 -35
  36. data/lib/herb/errors.rb +563 -88
  37. data/lib/herb/lex_result.rb +1 -0
  38. data/lib/herb/location.rb +7 -3
  39. data/lib/herb/parse_result.rb +12 -2
  40. data/lib/herb/parser_options.rb +57 -0
  41. data/lib/herb/position.rb +1 -0
  42. data/lib/herb/prism_inspect.rb +116 -0
  43. data/lib/herb/project.rb +923 -331
  44. data/lib/herb/range.rb +1 -0
  45. data/lib/herb/token.rb +7 -1
  46. data/lib/herb/version.rb +1 -1
  47. data/lib/herb/visitor.rb +37 -2
  48. data/lib/herb/warnings.rb +6 -1
  49. data/lib/herb.rb +35 -3
  50. data/sig/herb/ast/helpers.rbs +2 -2
  51. data/sig/herb/ast/node.rbs +12 -2
  52. data/sig/herb/ast/nodes.rbs +641 -128
  53. data/sig/herb/bootstrap.rbs +31 -0
  54. data/sig/herb/configuration.rbs +89 -0
  55. data/sig/herb/engine/compiler.rbs +9 -1
  56. data/sig/herb/engine/debug_visitor.rbs +2 -0
  57. data/sig/herb/engine/validator.rbs +5 -1
  58. data/sig/herb/engine.rbs +17 -3
  59. data/sig/herb/errors.rbs +258 -63
  60. data/sig/herb/location.rbs +4 -0
  61. data/sig/herb/parse_result.rbs +4 -2
  62. data/sig/herb/parser_options.rbs +42 -0
  63. data/sig/herb/position.rbs +1 -0
  64. data/sig/herb/prism_inspect.rbs +28 -0
  65. data/sig/herb/range.rbs +1 -0
  66. data/sig/herb/token.rbs +6 -0
  67. data/sig/herb/visitor.rbs +25 -4
  68. data/sig/herb/warnings.rbs +6 -1
  69. data/sig/herb.rbs +14 -0
  70. data/sig/herb_c_extension.rbs +5 -2
  71. data/sig/serialized_ast_errors.rbs +54 -6
  72. data/sig/serialized_ast_nodes.rbs +60 -6
  73. data/src/analyze/action_view/attribute_extraction_helpers.c +290 -0
  74. data/src/analyze/action_view/content_tag.c +70 -0
  75. data/src/analyze/action_view/link_to.c +143 -0
  76. data/src/analyze/action_view/registry.c +60 -0
  77. data/src/analyze/action_view/tag.c +64 -0
  78. data/src/analyze/action_view/tag_helper_node_builders.c +305 -0
  79. data/src/analyze/action_view/tag_helpers.c +748 -0
  80. data/src/analyze/action_view/turbo_frame_tag.c +88 -0
  81. data/src/analyze/analyze.c +882 -0
  82. data/src/{analyzed_ruby.c → analyze/analyzed_ruby.c} +13 -11
  83. data/src/analyze/builders.c +343 -0
  84. data/src/analyze/conditional_elements.c +594 -0
  85. data/src/analyze/conditional_open_tags.c +640 -0
  86. data/src/analyze/control_type.c +250 -0
  87. data/src/{analyze_helpers.c → analyze/helpers.c} +48 -23
  88. data/src/analyze/invalid_structures.c +193 -0
  89. data/src/{analyze_missing_end.c → analyze/missing_end.c} +33 -22
  90. data/src/analyze/parse_errors.c +84 -0
  91. data/src/analyze/prism_annotate.c +397 -0
  92. data/src/{analyze_transform.c → analyze/transform.c} +17 -3
  93. data/src/ast_node.c +17 -7
  94. data/src/ast_nodes.c +662 -387
  95. data/src/ast_pretty_print.c +190 -6
  96. data/src/errors.c +1076 -520
  97. data/src/extract.c +145 -49
  98. data/src/herb.c +52 -34
  99. data/src/html_util.c +241 -12
  100. data/src/include/analyze/action_view/attribute_extraction_helpers.h +36 -0
  101. data/src/include/analyze/action_view/tag_helper_handler.h +41 -0
  102. data/src/include/analyze/action_view/tag_helper_node_builders.h +70 -0
  103. data/src/include/analyze/action_view/tag_helpers.h +38 -0
  104. data/src/include/{analyze.h → analyze/analyze.h} +14 -4
  105. data/src/include/{analyzed_ruby.h → analyze/analyzed_ruby.h} +3 -3
  106. data/src/include/analyze/builders.h +27 -0
  107. data/src/include/analyze/conditional_elements.h +9 -0
  108. data/src/include/analyze/conditional_open_tags.h +9 -0
  109. data/src/include/analyze/control_type.h +14 -0
  110. data/src/include/{analyze_helpers.h → analyze/helpers.h} +4 -2
  111. data/src/include/analyze/invalid_structures.h +11 -0
  112. data/src/include/analyze/prism_annotate.h +16 -0
  113. data/src/include/ast_node.h +11 -5
  114. data/src/include/ast_nodes.h +117 -38
  115. data/src/include/ast_pretty_print.h +5 -0
  116. data/src/include/element_source.h +3 -8
  117. data/src/include/errors.h +148 -55
  118. data/src/include/extract.h +21 -5
  119. data/src/include/herb.h +18 -6
  120. data/src/include/herb_prism_node.h +13 -0
  121. data/src/include/html_util.h +7 -2
  122. data/src/include/io.h +3 -1
  123. data/src/include/lex_helpers.h +29 -0
  124. data/src/include/lexer.h +1 -1
  125. data/src/include/lexer_peek_helpers.h +87 -13
  126. data/src/include/lexer_struct.h +2 -0
  127. data/src/include/location.h +2 -1
  128. data/src/include/parser.h +27 -2
  129. data/src/include/parser_helpers.h +19 -3
  130. data/src/include/pretty_print.h +10 -5
  131. data/src/include/prism_context.h +45 -0
  132. data/src/include/prism_helpers.h +10 -7
  133. data/src/include/prism_serialized.h +12 -0
  134. data/src/include/token.h +16 -4
  135. data/src/include/token_struct.h +10 -3
  136. data/src/include/utf8.h +2 -1
  137. data/src/include/util/hb_allocator.h +78 -0
  138. data/src/include/util/hb_arena.h +6 -1
  139. data/src/include/util/hb_arena_debug.h +12 -1
  140. data/src/include/util/hb_array.h +7 -3
  141. data/src/include/util/hb_buffer.h +6 -4
  142. data/src/include/util/hb_foreach.h +79 -0
  143. data/src/include/util/hb_narray.h +8 -4
  144. data/src/include/util/hb_string.h +56 -9
  145. data/src/include/util.h +6 -3
  146. data/src/include/version.h +1 -1
  147. data/src/io.c +3 -2
  148. data/src/lexer.c +42 -30
  149. data/src/lexer_peek_helpers.c +12 -74
  150. data/src/location.c +2 -2
  151. data/src/main.c +53 -28
  152. data/src/parser.c +783 -247
  153. data/src/parser_helpers.c +110 -23
  154. data/src/parser_match_tags.c +109 -48
  155. data/src/pretty_print.c +29 -24
  156. data/src/prism_helpers.c +30 -27
  157. data/src/ruby_parser.c +2 -0
  158. data/src/token.c +151 -66
  159. data/src/token_matchers.c +0 -1
  160. data/src/utf8.c +7 -6
  161. data/src/util/hb_allocator.c +341 -0
  162. data/src/util/hb_arena.c +81 -56
  163. data/src/util/hb_arena_debug.c +32 -17
  164. data/src/util/hb_array.c +30 -15
  165. data/src/util/hb_buffer.c +17 -21
  166. data/src/util/hb_narray.c +22 -7
  167. data/src/util/hb_string.c +49 -35
  168. data/src/util.c +21 -11
  169. data/src/visitor.c +47 -0
  170. data/templates/ext/herb/error_helpers.c.erb +24 -11
  171. data/templates/ext/herb/error_helpers.h.erb +1 -0
  172. data/templates/ext/herb/nodes.c.erb +50 -16
  173. data/templates/ext/herb/nodes.h.erb +1 -0
  174. data/templates/java/error_helpers.c.erb +1 -1
  175. data/templates/java/nodes.c.erb +30 -8
  176. data/templates/java/org/herb/ast/Errors.java.erb +24 -1
  177. data/templates/java/org/herb/ast/Nodes.java.erb +80 -21
  178. data/templates/javascript/packages/core/src/errors.ts.erb +16 -3
  179. data/templates/javascript/packages/core/src/node-type-guards.ts.erb +3 -1
  180. data/templates/javascript/packages/core/src/nodes.ts.erb +109 -32
  181. data/templates/javascript/packages/node/extension/error_helpers.cpp.erb +13 -4
  182. data/templates/javascript/packages/node/extension/nodes.cpp.erb +43 -4
  183. data/templates/lib/herb/ast/nodes.rb.erb +88 -31
  184. data/templates/lib/herb/errors.rb.erb +15 -3
  185. data/templates/lib/herb/visitor.rb.erb +2 -2
  186. data/templates/rust/src/ast/nodes.rs.erb +97 -44
  187. data/templates/rust/src/errors.rs.erb +2 -1
  188. data/templates/rust/src/nodes.rs.erb +167 -15
  189. data/templates/rust/src/union_types.rs.erb +60 -0
  190. data/templates/rust/src/visitor.rs.erb +81 -0
  191. data/templates/src/{analyze_missing_end.c.erb → analyze/missing_end.c.erb} +9 -6
  192. data/templates/src/{analyze_transform.c.erb → analyze/transform.c.erb} +2 -2
  193. data/templates/src/ast_nodes.c.erb +34 -26
  194. data/templates/src/ast_pretty_print.c.erb +24 -5
  195. data/templates/src/errors.c.erb +60 -54
  196. data/templates/src/include/ast_nodes.h.erb +6 -2
  197. data/templates/src/include/ast_pretty_print.h.erb +5 -0
  198. data/templates/src/include/errors.h.erb +15 -11
  199. data/templates/src/include/util/hb_foreach.h.erb +20 -0
  200. data/templates/src/parser_match_tags.c.erb +10 -4
  201. data/templates/src/visitor.c.erb +2 -2
  202. data/templates/template.rb +204 -29
  203. data/templates/wasm/error_helpers.cpp.erb +9 -5
  204. data/templates/wasm/nodes.cpp.erb +41 -4
  205. metadata +57 -16
  206. data/src/analyze.c +0 -1608
  207. data/src/element_source.c +0 -12
  208. data/src/include/util/hb_system.h +0 -9
  209. data/src/util/hb_system.c +0 -30
@@ -7,11 +7,15 @@
7
7
  #include <stdbool.h>
8
8
  #include <prism.h>
9
9
 
10
- #include "analyzed_ruby.h"
10
+ #include "analyze/analyzed_ruby.h"
11
11
  #include "element_source.h"
12
+ #include "herb_prism_node.h"
13
+ #include "prism_context.h"
14
+ #include "prism_serialized.h"
12
15
  #include "location.h"
13
16
  #include "position.h"
14
17
  #include "token_struct.h"
18
+ #include "util/hb_allocator.h"
15
19
  #include "util/hb_array.h"
16
20
  #include "util/hb_buffer.h"
17
21
  #include "util/hb_string.h"
@@ -20,11 +24,18 @@ typedef enum {
20
24
  AST_DOCUMENT_NODE,
21
25
  AST_LITERAL_NODE,
22
26
  AST_HTML_OPEN_TAG_NODE,
27
+ AST_HTML_CONDITIONAL_OPEN_TAG_NODE,
23
28
  AST_HTML_CLOSE_TAG_NODE,
29
+ AST_HTML_OMITTED_CLOSE_TAG_NODE,
30
+ AST_HTML_VIRTUAL_CLOSE_TAG_NODE,
24
31
  AST_HTML_ELEMENT_NODE,
32
+ AST_HTML_CONDITIONAL_ELEMENT_NODE,
25
33
  AST_HTML_ATTRIBUTE_VALUE_NODE,
26
34
  AST_HTML_ATTRIBUTE_NAME_NODE,
27
35
  AST_HTML_ATTRIBUTE_NODE,
36
+ AST_RUBY_LITERAL_NODE,
37
+ AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE,
38
+ AST_ERB_OPEN_TAG_NODE,
28
39
  AST_HTML_TEXT_NODE,
29
40
  AST_HTML_COMMENT_NODE,
30
41
  AST_HTML_DOCTYPE_NODE,
@@ -61,11 +72,13 @@ typedef struct AST_NODE_STRUCT {
61
72
  typedef struct AST_DOCUMENT_NODE_STRUCT {
62
73
  AST_NODE_T base;
63
74
  hb_array_T* children;
75
+ herb_prism_context_T* prism_context;
76
+ herb_prism_node_T prism_node;
64
77
  } AST_DOCUMENT_NODE_T;
65
78
 
66
79
  typedef struct AST_LITERAL_NODE_STRUCT {
67
80
  AST_NODE_T base;
68
- const char* content;
81
+ hb_string_T content;
69
82
  } AST_LITERAL_NODE_T;
70
83
 
71
84
  typedef struct AST_HTML_OPEN_TAG_NODE_STRUCT {
@@ -77,6 +90,13 @@ typedef struct AST_HTML_OPEN_TAG_NODE_STRUCT {
77
90
  bool is_void;
78
91
  } AST_HTML_OPEN_TAG_NODE_T;
79
92
 
93
+ typedef struct AST_HTML_CONDITIONAL_OPEN_TAG_NODE_STRUCT {
94
+ AST_NODE_T base;
95
+ AST_NODE_T* conditional;
96
+ token_T* tag_name;
97
+ bool is_void;
98
+ } AST_HTML_CONDITIONAL_OPEN_TAG_NODE_T;
99
+
80
100
  typedef struct AST_HTML_CLOSE_TAG_NODE_STRUCT {
81
101
  AST_NODE_T base;
82
102
  token_T* tag_opening;
@@ -85,16 +105,38 @@ typedef struct AST_HTML_CLOSE_TAG_NODE_STRUCT {
85
105
  token_T* tag_closing;
86
106
  } AST_HTML_CLOSE_TAG_NODE_T;
87
107
 
108
+ typedef struct AST_HTML_OMITTED_CLOSE_TAG_NODE_STRUCT {
109
+ AST_NODE_T base;
110
+ token_T* tag_name;
111
+ } AST_HTML_OMITTED_CLOSE_TAG_NODE_T;
112
+
113
+ typedef struct AST_HTML_VIRTUAL_CLOSE_TAG_NODE_STRUCT {
114
+ AST_NODE_T base;
115
+ token_T* tag_name;
116
+ } AST_HTML_VIRTUAL_CLOSE_TAG_NODE_T;
117
+
88
118
  typedef struct AST_HTML_ELEMENT_NODE_STRUCT {
89
119
  AST_NODE_T base;
90
- struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag;
120
+ AST_NODE_T* open_tag;
91
121
  token_T* tag_name;
92
122
  hb_array_T* body;
93
- struct AST_HTML_CLOSE_TAG_NODE_STRUCT* close_tag;
123
+ AST_NODE_T* close_tag;
94
124
  bool is_void;
95
- element_source_t source;
125
+ hb_string_T element_source;
96
126
  } AST_HTML_ELEMENT_NODE_T;
97
127
 
128
+ typedef struct AST_HTML_CONDITIONAL_ELEMENT_NODE_STRUCT {
129
+ AST_NODE_T base;
130
+ hb_string_T condition;
131
+ AST_NODE_T* open_conditional;
132
+ struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag;
133
+ hb_array_T* body;
134
+ AST_NODE_T* close_tag;
135
+ AST_NODE_T* close_conditional;
136
+ token_T* tag_name;
137
+ hb_string_T element_source;
138
+ } AST_HTML_CONDITIONAL_ELEMENT_NODE_T;
139
+
98
140
  typedef struct AST_HTML_ATTRIBUTE_VALUE_NODE_STRUCT {
99
141
  AST_NODE_T base;
100
142
  token_T* open_quote;
@@ -115,9 +157,29 @@ typedef struct AST_HTML_ATTRIBUTE_NODE_STRUCT {
115
157
  struct AST_HTML_ATTRIBUTE_VALUE_NODE_STRUCT* value;
116
158
  } AST_HTML_ATTRIBUTE_NODE_T;
117
159
 
160
+ typedef struct AST_RUBY_LITERAL_NODE_STRUCT {
161
+ AST_NODE_T base;
162
+ hb_string_T content;
163
+ } AST_RUBY_LITERAL_NODE_T;
164
+
165
+ typedef struct AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE_STRUCT {
166
+ AST_NODE_T base;
167
+ hb_string_T content;
168
+ hb_string_T prefix;
169
+ } AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE_T;
170
+
171
+ typedef struct AST_ERB_OPEN_TAG_NODE_STRUCT {
172
+ AST_NODE_T base;
173
+ token_T* tag_opening;
174
+ token_T* content;
175
+ token_T* tag_closing;
176
+ token_T* tag_name;
177
+ hb_array_T* children;
178
+ } AST_ERB_OPEN_TAG_NODE_T;
179
+
118
180
  typedef struct AST_HTML_TEXT_NODE_STRUCT {
119
181
  AST_NODE_T base;
120
- const char* content;
182
+ hb_string_T content;
121
183
  } AST_HTML_TEXT_NODE_T;
122
184
 
123
185
  typedef struct AST_HTML_COMMENT_NODE_STRUCT {
@@ -161,6 +223,7 @@ typedef struct AST_ERB_CONTENT_NODE_STRUCT {
161
223
  analyzed_ruby_T* analyzed_ruby;
162
224
  bool parsed;
163
225
  bool valid;
226
+ herb_prism_node_T prism_node;
164
227
  } AST_ERB_CONTENT_NODE_T;
165
228
 
166
229
  typedef struct AST_ERB_END_NODE_STRUCT {
@@ -184,8 +247,9 @@ typedef struct AST_ERB_IF_NODE_STRUCT {
184
247
  token_T* content;
185
248
  token_T* tag_closing;
186
249
  location_T* then_keyword;
250
+ herb_prism_node_T prism_node;
187
251
  hb_array_T* statements;
188
- struct AST_NODE_STRUCT* subsequent;
252
+ AST_NODE_T* subsequent;
189
253
  struct AST_ERB_END_NODE_STRUCT* end_node;
190
254
  } AST_ERB_IF_NODE_T;
191
255
 
@@ -194,6 +258,7 @@ typedef struct AST_ERB_BLOCK_NODE_STRUCT {
194
258
  token_T* tag_opening;
195
259
  token_T* content;
196
260
  token_T* tag_closing;
261
+ herb_prism_node_T prism_node;
197
262
  hb_array_T* body;
198
263
  struct AST_ERB_END_NODE_STRUCT* end_node;
199
264
  } AST_ERB_BLOCK_NODE_T;
@@ -213,6 +278,7 @@ typedef struct AST_ERB_CASE_NODE_STRUCT {
213
278
  token_T* content;
214
279
  token_T* tag_closing;
215
280
  hb_array_T* children;
281
+ herb_prism_node_T prism_node;
216
282
  hb_array_T* conditions;
217
283
  struct AST_ERB_ELSE_NODE_STRUCT* else_clause;
218
284
  struct AST_ERB_END_NODE_STRUCT* end_node;
@@ -224,6 +290,7 @@ typedef struct AST_ERB_CASE_MATCH_NODE_STRUCT {
224
290
  token_T* content;
225
291
  token_T* tag_closing;
226
292
  hb_array_T* children;
293
+ herb_prism_node_T prism_node;
227
294
  hb_array_T* conditions;
228
295
  struct AST_ERB_ELSE_NODE_STRUCT* else_clause;
229
296
  struct AST_ERB_END_NODE_STRUCT* end_node;
@@ -234,6 +301,7 @@ typedef struct AST_ERB_WHILE_NODE_STRUCT {
234
301
  token_T* tag_opening;
235
302
  token_T* content;
236
303
  token_T* tag_closing;
304
+ herb_prism_node_T prism_node;
237
305
  hb_array_T* statements;
238
306
  struct AST_ERB_END_NODE_STRUCT* end_node;
239
307
  } AST_ERB_WHILE_NODE_T;
@@ -243,6 +311,7 @@ typedef struct AST_ERB_UNTIL_NODE_STRUCT {
243
311
  token_T* tag_opening;
244
312
  token_T* content;
245
313
  token_T* tag_closing;
314
+ herb_prism_node_T prism_node;
246
315
  hb_array_T* statements;
247
316
  struct AST_ERB_END_NODE_STRUCT* end_node;
248
317
  } AST_ERB_UNTIL_NODE_T;
@@ -252,6 +321,7 @@ typedef struct AST_ERB_FOR_NODE_STRUCT {
252
321
  token_T* tag_opening;
253
322
  token_T* content;
254
323
  token_T* tag_closing;
324
+ herb_prism_node_T prism_node;
255
325
  hb_array_T* statements;
256
326
  struct AST_ERB_END_NODE_STRUCT* end_node;
257
327
  } AST_ERB_FOR_NODE_T;
@@ -278,6 +348,7 @@ typedef struct AST_ERB_BEGIN_NODE_STRUCT {
278
348
  token_T* tag_opening;
279
349
  token_T* content;
280
350
  token_T* tag_closing;
351
+ herb_prism_node_T prism_node;
281
352
  hb_array_T* statements;
282
353
  struct AST_ERB_RESCUE_NODE_STRUCT* rescue_clause;
283
354
  struct AST_ERB_ELSE_NODE_STRUCT* else_clause;
@@ -291,6 +362,7 @@ typedef struct AST_ERB_UNLESS_NODE_STRUCT {
291
362
  token_T* content;
292
363
  token_T* tag_closing;
293
364
  location_T* then_keyword;
365
+ herb_prism_node_T prism_node;
294
366
  hb_array_T* statements;
295
367
  struct AST_ERB_ELSE_NODE_STRUCT* else_clause;
296
368
  struct AST_ERB_END_NODE_STRUCT* end_node;
@@ -312,37 +384,44 @@ typedef struct AST_ERB_IN_NODE_STRUCT {
312
384
  hb_array_T* statements;
313
385
  } AST_ERB_IN_NODE_T;
314
386
 
315
- AST_DOCUMENT_NODE_T* ast_document_node_init(hb_array_T* children, position_T start_position, position_T end_position, hb_array_T* errors);
316
- AST_LITERAL_NODE_T* ast_literal_node_init(const char* content, position_T start_position, position_T end_position, hb_array_T* errors);
317
- 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);
318
- 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);
319
- 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);
320
- 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);
321
- 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);
322
- 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);
323
- 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);
324
- 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);
325
- 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);
326
- 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);
327
- 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);
328
- AST_WHITESPACE_NODE_T* ast_whitespace_node_init(token_T* value, position_T start_position, position_T end_position, hb_array_T* errors);
329
- 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);
330
- 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);
331
- 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);
332
- AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, hb_array_T* statements, struct AST_NODE_STRUCT* subsequent, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors);
333
- 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);
334
- AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors);
335
- 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);
336
- 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);
337
- 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);
338
- 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);
339
- 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);
340
- 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);
341
- 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);
342
- 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);
343
- AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, hb_array_T* statements, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors);
344
- 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);
345
- AST_ERB_IN_NODE_T* ast_erb_in_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors);
387
+ AST_DOCUMENT_NODE_T* ast_document_node_init(hb_array_T* children, herb_prism_context_T* prism_context, herb_prism_node_T prism_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
388
+ AST_LITERAL_NODE_T* ast_literal_node_init(hb_string_T content, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
389
+ AST_HTML_OPEN_TAG_NODE_T* ast_html_open_tag_node_init(token_T* tag_opening, token_T* tag_name, token_T* tag_closing, hb_array_T* children, bool is_void, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
390
+ AST_HTML_CONDITIONAL_OPEN_TAG_NODE_T* ast_html_conditional_open_tag_node_init(AST_NODE_T* conditional, token_T* tag_name, bool is_void, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
391
+ AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, token_T* tag_name, hb_array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
392
+ AST_HTML_OMITTED_CLOSE_TAG_NODE_T* ast_html_omitted_close_tag_node_init(token_T* tag_name, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
393
+ AST_HTML_VIRTUAL_CLOSE_TAG_NODE_T* ast_html_virtual_close_tag_node_init(token_T* tag_name, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
394
+ AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(AST_NODE_T* open_tag, token_T* tag_name, hb_array_T* body, AST_NODE_T* close_tag, bool is_void, hb_string_T element_source, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
395
+ AST_HTML_CONDITIONAL_ELEMENT_NODE_T* ast_html_conditional_element_node_init(hb_string_T condition, AST_NODE_T* open_conditional, struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, hb_array_T* body, AST_NODE_T* close_tag, AST_NODE_T* close_conditional, token_T* tag_name, hb_string_T element_source, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
396
+ AST_HTML_ATTRIBUTE_VALUE_NODE_T* ast_html_attribute_value_node_init(token_T* open_quote, hb_array_T* children, token_T* close_quote, bool quoted, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
397
+ AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(hb_array_T* children, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
398
+ AST_HTML_ATTRIBUTE_NODE_T* ast_html_attribute_node_init(struct AST_HTML_ATTRIBUTE_NAME_NODE_STRUCT* name, token_T* equals, struct AST_HTML_ATTRIBUTE_VALUE_NODE_STRUCT* value, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
399
+ AST_RUBY_LITERAL_NODE_T* ast_ruby_literal_node_init(hb_string_T content, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
400
+ AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE_T* ast_ruby_html_attributes_splat_node_init(hb_string_T content, hb_string_T prefix, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
401
+ AST_ERB_OPEN_TAG_NODE_T* ast_erb_open_tag_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, token_T* tag_name, hb_array_T* children, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
402
+ AST_HTML_TEXT_NODE_T* ast_html_text_node_init(hb_string_T content, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
403
+ AST_HTML_COMMENT_NODE_T* ast_html_comment_node_init(token_T* comment_start, hb_array_T* children, token_T* comment_end, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
404
+ AST_HTML_DOCTYPE_NODE_T* ast_html_doctype_node_init(token_T* tag_opening, hb_array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
405
+ AST_XML_DECLARATION_NODE_T* ast_xml_declaration_node_init(token_T* tag_opening, hb_array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
406
+ AST_CDATA_NODE_T* ast_cdata_node_init(token_T* tag_opening, hb_array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
407
+ AST_WHITESPACE_NODE_T* ast_whitespace_node_init(token_T* value, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
408
+ AST_ERB_CONTENT_NODE_T* ast_erb_content_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, analyzed_ruby_T* analyzed_ruby, bool parsed, bool valid, herb_prism_node_T prism_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
409
+ AST_ERB_END_NODE_T* ast_erb_end_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
410
+ AST_ERB_ELSE_NODE_T* ast_erb_else_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
411
+ AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, herb_prism_node_T prism_node, hb_array_T* statements, AST_NODE_T* subsequent, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
412
+ AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, herb_prism_node_T prism_node, hb_array_T* body, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
413
+ AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
414
+ AST_ERB_CASE_NODE_T* ast_erb_case_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* children, herb_prism_node_T prism_node, hb_array_T* conditions, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
415
+ AST_ERB_CASE_MATCH_NODE_T* ast_erb_case_match_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* children, herb_prism_node_T prism_node, hb_array_T* conditions, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
416
+ AST_ERB_WHILE_NODE_T* ast_erb_while_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, herb_prism_node_T prism_node, hb_array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
417
+ AST_ERB_UNTIL_NODE_T* ast_erb_until_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, herb_prism_node_T prism_node, hb_array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
418
+ AST_ERB_FOR_NODE_T* ast_erb_for_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, herb_prism_node_T prism_node, hb_array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
419
+ AST_ERB_RESCUE_NODE_T* ast_erb_rescue_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, struct AST_ERB_RESCUE_NODE_STRUCT* subsequent, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
420
+ AST_ERB_ENSURE_NODE_T* ast_erb_ensure_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
421
+ AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, herb_prism_node_T prism_node, hb_array_T* statements, struct AST_ERB_RESCUE_NODE_STRUCT* rescue_clause, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_ENSURE_NODE_STRUCT* ensure_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
422
+ AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, herb_prism_node_T prism_node, hb_array_T* statements, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
423
+ AST_ERB_YIELD_NODE_T* ast_erb_yield_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
424
+ AST_ERB_IN_NODE_T* ast_erb_in_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
346
425
 
347
426
  hb_string_T ast_node_type_to_string(AST_NODE_T* node);
348
427
  hb_string_T ast_node_human_type(AST_NODE_T* node);
@@ -4,6 +4,10 @@
4
4
  #ifndef HERB_AST_PRETTY_PRINT_H
5
5
  #define HERB_AST_PRETTY_PRINT_H
6
6
 
7
+ #ifdef HERB_EXCLUDE_PRETTYPRINT
8
+ // Pretty print support excluded
9
+ #else
10
+
7
11
  #include "ast_nodes.h"
8
12
  #include "util/hb_buffer.h"
9
13
 
@@ -15,3 +19,4 @@ void ast_pretty_print_node(
15
19
  );
16
20
 
17
21
  #endif
22
+ #endif
@@ -3,13 +3,8 @@
3
3
 
4
4
  #include "util/hb_string.h"
5
5
 
6
- typedef enum {
7
- ELEMENT_SOURCE_HTML,
8
- ELEMENT_SOURCE_ACTIONVIEW,
9
- ELEMENT_SOURCE_HAML,
10
- ELEMENT_SOURCE_SLIM
11
- } element_source_t;
12
-
13
- hb_string_T element_source_to_string(element_source_t source);
6
+ #define ELEMENT_SOURCE_HTML hb_string("HTML")
7
+ #define ELEMENT_SOURCE_HAML hb_string("Haml")
8
+ #define ELEMENT_SOURCE_SLIM hb_string("Slim")
14
9
 
15
10
  #endif
data/src/include/errors.h CHANGED
@@ -8,8 +8,10 @@
8
8
  #include "location.h"
9
9
  #include "position.h"
10
10
  #include "token.h"
11
+ #include "util/hb_allocator.h"
11
12
  #include "util/hb_array.h"
12
13
  #include "util/hb_buffer.h"
14
+ #include "util/hb_string.h"
13
15
 
14
16
  typedef enum {
15
17
  UNEXPECTED_ERROR,
@@ -17,28 +19,38 @@ typedef enum {
17
19
  MISSING_OPENING_TAG_ERROR,
18
20
  MISSING_CLOSING_TAG_ERROR,
19
21
  TAG_NAMES_MISMATCH_ERROR,
20
- QUOTES_MISMATCH_ERROR,
21
22
  VOID_ELEMENT_CLOSING_TAG_ERROR,
22
23
  UNCLOSED_ELEMENT_ERROR,
23
24
  RUBY_PARSE_ERROR,
24
25
  ERB_CONTROL_FLOW_SCOPE_ERROR,
25
- MISSINGERB_END_TAG_ERROR,
26
+ MISSING_ERB_END_TAG_ERROR,
26
27
  ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR,
27
28
  ERB_CASE_WITH_CONDITIONS_ERROR,
29
+ CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR,
30
+ CONDITIONAL_ELEMENT_CONDITION_MISMATCH_ERROR,
31
+ INVALID_COMMENT_CLOSING_TAG_ERROR,
32
+ OMITTED_CLOSING_TAG_ERROR,
33
+ UNCLOSED_OPEN_TAG_ERROR,
34
+ UNCLOSED_CLOSE_TAG_ERROR,
35
+ UNCLOSED_QUOTE_ERROR,
36
+ MISSING_ATTRIBUTE_VALUE_ERROR,
37
+ UNCLOSED_ERB_TAG_ERROR,
38
+ STRAY_ERB_CLOSING_TAG_ERROR,
39
+ NESTED_ERB_TAG_ERROR,
28
40
  } error_type_T;
29
41
 
30
42
  typedef struct ERROR_STRUCT {
31
43
  error_type_T type;
32
44
  location_T location;
33
- char* message;
45
+ hb_string_T message;
34
46
  } ERROR_T;
35
47
 
36
48
 
37
49
  typedef struct {
38
50
  ERROR_T base;
39
- const char* description;
40
- const char* expected;
41
- const char* found;
51
+ hb_string_T description;
52
+ hb_string_T expected;
53
+ hb_string_T found;
42
54
  } UNEXPECTED_ERROR_T;
43
55
 
44
56
  typedef struct {
@@ -63,17 +75,11 @@ typedef struct {
63
75
  token_T* closing_tag;
64
76
  } TAG_NAMES_MISMATCH_ERROR_T;
65
77
 
66
- typedef struct {
67
- ERROR_T base;
68
- token_T* opening_quote;
69
- token_T* closing_quote;
70
- } QUOTES_MISMATCH_ERROR_T;
71
-
72
78
  typedef struct {
73
79
  ERROR_T base;
74
80
  token_T* tag_name;
75
- const char* expected;
76
- const char* found;
81
+ hb_string_T expected;
82
+ hb_string_T found;
77
83
  } VOID_ELEMENT_CLOSING_TAG_ERROR_T;
78
84
 
79
85
  typedef struct {
@@ -83,20 +89,20 @@ typedef struct {
83
89
 
84
90
  typedef struct {
85
91
  ERROR_T base;
86
- const char* error_message;
87
- const char* diagnostic_id;
88
- const char* level;
92
+ hb_string_T error_message;
93
+ hb_string_T diagnostic_id;
94
+ hb_string_T level;
89
95
  } RUBY_PARSE_ERROR_T;
90
96
 
91
97
  typedef struct {
92
98
  ERROR_T base;
93
- const char* keyword;
99
+ hb_string_T keyword;
94
100
  } ERB_CONTROL_FLOW_SCOPE_ERROR_T;
95
101
 
96
102
  typedef struct {
97
103
  ERROR_T base;
98
- const char* keyword;
99
- } MISSINGERB_END_TAG_ERROR_T;
104
+ hb_string_T keyword;
105
+ } MISSING_ERB_END_TAG_ERROR_T;
100
106
 
101
107
  typedef struct {
102
108
  ERROR_T base;
@@ -108,50 +114,137 @@ typedef struct {
108
114
  /* no additional fields */
109
115
  } ERB_CASE_WITH_CONDITIONS_ERROR_T;
110
116
 
111
- UNEXPECTED_ERROR_T* unexpected_error_init(const char* description, const char* expected, const char* found, position_T start, position_T end);
112
- void append_unexpected_error(const char* description, const char* expected, const char* found, position_T start, position_T end, hb_array_T* errors);
113
- UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error_init(token_type_T expected_type, token_T* found, position_T start, position_T end);
114
- void append_unexpected_token_error(token_type_T expected_type, token_T* found, position_T start, position_T end, hb_array_T* errors);
115
- MISSING_OPENING_TAG_ERROR_T* missing_opening_tag_error_init(token_T* closing_tag, position_T start, position_T end);
116
- void append_missing_opening_tag_error(token_T* closing_tag, position_T start, position_T end, hb_array_T* errors);
117
- MISSING_CLOSING_TAG_ERROR_T* missing_closing_tag_error_init(token_T* opening_tag, position_T start, position_T end);
118
- void append_missing_closing_tag_error(token_T* opening_tag, position_T start, position_T end, hb_array_T* errors);
119
- TAG_NAMES_MISMATCH_ERROR_T* tag_names_mismatch_error_init(token_T* opening_tag, token_T* closing_tag, position_T start, position_T end);
120
- void append_tag_names_mismatch_error(token_T* opening_tag, token_T* closing_tag, position_T start, position_T end, hb_array_T* errors);
121
- QUOTES_MISMATCH_ERROR_T* quotes_mismatch_error_init(token_T* opening_quote, token_T* closing_quote, position_T start, position_T end);
122
- void append_quotes_mismatch_error(token_T* opening_quote, token_T* closing_quote, position_T start, position_T end, hb_array_T* errors);
123
- 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);
124
- 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);
125
- UNCLOSED_ELEMENT_ERROR_T* unclosed_element_error_init(token_T* opening_tag, position_T start, position_T end);
126
- void append_unclosed_element_error(token_T* opening_tag, position_T start, position_T end, hb_array_T* errors);
127
- 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);
128
- 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);
129
- ERB_CONTROL_FLOW_SCOPE_ERROR_T* erb_control_flow_scope_error_init(const char* keyword, position_T start, position_T end);
130
- void append_erb_control_flow_scope_error(const char* keyword, position_T start, position_T end, hb_array_T* errors);
131
- MISSINGERB_END_TAG_ERROR_T* missingerb_end_tag_error_init(const char* keyword, position_T start, position_T end);
132
- void append_missingerb_end_tag_error(const char* keyword, position_T start, position_T end, hb_array_T* errors);
133
- ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR_T* erb_multiple_blocks_in_tag_error_init(position_T start, position_T end);
134
- void append_erb_multiple_blocks_in_tag_error(position_T start, position_T end, hb_array_T* errors);
135
- ERB_CASE_WITH_CONDITIONS_ERROR_T* erb_case_with_conditions_error_init(position_T start, position_T end);
136
- void append_erb_case_with_conditions_error(position_T start, position_T end, hb_array_T* errors);
117
+ typedef struct {
118
+ ERROR_T base;
119
+ size_t line;
120
+ size_t column;
121
+ } CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR_T;
122
+
123
+ typedef struct {
124
+ ERROR_T base;
125
+ hb_string_T tag_name;
126
+ hb_string_T open_condition;
127
+ size_t open_line;
128
+ size_t open_column;
129
+ hb_string_T close_condition;
130
+ size_t close_line;
131
+ size_t close_column;
132
+ } CONDITIONAL_ELEMENT_CONDITION_MISMATCH_ERROR_T;
133
+
134
+ typedef struct {
135
+ ERROR_T base;
136
+ token_T* closing_tag;
137
+ } INVALID_COMMENT_CLOSING_TAG_ERROR_T;
138
+
139
+ typedef struct {
140
+ ERROR_T base;
141
+ token_T* opening_tag;
142
+ position_T insertion_point;
143
+ } OMITTED_CLOSING_TAG_ERROR_T;
144
+
145
+ typedef struct {
146
+ ERROR_T base;
147
+ token_T* tag_name;
148
+ } UNCLOSED_OPEN_TAG_ERROR_T;
149
+
150
+ typedef struct {
151
+ ERROR_T base;
152
+ token_T* tag_name;
153
+ } UNCLOSED_CLOSE_TAG_ERROR_T;
154
+
155
+ typedef struct {
156
+ ERROR_T base;
157
+ token_T* opening_quote;
158
+ } UNCLOSED_QUOTE_ERROR_T;
159
+
160
+ typedef struct {
161
+ ERROR_T base;
162
+ hb_string_T attribute_name;
163
+ } MISSING_ATTRIBUTE_VALUE_ERROR_T;
164
+
165
+ typedef struct {
166
+ ERROR_T base;
167
+ token_T* opening_tag;
168
+ } UNCLOSED_ERB_TAG_ERROR_T;
169
+
170
+ typedef struct {
171
+ ERROR_T base;
172
+ /* no additional fields */
173
+ } STRAY_ERB_CLOSING_TAG_ERROR_T;
174
+
175
+ typedef struct {
176
+ ERROR_T base;
177
+ token_T* opening_tag;
178
+ size_t nested_tag_line;
179
+ size_t nested_tag_column;
180
+ } NESTED_ERB_TAG_ERROR_T;
181
+
182
+ UNEXPECTED_ERROR_T* unexpected_error_init(hb_string_T description, hb_string_T expected, hb_string_T found, position_T start, position_T end, hb_allocator_T* allocator);
183
+ void append_unexpected_error(hb_string_T description, hb_string_T expected, hb_string_T found, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
184
+ UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error_init(token_type_T expected_type, token_T* found, position_T start, position_T end, hb_allocator_T* allocator);
185
+ void append_unexpected_token_error(token_type_T expected_type, token_T* found, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
186
+ MISSING_OPENING_TAG_ERROR_T* missing_opening_tag_error_init(token_T* closing_tag, position_T start, position_T end, hb_allocator_T* allocator);
187
+ void append_missing_opening_tag_error(token_T* closing_tag, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
188
+ MISSING_CLOSING_TAG_ERROR_T* missing_closing_tag_error_init(token_T* opening_tag, position_T start, position_T end, hb_allocator_T* allocator);
189
+ void append_missing_closing_tag_error(token_T* opening_tag, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
190
+ TAG_NAMES_MISMATCH_ERROR_T* tag_names_mismatch_error_init(token_T* opening_tag, token_T* closing_tag, position_T start, position_T end, hb_allocator_T* allocator);
191
+ void append_tag_names_mismatch_error(token_T* opening_tag, token_T* closing_tag, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
192
+ VOID_ELEMENT_CLOSING_TAG_ERROR_T* void_element_closing_tag_error_init(token_T* tag_name, hb_string_T expected, hb_string_T found, position_T start, position_T end, hb_allocator_T* allocator);
193
+ void append_void_element_closing_tag_error(token_T* tag_name, hb_string_T expected, hb_string_T found, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
194
+ UNCLOSED_ELEMENT_ERROR_T* unclosed_element_error_init(token_T* opening_tag, position_T start, position_T end, hb_allocator_T* allocator);
195
+ void append_unclosed_element_error(token_T* opening_tag, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
196
+ RUBY_PARSE_ERROR_T* ruby_parse_error_init(hb_string_T error_message, hb_string_T diagnostic_id, hb_string_T level, position_T start, position_T end, hb_allocator_T* allocator);
197
+ void append_ruby_parse_error(hb_string_T error_message, hb_string_T diagnostic_id, hb_string_T level, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
198
+ ERB_CONTROL_FLOW_SCOPE_ERROR_T* erb_control_flow_scope_error_init(hb_string_T keyword, position_T start, position_T end, hb_allocator_T* allocator);
199
+ void append_erb_control_flow_scope_error(hb_string_T keyword, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
200
+ MISSING_ERB_END_TAG_ERROR_T* missing_erb_end_tag_error_init(hb_string_T keyword, position_T start, position_T end, hb_allocator_T* allocator);
201
+ void append_missing_erb_end_tag_error(hb_string_T keyword, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
202
+ ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR_T* erb_multiple_blocks_in_tag_error_init(position_T start, position_T end, hb_allocator_T* allocator);
203
+ void append_erb_multiple_blocks_in_tag_error(position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
204
+ ERB_CASE_WITH_CONDITIONS_ERROR_T* erb_case_with_conditions_error_init(position_T start, position_T end, hb_allocator_T* allocator);
205
+ void append_erb_case_with_conditions_error(position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
206
+ CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR_T* conditional_element_multiple_tags_error_init(size_t line, size_t column, position_T start, position_T end, hb_allocator_T* allocator);
207
+ void append_conditional_element_multiple_tags_error(size_t line, size_t column, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
208
+ CONDITIONAL_ELEMENT_CONDITION_MISMATCH_ERROR_T* conditional_element_condition_mismatch_error_init(hb_string_T tag_name, hb_string_T open_condition, size_t open_line, size_t open_column, hb_string_T close_condition, size_t close_line, size_t close_column, position_T start, position_T end, hb_allocator_T* allocator);
209
+ void append_conditional_element_condition_mismatch_error(hb_string_T tag_name, hb_string_T open_condition, size_t open_line, size_t open_column, hb_string_T close_condition, size_t close_line, size_t close_column, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
210
+ INVALID_COMMENT_CLOSING_TAG_ERROR_T* invalid_comment_closing_tag_error_init(token_T* closing_tag, position_T start, position_T end, hb_allocator_T* allocator);
211
+ void append_invalid_comment_closing_tag_error(token_T* closing_tag, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
212
+ OMITTED_CLOSING_TAG_ERROR_T* omitted_closing_tag_error_init(token_T* opening_tag, position_T insertion_point, position_T start, position_T end, hb_allocator_T* allocator);
213
+ void append_omitted_closing_tag_error(token_T* opening_tag, position_T insertion_point, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
214
+ UNCLOSED_OPEN_TAG_ERROR_T* unclosed_open_tag_error_init(token_T* tag_name, position_T start, position_T end, hb_allocator_T* allocator);
215
+ void append_unclosed_open_tag_error(token_T* tag_name, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
216
+ UNCLOSED_CLOSE_TAG_ERROR_T* unclosed_close_tag_error_init(token_T* tag_name, position_T start, position_T end, hb_allocator_T* allocator);
217
+ void append_unclosed_close_tag_error(token_T* tag_name, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
218
+ UNCLOSED_QUOTE_ERROR_T* unclosed_quote_error_init(token_T* opening_quote, position_T start, position_T end, hb_allocator_T* allocator);
219
+ void append_unclosed_quote_error(token_T* opening_quote, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
220
+ MISSING_ATTRIBUTE_VALUE_ERROR_T* missing_attribute_value_error_init(hb_string_T attribute_name, position_T start, position_T end, hb_allocator_T* allocator);
221
+ void append_missing_attribute_value_error(hb_string_T attribute_name, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
222
+ UNCLOSED_ERB_TAG_ERROR_T* unclosed_erb_tag_error_init(token_T* opening_tag, position_T start, position_T end, hb_allocator_T* allocator);
223
+ void append_unclosed_erb_tag_error(token_T* opening_tag, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
224
+ STRAY_ERB_CLOSING_TAG_ERROR_T* stray_erb_closing_tag_error_init(position_T start, position_T end, hb_allocator_T* allocator);
225
+ void append_stray_erb_closing_tag_error(position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
226
+ NESTED_ERB_TAG_ERROR_T* nested_erb_tag_error_init(token_T* opening_tag, size_t nested_tag_line, size_t nested_tag_column, position_T start, position_T end, hb_allocator_T* allocator);
227
+ void append_nested_erb_tag_error(token_T* opening_tag, size_t nested_tag_line, size_t nested_tag_column, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
137
228
 
138
229
  void error_init(ERROR_T* error, error_type_T type, position_T start, position_T end);
139
230
 
140
231
  size_t error_sizeof(void);
141
232
  error_type_T error_type(ERROR_T* error);
142
233
 
143
- char* error_message(ERROR_T* error);
234
+ hb_string_T error_message(ERROR_T* error);
144
235
 
145
- const char* error_type_to_string(ERROR_T* error);
146
- const char* error_human_type(ERROR_T* error);
236
+ hb_string_T error_type_to_string(ERROR_T* error);
237
+ hb_string_T error_human_type(ERROR_T* error);
147
238
 
148
- void error_free(ERROR_T* error);
239
+ void error_free(ERROR_T* error, hb_allocator_T* allocator);
149
240
 
150
- void error_pretty_print(ERROR_T* error, size_t indent, size_t relative_indent, hb_buffer_T* buffer);
241
+ #ifndef HERB_EXCLUDE_PRETTYPRINT
242
+ void error_pretty_print(ERROR_T* error, size_t indent, size_t relative_indent, hb_buffer_T* buffer);
151
243
 
152
- void error_pretty_print_array(
153
- const char* name, hb_array_T* array, size_t indent, size_t relative_indent, bool last_property,
154
- hb_buffer_T* buffer
155
- );
244
+ void error_pretty_print_array(
245
+ const char* name, hb_array_T* array, size_t indent, size_t relative_indent, bool last_property,
246
+ hb_buffer_T* buffer
247
+ );
248
+ #endif
156
249
 
157
250
  #endif