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.
- checksums.yaml +4 -4
- data/Makefile +8 -5
- data/config.yml +40 -20
- data/ext/herb/error_helpers.c +57 -3
- data/ext/herb/error_helpers.h +1 -1
- data/ext/herb/extconf.rb +1 -0
- data/ext/herb/extension.c +10 -24
- data/ext/herb/extension_helpers.c +12 -18
- data/ext/herb/extension_helpers.h +4 -4
- data/ext/herb/nodes.c +72 -37
- data/herb.gemspec +0 -2
- data/lib/herb/3.0/herb.so +0 -0
- data/lib/herb/3.1/herb.so +0 -0
- data/lib/herb/3.2/herb.so +0 -0
- data/lib/herb/3.3/herb.so +0 -0
- data/lib/herb/3.4/herb.so +0 -0
- data/lib/herb/ast/helpers.rb +11 -0
- data/lib/herb/ast/node.rb +15 -6
- data/lib/herb/ast/nodes.rb +609 -392
- data/lib/herb/cli.rb +31 -0
- data/lib/herb/colors.rb +82 -0
- data/lib/herb/engine/compiler.rb +140 -14
- data/lib/herb/engine/debug_visitor.rb +1 -5
- data/lib/herb/engine/parser_error_overlay.rb +1 -1
- data/lib/herb/engine.rb +18 -20
- data/lib/herb/errors.rb +166 -56
- data/lib/herb/location.rb +2 -2
- data/lib/herb/project.rb +86 -21
- data/lib/herb/token.rb +14 -2
- data/lib/herb/version.rb +1 -1
- data/lib/herb.rb +1 -0
- data/sig/herb/ast/helpers.rbs +3 -0
- data/sig/herb/ast/node.rbs +12 -5
- data/sig/herb/ast/nodes.rbs +124 -62
- data/sig/herb/colors.rbs +35 -0
- data/sig/herb/engine/compiler.rbs +23 -1
- data/sig/herb/errors.rbs +74 -20
- data/sig/herb/token.rbs +8 -0
- data/sig/herb_c_extension.rbs +1 -1
- data/sig/serialized_ast_errors.rbs +8 -0
- data/src/analyze.c +461 -249
- data/src/analyze_helpers.c +5 -0
- data/src/analyze_missing_end.c +147 -0
- data/src/analyze_transform.c +196 -0
- data/src/analyzed_ruby.c +23 -2
- data/src/ast_node.c +14 -17
- data/src/ast_nodes.c +179 -181
- data/src/ast_pretty_print.c +232 -232
- data/src/element_source.c +7 -6
- data/src/errors.c +272 -152
- data/src/extract.c +92 -34
- data/src/herb.c +37 -49
- data/src/html_util.c +34 -96
- data/src/include/analyze.h +10 -2
- data/src/include/analyze_helpers.h +3 -0
- data/src/include/analyzed_ruby.h +4 -2
- data/src/include/ast_node.h +4 -4
- data/src/include/ast_nodes.h +68 -67
- data/src/include/ast_pretty_print.h +2 -2
- data/src/include/element_source.h +3 -1
- data/src/include/errors.h +42 -26
- data/src/include/extract.h +4 -4
- data/src/include/herb.h +6 -7
- data/src/include/html_util.h +4 -5
- data/src/include/lexer.h +1 -3
- data/src/include/lexer_peek_helpers.h +21 -19
- data/src/include/lexer_struct.h +12 -10
- data/src/include/location.h +10 -13
- data/src/include/macros.h +4 -0
- data/src/include/parser.h +12 -6
- data/src/include/parser_helpers.h +26 -16
- data/src/include/position.h +3 -14
- data/src/include/pretty_print.h +38 -28
- data/src/include/prism_helpers.h +1 -1
- data/src/include/range.h +4 -13
- data/src/include/token.h +5 -11
- data/src/include/token_struct.h +2 -2
- data/src/include/utf8.h +3 -2
- data/src/include/util/hb_arena.h +31 -0
- data/src/include/util/hb_arena_debug.h +8 -0
- data/src/include/util/hb_array.h +33 -0
- data/src/include/util/hb_buffer.h +34 -0
- data/src/include/util/hb_string.h +29 -0
- data/src/include/util/hb_system.h +9 -0
- data/src/include/util.h +3 -14
- data/src/include/version.h +1 -1
- data/src/include/visitor.h +1 -1
- data/src/io.c +7 -4
- data/src/lexer.c +62 -88
- data/src/lexer_peek_helpers.c +42 -38
- data/src/location.c +9 -37
- data/src/main.c +19 -23
- data/src/parser.c +373 -313
- data/src/parser_helpers.c +60 -54
- data/src/parser_match_tags.c +316 -0
- data/src/pretty_print.c +88 -117
- data/src/prism_helpers.c +7 -7
- data/src/range.c +2 -35
- data/src/token.c +36 -87
- data/src/utf8.c +4 -4
- data/src/util/hb_arena.c +179 -0
- data/src/util/hb_arena_debug.c +237 -0
- data/src/{array.c → util/hb_array.c} +26 -27
- data/src/util/hb_buffer.c +203 -0
- data/src/util/hb_string.c +85 -0
- data/src/util/hb_system.c +30 -0
- data/src/util.c +29 -99
- data/src/visitor.c +54 -54
- data/templates/ext/herb/error_helpers.c.erb +3 -3
- data/templates/ext/herb/error_helpers.h.erb +1 -1
- data/templates/ext/herb/nodes.c.erb +11 -6
- data/templates/java/error_helpers.c.erb +75 -0
- data/templates/java/error_helpers.h.erb +20 -0
- data/templates/java/nodes.c.erb +97 -0
- data/templates/java/nodes.h.erb +23 -0
- data/templates/java/org/herb/ast/Errors.java.erb +121 -0
- data/templates/java/org/herb/ast/NodeVisitor.java.erb +14 -0
- data/templates/java/org/herb/ast/Nodes.java.erb +220 -0
- data/templates/java/org/herb/ast/Visitor.java.erb +56 -0
- data/templates/javascript/packages/core/src/visitor.ts.erb +29 -1
- data/templates/javascript/packages/node/extension/error_helpers.cpp.erb +8 -8
- data/templates/javascript/packages/node/extension/error_helpers.h.erb +1 -1
- data/templates/javascript/packages/node/extension/nodes.cpp.erb +9 -9
- data/templates/javascript/packages/node/extension/nodes.h.erb +1 -1
- data/templates/lib/herb/ast/nodes.rb.erb +28 -16
- data/templates/lib/herb/errors.rb.erb +17 -12
- data/templates/rust/src/ast/nodes.rs.erb +220 -0
- data/templates/rust/src/errors.rs.erb +216 -0
- data/templates/rust/src/nodes.rs.erb +374 -0
- data/templates/src/analyze_missing_end.c.erb +36 -0
- data/templates/src/analyze_transform.c.erb +24 -0
- data/templates/src/ast_nodes.c.erb +14 -16
- data/templates/src/ast_pretty_print.c.erb +36 -36
- data/templates/src/errors.c.erb +36 -38
- data/templates/src/include/ast_nodes.h.erb +11 -10
- data/templates/src/include/ast_pretty_print.h.erb +2 -2
- data/templates/src/include/errors.h.erb +9 -9
- data/templates/src/parser_match_tags.c.erb +38 -0
- data/templates/src/visitor.c.erb +4 -4
- data/templates/template.rb +22 -3
- data/templates/wasm/error_helpers.cpp.erb +9 -9
- data/templates/wasm/error_helpers.h.erb +1 -1
- data/templates/wasm/nodes.cpp.erb +9 -9
- data/templates/wasm/nodes.h.erb +1 -1
- data/vendor/prism/Rakefile +4 -1
- data/vendor/prism/config.yml +2 -1
- data/vendor/prism/include/prism/ast.h +31 -1
- data/vendor/prism/include/prism/diagnostic.h +1 -0
- data/vendor/prism/include/prism/version.h +3 -3
- data/vendor/prism/src/diagnostic.c +3 -1
- data/vendor/prism/src/prism.c +130 -71
- data/vendor/prism/src/util/pm_string.c +6 -8
- data/vendor/prism/templates/include/prism/ast.h.erb +2 -0
- data/vendor/prism/templates/java/org/prism/Loader.java.erb +2 -2
- data/vendor/prism/templates/javascript/src/deserialize.js.erb +2 -2
- data/vendor/prism/templates/lib/prism/serialize.rb.erb +2 -2
- data/vendor/prism/templates/sig/prism.rbs.erb +4 -0
- data/vendor/prism/templates/src/diagnostic.c.erb +1 -0
- metadata +34 -21
- data/lib/herb/libherb/array.rb +0 -51
- data/lib/herb/libherb/ast_node.rb +0 -50
- data/lib/herb/libherb/buffer.rb +0 -56
- data/lib/herb/libherb/extract_result.rb +0 -20
- data/lib/herb/libherb/lex_result.rb +0 -32
- data/lib/herb/libherb/libherb.rb +0 -52
- data/lib/herb/libherb/parse_result.rb +0 -20
- data/lib/herb/libherb/token.rb +0 -46
- data/lib/herb/libherb.rb +0 -35
- data/src/buffer.c +0 -232
- data/src/include/array.h +0 -33
- data/src/include/buffer.h +0 -39
- data/src/include/json.h +0 -28
- data/src/include/memory.h +0 -12
- data/src/json.c +0 -205
- data/src/memory.c +0 -53
- data/src/position.c +0 -33
data/ext/herb/nodes.c
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
#include "../../src/include/token.h"
|
|
13
13
|
|
|
14
14
|
VALUE rb_node_from_c_struct(AST_NODE_T* node);
|
|
15
|
-
static VALUE rb_nodes_array_from_c_array(
|
|
15
|
+
static VALUE rb_nodes_array_from_c_array(hb_array_T* array);
|
|
16
16
|
|
|
17
17
|
static VALUE rb_document_node_from_c_struct(AST_DOCUMENT_NODE_T* document_node) {
|
|
18
18
|
if (document_node == NULL) { return Qnil; }
|
|
@@ -24,7 +24,8 @@ static VALUE rb_document_node_from_c_struct(AST_DOCUMENT_NODE_T* document_node)
|
|
|
24
24
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
25
25
|
VALUE DocumentNode = rb_define_class_under(AST, "DocumentNode", Node);
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
28
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
28
29
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
29
30
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
30
31
|
|
|
@@ -50,7 +51,8 @@ static VALUE rb_literal_node_from_c_struct(AST_LITERAL_NODE_T* literal_node) {
|
|
|
50
51
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
51
52
|
VALUE LiteralNode = rb_define_class_under(AST, "LiteralNode", Node);
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
55
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
54
56
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
55
57
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
56
58
|
|
|
@@ -76,7 +78,8 @@ static VALUE rb_html_open_tag_node_from_c_struct(AST_HTML_OPEN_TAG_NODE_T* html_
|
|
|
76
78
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
77
79
|
VALUE HTMLOpenTagNode = rb_define_class_under(AST, "HTMLOpenTagNode", Node);
|
|
78
80
|
|
|
79
|
-
|
|
81
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
82
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
80
83
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
81
84
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
82
85
|
|
|
@@ -110,7 +113,8 @@ static VALUE rb_html_close_tag_node_from_c_struct(AST_HTML_CLOSE_TAG_NODE_T* htm
|
|
|
110
113
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
111
114
|
VALUE HTMLCloseTagNode = rb_define_class_under(AST, "HTMLCloseTagNode", Node);
|
|
112
115
|
|
|
113
|
-
|
|
116
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
117
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
114
118
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
115
119
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
116
120
|
|
|
@@ -142,7 +146,8 @@ static VALUE rb_html_element_node_from_c_struct(AST_HTML_ELEMENT_NODE_T* html_el
|
|
|
142
146
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
143
147
|
VALUE HTMLElementNode = rb_define_class_under(AST, "HTMLElementNode", Node);
|
|
144
148
|
|
|
145
|
-
|
|
149
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
150
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
146
151
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
147
152
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
148
153
|
|
|
@@ -151,7 +156,11 @@ static VALUE rb_html_element_node_from_c_struct(AST_HTML_ELEMENT_NODE_T* html_el
|
|
|
151
156
|
VALUE html_element_node_body = rb_nodes_array_from_c_array(html_element_node->body);
|
|
152
157
|
VALUE html_element_node_close_tag = rb_node_from_c_struct((AST_NODE_T*) html_element_node->close_tag);
|
|
153
158
|
VALUE html_element_node_is_void = (html_element_node->is_void) ? Qtrue : Qfalse;
|
|
154
|
-
VALUE html_element_node_source
|
|
159
|
+
VALUE html_element_node_source;
|
|
160
|
+
{
|
|
161
|
+
hb_string_T element_source_string = element_source_to_string(html_element_node->source);
|
|
162
|
+
html_element_node_source = rb_utf8_str_new(element_source_string.data, element_source_string.length);
|
|
163
|
+
}
|
|
155
164
|
|
|
156
165
|
VALUE args[9] = {
|
|
157
166
|
type,
|
|
@@ -178,7 +187,8 @@ static VALUE rb_html_attribute_value_node_from_c_struct(AST_HTML_ATTRIBUTE_VALUE
|
|
|
178
187
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
179
188
|
VALUE HTMLAttributeValueNode = rb_define_class_under(AST, "HTMLAttributeValueNode", Node);
|
|
180
189
|
|
|
181
|
-
|
|
190
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
191
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
182
192
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
183
193
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
184
194
|
|
|
@@ -210,7 +220,8 @@ static VALUE rb_html_attribute_name_node_from_c_struct(AST_HTML_ATTRIBUTE_NAME_N
|
|
|
210
220
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
211
221
|
VALUE HTMLAttributeNameNode = rb_define_class_under(AST, "HTMLAttributeNameNode", Node);
|
|
212
222
|
|
|
213
|
-
|
|
223
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
224
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
214
225
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
215
226
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
216
227
|
|
|
@@ -236,7 +247,8 @@ static VALUE rb_html_attribute_node_from_c_struct(AST_HTML_ATTRIBUTE_NODE_T* htm
|
|
|
236
247
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
237
248
|
VALUE HTMLAttributeNode = rb_define_class_under(AST, "HTMLAttributeNode", Node);
|
|
238
249
|
|
|
239
|
-
|
|
250
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
251
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
240
252
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
241
253
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
242
254
|
|
|
@@ -266,7 +278,8 @@ static VALUE rb_html_text_node_from_c_struct(AST_HTML_TEXT_NODE_T* html_text_nod
|
|
|
266
278
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
267
279
|
VALUE HTMLTextNode = rb_define_class_under(AST, "HTMLTextNode", Node);
|
|
268
280
|
|
|
269
|
-
|
|
281
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
282
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
270
283
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
271
284
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
272
285
|
|
|
@@ -292,7 +305,8 @@ static VALUE rb_html_comment_node_from_c_struct(AST_HTML_COMMENT_NODE_T* html_co
|
|
|
292
305
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
293
306
|
VALUE HTMLCommentNode = rb_define_class_under(AST, "HTMLCommentNode", Node);
|
|
294
307
|
|
|
295
|
-
|
|
308
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
309
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
296
310
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
297
311
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
298
312
|
|
|
@@ -322,7 +336,8 @@ static VALUE rb_html_doctype_node_from_c_struct(AST_HTML_DOCTYPE_NODE_T* html_do
|
|
|
322
336
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
323
337
|
VALUE HTMLDoctypeNode = rb_define_class_under(AST, "HTMLDoctypeNode", Node);
|
|
324
338
|
|
|
325
|
-
|
|
339
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
340
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
326
341
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
327
342
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
328
343
|
|
|
@@ -352,7 +367,8 @@ static VALUE rb_xml_declaration_node_from_c_struct(AST_XML_DECLARATION_NODE_T* x
|
|
|
352
367
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
353
368
|
VALUE XMLDeclarationNode = rb_define_class_under(AST, "XMLDeclarationNode", Node);
|
|
354
369
|
|
|
355
|
-
|
|
370
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
371
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
356
372
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
357
373
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
358
374
|
|
|
@@ -382,7 +398,8 @@ static VALUE rb_cdata_node_from_c_struct(AST_CDATA_NODE_T* cdata_node) {
|
|
|
382
398
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
383
399
|
VALUE CDATANode = rb_define_class_under(AST, "CDATANode", Node);
|
|
384
400
|
|
|
385
|
-
|
|
401
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
402
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
386
403
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
387
404
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
388
405
|
|
|
@@ -412,7 +429,8 @@ static VALUE rb_whitespace_node_from_c_struct(AST_WHITESPACE_NODE_T* whitespace_
|
|
|
412
429
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
413
430
|
VALUE WhitespaceNode = rb_define_class_under(AST, "WhitespaceNode", Node);
|
|
414
431
|
|
|
415
|
-
|
|
432
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
433
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
416
434
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
417
435
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
418
436
|
|
|
@@ -438,14 +456,15 @@ static VALUE rb_erb_content_node_from_c_struct(AST_ERB_CONTENT_NODE_T* erb_conte
|
|
|
438
456
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
439
457
|
VALUE ERBContentNode = rb_define_class_under(AST, "ERBContentNode", Node);
|
|
440
458
|
|
|
441
|
-
|
|
459
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
460
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
442
461
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
443
462
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
444
463
|
|
|
445
464
|
VALUE erb_content_node_tag_opening = rb_token_from_c_struct(erb_content_node->tag_opening);
|
|
446
465
|
VALUE erb_content_node_content = rb_token_from_c_struct(erb_content_node->content);
|
|
447
466
|
VALUE erb_content_node_tag_closing = rb_token_from_c_struct(erb_content_node->tag_closing);
|
|
448
|
-
/* #<Herb::Template::AnalyzedRubyField:
|
|
467
|
+
/* #<Herb::Template::AnalyzedRubyField:0x00007f4cca4277a0 @name="analyzed_ruby", @options={kind: nil}> */
|
|
449
468
|
VALUE erb_content_node_analyzed_ruby = Qnil;
|
|
450
469
|
VALUE erb_content_node_parsed = (erb_content_node->parsed) ? Qtrue : Qfalse;
|
|
451
470
|
VALUE erb_content_node_valid = (erb_content_node->valid) ? Qtrue : Qfalse;
|
|
@@ -475,7 +494,8 @@ static VALUE rb_erb_end_node_from_c_struct(AST_ERB_END_NODE_T* erb_end_node) {
|
|
|
475
494
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
476
495
|
VALUE ERBEndNode = rb_define_class_under(AST, "ERBEndNode", Node);
|
|
477
496
|
|
|
478
|
-
|
|
497
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
498
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
479
499
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
480
500
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
481
501
|
|
|
@@ -505,7 +525,8 @@ static VALUE rb_erb_else_node_from_c_struct(AST_ERB_ELSE_NODE_T* erb_else_node)
|
|
|
505
525
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
506
526
|
VALUE ERBElseNode = rb_define_class_under(AST, "ERBElseNode", Node);
|
|
507
527
|
|
|
508
|
-
|
|
528
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
529
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
509
530
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
510
531
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
511
532
|
|
|
@@ -537,7 +558,8 @@ static VALUE rb_erb_if_node_from_c_struct(AST_ERB_IF_NODE_T* erb_if_node) {
|
|
|
537
558
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
538
559
|
VALUE ERBIfNode = rb_define_class_under(AST, "ERBIfNode", Node);
|
|
539
560
|
|
|
540
|
-
|
|
561
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
562
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
541
563
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
542
564
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
543
565
|
|
|
@@ -573,7 +595,8 @@ static VALUE rb_erb_block_node_from_c_struct(AST_ERB_BLOCK_NODE_T* erb_block_nod
|
|
|
573
595
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
574
596
|
VALUE ERBBlockNode = rb_define_class_under(AST, "ERBBlockNode", Node);
|
|
575
597
|
|
|
576
|
-
|
|
598
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
599
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
577
600
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
578
601
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
579
602
|
|
|
@@ -607,7 +630,8 @@ static VALUE rb_erb_when_node_from_c_struct(AST_ERB_WHEN_NODE_T* erb_when_node)
|
|
|
607
630
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
608
631
|
VALUE ERBWhenNode = rb_define_class_under(AST, "ERBWhenNode", Node);
|
|
609
632
|
|
|
610
|
-
|
|
633
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
634
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
611
635
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
612
636
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
613
637
|
|
|
@@ -639,7 +663,8 @@ static VALUE rb_erb_case_node_from_c_struct(AST_ERB_CASE_NODE_T* erb_case_node)
|
|
|
639
663
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
640
664
|
VALUE ERBCaseNode = rb_define_class_under(AST, "ERBCaseNode", Node);
|
|
641
665
|
|
|
642
|
-
|
|
666
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
667
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
643
668
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
644
669
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
645
670
|
|
|
@@ -677,7 +702,8 @@ static VALUE rb_erb_case_match_node_from_c_struct(AST_ERB_CASE_MATCH_NODE_T* erb
|
|
|
677
702
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
678
703
|
VALUE ERBCaseMatchNode = rb_define_class_under(AST, "ERBCaseMatchNode", Node);
|
|
679
704
|
|
|
680
|
-
|
|
705
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
706
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
681
707
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
682
708
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
683
709
|
|
|
@@ -715,7 +741,8 @@ static VALUE rb_erb_while_node_from_c_struct(AST_ERB_WHILE_NODE_T* erb_while_nod
|
|
|
715
741
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
716
742
|
VALUE ERBWhileNode = rb_define_class_under(AST, "ERBWhileNode", Node);
|
|
717
743
|
|
|
718
|
-
|
|
744
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
745
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
719
746
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
720
747
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
721
748
|
|
|
@@ -749,7 +776,8 @@ static VALUE rb_erb_until_node_from_c_struct(AST_ERB_UNTIL_NODE_T* erb_until_nod
|
|
|
749
776
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
750
777
|
VALUE ERBUntilNode = rb_define_class_under(AST, "ERBUntilNode", Node);
|
|
751
778
|
|
|
752
|
-
|
|
779
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
780
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
753
781
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
754
782
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
755
783
|
|
|
@@ -783,7 +811,8 @@ static VALUE rb_erb_for_node_from_c_struct(AST_ERB_FOR_NODE_T* erb_for_node) {
|
|
|
783
811
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
784
812
|
VALUE ERBForNode = rb_define_class_under(AST, "ERBForNode", Node);
|
|
785
813
|
|
|
786
|
-
|
|
814
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
815
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
787
816
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
788
817
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
789
818
|
|
|
@@ -817,7 +846,8 @@ static VALUE rb_erb_rescue_node_from_c_struct(AST_ERB_RESCUE_NODE_T* erb_rescue_
|
|
|
817
846
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
818
847
|
VALUE ERBRescueNode = rb_define_class_under(AST, "ERBRescueNode", Node);
|
|
819
848
|
|
|
820
|
-
|
|
849
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
850
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
821
851
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
822
852
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
823
853
|
|
|
@@ -851,7 +881,8 @@ static VALUE rb_erb_ensure_node_from_c_struct(AST_ERB_ENSURE_NODE_T* erb_ensure_
|
|
|
851
881
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
852
882
|
VALUE ERBEnsureNode = rb_define_class_under(AST, "ERBEnsureNode", Node);
|
|
853
883
|
|
|
854
|
-
|
|
884
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
885
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
855
886
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
856
887
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
857
888
|
|
|
@@ -883,7 +914,8 @@ static VALUE rb_erb_begin_node_from_c_struct(AST_ERB_BEGIN_NODE_T* erb_begin_nod
|
|
|
883
914
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
884
915
|
VALUE ERBBeginNode = rb_define_class_under(AST, "ERBBeginNode", Node);
|
|
885
916
|
|
|
886
|
-
|
|
917
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
918
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
887
919
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
888
920
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
889
921
|
|
|
@@ -923,7 +955,8 @@ static VALUE rb_erb_unless_node_from_c_struct(AST_ERB_UNLESS_NODE_T* erb_unless_
|
|
|
923
955
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
924
956
|
VALUE ERBUnlessNode = rb_define_class_under(AST, "ERBUnlessNode", Node);
|
|
925
957
|
|
|
926
|
-
|
|
958
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
959
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
927
960
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
928
961
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
929
962
|
|
|
@@ -959,7 +992,8 @@ static VALUE rb_erb_yield_node_from_c_struct(AST_ERB_YIELD_NODE_T* erb_yield_nod
|
|
|
959
992
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
960
993
|
VALUE ERBYieldNode = rb_define_class_under(AST, "ERBYieldNode", Node);
|
|
961
994
|
|
|
962
|
-
|
|
995
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
996
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
963
997
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
964
998
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
965
999
|
|
|
@@ -989,7 +1023,8 @@ static VALUE rb_erb_in_node_from_c_struct(AST_ERB_IN_NODE_T* erb_in_node) {
|
|
|
989
1023
|
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
990
1024
|
VALUE ERBInNode = rb_define_class_under(AST, "ERBInNode", Node);
|
|
991
1025
|
|
|
992
|
-
|
|
1026
|
+
hb_string_T node_type = ast_node_type_to_string(node);
|
|
1027
|
+
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
993
1028
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
994
1029
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
995
1030
|
|
|
@@ -1052,12 +1087,12 @@ VALUE rb_node_from_c_struct(AST_NODE_T* node) {
|
|
|
1052
1087
|
return Qnil;
|
|
1053
1088
|
}
|
|
1054
1089
|
|
|
1055
|
-
static VALUE rb_nodes_array_from_c_array(
|
|
1090
|
+
static VALUE rb_nodes_array_from_c_array(hb_array_T* array) {
|
|
1056
1091
|
VALUE rb_array = rb_ary_new();
|
|
1057
1092
|
|
|
1058
1093
|
if (array) {
|
|
1059
|
-
for (size_t i = 0; i <
|
|
1060
|
-
AST_NODE_T* child_node = (AST_NODE_T*)
|
|
1094
|
+
for (size_t i = 0; i < hb_array_size(array); i++) {
|
|
1095
|
+
AST_NODE_T* child_node = (AST_NODE_T*) hb_array_get(array, i);
|
|
1061
1096
|
|
|
1062
1097
|
if (child_node) {
|
|
1063
1098
|
VALUE rb_child = rb_node_from_c_struct(child_node);
|
data/herb.gemspec
CHANGED
|
@@ -48,6 +48,4 @@ Gem::Specification.new do |spec|
|
|
|
48
48
|
spec.metadata["source_code_uri"] = "https://github.com/marcoroth/herb"
|
|
49
49
|
spec.metadata["bug_tracker_uri"] = "https://github.com/marcoroth/herb/issues"
|
|
50
50
|
spec.metadata["documentation_uri"] = "https://docs.herb-tools.dev"
|
|
51
|
-
|
|
52
|
-
# spec.add_dependency "ffi"
|
|
53
51
|
end
|
data/lib/herb/3.0/herb.so
CHANGED
|
Binary file
|
data/lib/herb/3.1/herb.so
CHANGED
|
Binary file
|
data/lib/herb/3.2/herb.so
CHANGED
|
Binary file
|
data/lib/herb/3.3/herb.so
CHANGED
|
Binary file
|
data/lib/herb/3.4/herb.so
CHANGED
|
Binary file
|
data/lib/herb/ast/helpers.rb
CHANGED
|
@@ -21,6 +21,17 @@ module Herb
|
|
|
21
21
|
def erb_output?(opening)
|
|
22
22
|
opening.include?("=")
|
|
23
23
|
end
|
|
24
|
+
|
|
25
|
+
#: (Herb::AST::ERBContentNode) -> bool
|
|
26
|
+
def inline_ruby_comment?(node)
|
|
27
|
+
return false unless node.is_a?(Herb::AST::ERBContentNode)
|
|
28
|
+
return false if erb_comment?(node.tag_opening&.value || "")
|
|
29
|
+
|
|
30
|
+
content = node.content&.value || ""
|
|
31
|
+
stripped = content.lstrip
|
|
32
|
+
|
|
33
|
+
stripped.start_with?("#") && node.location.start.line == node.location.end.line
|
|
34
|
+
end
|
|
24
35
|
end
|
|
25
36
|
end
|
|
26
37
|
end
|
data/lib/herb/ast/node.rb
CHANGED
|
@@ -46,8 +46,15 @@ module Herb
|
|
|
46
46
|
"├── errors: #{inspect_array(errors, item_name: "error", prefix: prefix)}"
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
#: (
|
|
50
|
-
|
|
49
|
+
#: (
|
|
50
|
+
#| Array[Herb::AST::Node|Herb::Errors::Error],
|
|
51
|
+
#| ?item_name: String,
|
|
52
|
+
#| ?prefix: String,
|
|
53
|
+
#| ?indent: Integer,
|
|
54
|
+
#| ?depth: Integer,
|
|
55
|
+
#| ?depth_limit: Integer
|
|
56
|
+
#| ) -> String
|
|
57
|
+
def inspect_array(array, item_name: "item", prefix: " ", indent: 0, depth: 0, depth_limit: 25)
|
|
51
58
|
output = +""
|
|
52
59
|
|
|
53
60
|
if array.any?
|
|
@@ -55,10 +62,12 @@ module Herb
|
|
|
55
62
|
output += "\n"
|
|
56
63
|
|
|
57
64
|
items = array.map { |item|
|
|
65
|
+
kwargs = { indent: indent, depth: depth, depth_limit: depth_limit }
|
|
66
|
+
|
|
58
67
|
if array.last == item
|
|
59
|
-
"└── #{item.tree_inspect.gsub(/^/, " ").lstrip}"
|
|
68
|
+
"└── #{item.tree_inspect(**kwargs).gsub(/^/, " ").lstrip}"
|
|
60
69
|
else
|
|
61
|
-
"├── #{item.tree_inspect.gsub(/^/, "│ ")}".gsub("├── │ ", "├──")
|
|
70
|
+
"├── #{item.tree_inspect(**kwargs).gsub(/^/, "│ ")}".gsub("├── │ ", "├──")
|
|
62
71
|
end
|
|
63
72
|
}
|
|
64
73
|
|
|
@@ -71,8 +80,8 @@ module Herb
|
|
|
71
80
|
output
|
|
72
81
|
end
|
|
73
82
|
|
|
74
|
-
#: (?Integer) -> String
|
|
75
|
-
def tree_inspect(
|
|
83
|
+
#: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
|
|
84
|
+
def tree_inspect(indent: 0, depth: 0, depth_limit: 25)
|
|
76
85
|
raise NotImplementedError
|
|
77
86
|
end
|
|
78
87
|
|