herb 0.9.2-arm-linux-gnu → 0.9.4-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.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/config.yml +125 -0
- data/ext/herb/error_helpers.c +172 -2
- data/ext/herb/extconf.rb +6 -0
- data/ext/herb/extension.c +16 -2
- data/ext/herb/extension_helpers.c +6 -5
- data/ext/herb/extension_helpers.h +4 -4
- data/ext/herb/nodes.c +89 -3
- 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/4.0/herb.so +0 -0
- data/lib/herb/ast/erb_content_node.rb +32 -0
- data/lib/herb/ast/nodes.rb +244 -3
- data/lib/herb/cli.rb +12 -2
- data/lib/herb/engine/compiler.rb +166 -75
- data/lib/herb/engine/validators/security_validator.rb +40 -0
- data/lib/herb/engine.rb +3 -0
- data/lib/herb/errors.rb +268 -0
- data/lib/herb/parser_options.rb +7 -2
- data/lib/herb/project.rb +58 -17
- data/lib/herb/version.rb +1 -1
- data/lib/herb/visitor.rb +82 -0
- data/lib/herb.rb +1 -0
- data/sig/herb/ast/erb_content_node.rbs +13 -0
- data/sig/herb/ast/nodes.rbs +98 -2
- data/sig/herb/engine/compiler.rbs +31 -2
- data/sig/herb/engine/validators/security_validator.rbs +4 -0
- data/sig/herb/engine.rbs +3 -0
- data/sig/herb/errors.rbs +122 -0
- data/sig/herb/parser_options.rbs +6 -2
- data/sig/herb/visitor.rbs +12 -0
- data/sig/serialized_ast_errors.rbs +29 -0
- data/sig/serialized_ast_nodes.rbs +19 -0
- data/src/analyze/action_view/attribute_extraction_helpers.c +420 -91
- data/src/analyze/action_view/image_tag.c +87 -0
- data/src/analyze/action_view/javascript_include_tag.c +22 -12
- data/src/analyze/action_view/registry.c +6 -3
- data/src/analyze/action_view/tag.c +19 -2
- data/src/analyze/action_view/tag_helper_node_builders.c +105 -36
- data/src/analyze/action_view/tag_helpers.c +792 -44
- data/src/analyze/analyze.c +167 -13
- data/src/analyze/{helpers.c → analyze_helpers.c} +1 -1
- data/src/analyze/analyzed_ruby.c +1 -1
- data/src/analyze/builders.c +11 -8
- data/src/analyze/conditional_elements.c +6 -7
- data/src/analyze/conditional_open_tags.c +6 -7
- data/src/analyze/control_type.c +4 -2
- data/src/analyze/invalid_structures.c +5 -5
- data/src/analyze/missing_end.c +2 -2
- data/src/analyze/parse_errors.c +47 -6
- data/src/analyze/prism_annotate.c +7 -7
- data/src/analyze/render_nodes.c +6 -26
- data/src/analyze/strict_locals.c +651 -0
- data/src/analyze/transform.c +7 -0
- data/src/{ast_node.c → ast/ast_node.c} +8 -8
- data/src/{ast_nodes.c → ast/ast_nodes.c} +82 -11
- data/src/{ast_pretty_print.c → ast/ast_pretty_print.c} +113 -9
- data/src/{pretty_print.c → ast/pretty_print.c} +9 -9
- data/src/errors.c +398 -8
- data/src/extract.c +5 -5
- data/src/herb.c +15 -5
- data/src/include/analyze/action_view/attribute_extraction_helpers.h +3 -1
- data/src/include/analyze/action_view/tag_helper_handler.h +3 -3
- data/src/include/analyze/action_view/tag_helper_node_builders.h +34 -5
- data/src/include/analyze/action_view/tag_helpers.h +4 -3
- data/src/include/analyze/analyze.h +12 -5
- data/src/include/analyze/analyzed_ruby.h +2 -2
- data/src/include/analyze/builders.h +4 -4
- data/src/include/analyze/conditional_elements.h +2 -2
- data/src/include/analyze/conditional_open_tags.h +2 -2
- data/src/include/analyze/control_type.h +1 -1
- data/src/include/analyze/helpers.h +2 -2
- data/src/include/analyze/invalid_structures.h +1 -1
- data/src/include/analyze/prism_annotate.h +2 -2
- data/src/include/analyze/render_nodes.h +1 -1
- data/src/include/analyze/strict_locals.h +11 -0
- data/src/include/{ast_node.h → ast/ast_node.h} +4 -4
- data/src/include/{ast_nodes.h → ast/ast_nodes.h} +38 -14
- data/src/include/{ast_pretty_print.h → ast/ast_pretty_print.h} +3 -3
- data/src/include/{pretty_print.h → ast/pretty_print.h} +4 -4
- data/src/include/errors.h +65 -7
- data/src/include/extract.h +2 -2
- data/src/include/herb.h +5 -5
- data/src/include/{lex_helpers.h → lexer/lex_helpers.h} +5 -5
- data/src/include/{lexer.h → lexer/lexer.h} +1 -1
- data/src/include/{lexer_peek_helpers.h → lexer/lexer_peek_helpers.h} +2 -2
- data/src/include/{lexer_struct.h → lexer/lexer_struct.h} +2 -2
- data/src/include/{token.h → lexer/token.h} +3 -3
- data/src/include/{token_matchers.h → lexer/token_matchers.h} +1 -1
- data/src/include/{token_struct.h → lexer/token_struct.h} +3 -3
- data/src/include/{util → lib}/hb_foreach.h +1 -1
- data/src/include/{util → lib}/hb_string.h +5 -1
- data/src/include/{location.h → location/location.h} +1 -1
- data/src/include/parser/dot_notation.h +12 -0
- data/src/include/{parser.h → parser/parser.h} +11 -4
- data/src/include/{parser_helpers.h → parser/parser_helpers.h} +6 -6
- data/src/include/{prism_context.h → prism/prism_context.h} +2 -2
- data/src/include/{prism_helpers.h → prism/prism_helpers.h} +6 -6
- data/src/include/{html_util.h → util/html_util.h} +1 -1
- data/src/include/util/ruby_util.h +9 -0
- data/src/include/{utf8.h → util/utf8.h} +1 -1
- data/src/include/{util.h → util/util.h} +1 -1
- data/src/include/version.h +1 -1
- data/src/include/visitor.h +3 -3
- data/src/{lexer_peek_helpers.c → lexer/lexer_peek_helpers.c} +3 -3
- data/src/{token.c → lexer/token.c} +8 -8
- data/src/{token_matchers.c → lexer/token_matchers.c} +2 -2
- data/src/lexer.c +6 -6
- data/src/{util → lib}/hb_allocator.c +2 -2
- data/src/{util → lib}/hb_arena.c +1 -1
- data/src/{util → lib}/hb_arena_debug.c +2 -2
- data/src/{util → lib}/hb_array.c +2 -2
- data/src/{util → lib}/hb_buffer.c +2 -2
- data/src/{util → lib}/hb_narray.c +1 -1
- data/src/{util → lib}/hb_string.c +2 -2
- data/src/{location.c → location/location.c} +2 -2
- data/src/{position.c → location/position.c} +2 -2
- data/src/{range.c → location/range.c} +1 -1
- data/src/main.c +11 -11
- data/src/parser/dot_notation.c +100 -0
- data/src/{parser_match_tags.c → parser/match_tags.c} +34 -5
- data/src/{parser_helpers.c → parser/parser_helpers.c} +10 -10
- data/src/parser.c +68 -32
- data/src/{prism_helpers.c → prism/prism_helpers.c} +7 -7
- data/src/{ruby_parser.c → prism/ruby_parser.c} +1 -1
- data/src/{html_util.c → util/html_util.c} +4 -4
- data/src/{io.c → util/io.c} +3 -3
- data/src/util/ruby_util.c +42 -0
- data/src/{utf8.c → util/utf8.c} +2 -2
- data/src/{util.c → util/util.c} +4 -4
- data/src/visitor.c +35 -3
- data/templates/ext/herb/error_helpers.c.erb +2 -2
- data/templates/ext/herb/nodes.c.erb +1 -1
- data/templates/java/error_helpers.c.erb +1 -1
- data/templates/java/error_helpers.h.erb +2 -2
- data/templates/java/nodes.c.erb +4 -4
- data/templates/java/nodes.h.erb +1 -1
- data/templates/javascript/packages/node/extension/error_helpers.cpp.erb +4 -4
- data/templates/javascript/packages/node/extension/nodes.cpp.erb +4 -4
- data/templates/lib/herb/visitor.rb.erb +14 -0
- data/templates/src/analyze/missing_end.c.erb +2 -2
- data/templates/src/{ast_nodes.c.erb → ast/ast_nodes.c.erb} +9 -9
- data/templates/src/{ast_pretty_print.c.erb → ast/ast_pretty_print.c.erb} +8 -8
- data/templates/src/errors.c.erb +8 -8
- data/templates/src/include/{ast_nodes.h.erb → ast/ast_nodes.h.erb} +11 -12
- data/templates/src/include/{ast_pretty_print.h.erb → ast/ast_pretty_print.h.erb} +2 -2
- data/templates/src/include/errors.h.erb +7 -7
- data/templates/src/{parser_match_tags.c.erb → parser/match_tags.c.erb} +4 -4
- data/templates/src/visitor.c.erb +3 -3
- data/templates/wasm/error_helpers.cpp.erb +4 -4
- data/templates/wasm/nodes.cpp.erb +5 -5
- metadata +76 -68
- data/src/include/element_source.h +0 -10
- /data/src/include/{util → lib}/hb_allocator.h +0 -0
- /data/src/include/{util → lib}/hb_arena.h +0 -0
- /data/src/include/{util → lib}/hb_arena_debug.h +0 -0
- /data/src/include/{util → lib}/hb_array.h +0 -0
- /data/src/include/{util → lib}/hb_buffer.h +0 -0
- /data/src/include/{util → lib}/hb_narray.h +0 -0
- /data/src/include/{util → lib}/string.h +0 -0
- /data/src/include/{position.h → location/position.h} +0 -0
- /data/src/include/{range.h → location/range.h} +0 -0
- /data/src/include/{herb_prism_node.h → prism/herb_prism_node.h} +0 -0
- /data/src/include/{prism_serialized.h → prism/prism_serialized.h} +0 -0
- /data/src/include/{ruby_parser.h → prism/ruby_parser.h} +0 -0
- /data/src/include/{io.h → util/io.h} +0 -0
- /data/templates/src/include/{util → lib}/hb_foreach.h.erb +0 -0
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /home/runner/work/herb/herb/templates/src/ast_nodes.c.erb
|
|
2
|
+
// be modified manually. See /home/runner/work/herb/herb/templates/src/ast/ast_nodes.c.erb
|
|
3
3
|
|
|
4
4
|
#include <stdio.h>
|
|
5
5
|
#include <stdbool.h>
|
|
6
6
|
|
|
7
7
|
#include <prism.h>
|
|
8
8
|
|
|
9
|
-
#include "include/analyze/analyzed_ruby.h"
|
|
10
|
-
#include "include/ast_node.h"
|
|
11
|
-
#include "include/ast_nodes.h"
|
|
12
|
-
#include "include/errors.h"
|
|
13
|
-
#include "include/token.h"
|
|
14
|
-
#include "include/util.h"
|
|
15
|
-
#include "include/
|
|
16
|
-
#include "include/
|
|
17
|
-
#include "include/
|
|
9
|
+
#include "../include/analyze/analyzed_ruby.h"
|
|
10
|
+
#include "../include/ast/ast_node.h"
|
|
11
|
+
#include "../include/ast/ast_nodes.h"
|
|
12
|
+
#include "../include/errors.h"
|
|
13
|
+
#include "../include/lexer/token.h"
|
|
14
|
+
#include "../include/util/util.h"
|
|
15
|
+
#include "../include/lib/hb_allocator.h"
|
|
16
|
+
#include "../include/lib/hb_array.h"
|
|
17
|
+
#include "../include/lib/hb_string.h"
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
AST_DOCUMENT_NODE_T* ast_document_node_init(hb_array_T* children, herb_prism_context_T* prism_context, herb_prism_node_T prism_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
|
|
@@ -376,7 +376,7 @@ AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content,
|
|
|
376
376
|
return erb_if_node;
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
-
AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, herb_prism_node_T prism_node, hb_array_T* body, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
|
|
379
|
+
AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, herb_prism_node_T prism_node, hb_array_T* body, struct AST_ERB_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) {
|
|
380
380
|
AST_ERB_BLOCK_NODE_T* erb_block_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_BLOCK_NODE_T));
|
|
381
381
|
|
|
382
382
|
if (!erb_block_node) { return NULL; }
|
|
@@ -388,6 +388,9 @@ AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* con
|
|
|
388
388
|
erb_block_node->tag_closing = token_copy(tag_closing, allocator);
|
|
389
389
|
erb_block_node->prism_node = prism_node;
|
|
390
390
|
erb_block_node->body = body;
|
|
391
|
+
erb_block_node->rescue_clause = rescue_clause;
|
|
392
|
+
erb_block_node->else_clause = else_clause;
|
|
393
|
+
erb_block_node->ensure_clause = ensure_clause;
|
|
391
394
|
erb_block_node->end_node = end_node;
|
|
392
395
|
|
|
393
396
|
return erb_block_node;
|
|
@@ -615,6 +618,38 @@ AST_ERB_RENDER_NODE_T* ast_erb_render_node_init(token_T* tag_opening, token_T* c
|
|
|
615
618
|
return erb_render_node;
|
|
616
619
|
}
|
|
617
620
|
|
|
621
|
+
AST_RUBY_STRICT_LOCAL_NODE_T* ast_ruby_strict_local_node_init(token_T* name, struct AST_RUBY_LITERAL_NODE_STRUCT* default_value, bool required, bool double_splat, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
|
|
622
|
+
AST_RUBY_STRICT_LOCAL_NODE_T* ruby_strict_local_node = hb_allocator_alloc(allocator, sizeof(AST_RUBY_STRICT_LOCAL_NODE_T));
|
|
623
|
+
|
|
624
|
+
if (!ruby_strict_local_node) { return NULL; }
|
|
625
|
+
|
|
626
|
+
ast_node_init(&ruby_strict_local_node->base, AST_RUBY_STRICT_LOCAL_NODE, start_position, end_position, errors, allocator);
|
|
627
|
+
|
|
628
|
+
ruby_strict_local_node->name = token_copy(name, allocator);
|
|
629
|
+
ruby_strict_local_node->default_value = default_value;
|
|
630
|
+
ruby_strict_local_node->required = required;
|
|
631
|
+
ruby_strict_local_node->double_splat = double_splat;
|
|
632
|
+
|
|
633
|
+
return ruby_strict_local_node;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
AST_ERB_STRICT_LOCALS_NODE_T* ast_erb_strict_locals_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, analyzed_ruby_T* analyzed_ruby, herb_prism_node_T prism_node, hb_array_T* locals, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator) {
|
|
637
|
+
AST_ERB_STRICT_LOCALS_NODE_T* erb_strict_locals_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_STRICT_LOCALS_NODE_T));
|
|
638
|
+
|
|
639
|
+
if (!erb_strict_locals_node) { return NULL; }
|
|
640
|
+
|
|
641
|
+
ast_node_init(&erb_strict_locals_node->base, AST_ERB_STRICT_LOCALS_NODE, start_position, end_position, errors, allocator);
|
|
642
|
+
|
|
643
|
+
erb_strict_locals_node->tag_opening = token_copy(tag_opening, allocator);
|
|
644
|
+
erb_strict_locals_node->content = token_copy(content, allocator);
|
|
645
|
+
erb_strict_locals_node->tag_closing = token_copy(tag_closing, allocator);
|
|
646
|
+
erb_strict_locals_node->analyzed_ruby = analyzed_ruby;
|
|
647
|
+
erb_strict_locals_node->prism_node = prism_node;
|
|
648
|
+
erb_strict_locals_node->locals = locals;
|
|
649
|
+
|
|
650
|
+
return erb_strict_locals_node;
|
|
651
|
+
}
|
|
652
|
+
|
|
618
653
|
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) {
|
|
619
654
|
AST_ERB_YIELD_NODE_T* erb_yield_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_YIELD_NODE_T));
|
|
620
655
|
|
|
@@ -685,6 +720,8 @@ hb_string_T ast_node_type_to_string(AST_NODE_T* node) {
|
|
|
685
720
|
case AST_ERB_UNLESS_NODE: return hb_string("AST_ERB_UNLESS_NODE");
|
|
686
721
|
case AST_RUBY_RENDER_LOCAL_NODE: return hb_string("AST_RUBY_RENDER_LOCAL_NODE");
|
|
687
722
|
case AST_ERB_RENDER_NODE: return hb_string("AST_ERB_RENDER_NODE");
|
|
723
|
+
case AST_RUBY_STRICT_LOCAL_NODE: return hb_string("AST_RUBY_STRICT_LOCAL_NODE");
|
|
724
|
+
case AST_ERB_STRICT_LOCALS_NODE: return hb_string("AST_ERB_STRICT_LOCALS_NODE");
|
|
688
725
|
case AST_ERB_YIELD_NODE: return hb_string("AST_ERB_YIELD_NODE");
|
|
689
726
|
case AST_ERB_IN_NODE: return hb_string("AST_ERB_IN_NODE");
|
|
690
727
|
}
|
|
@@ -732,6 +769,8 @@ hb_string_T ast_node_human_type(AST_NODE_T* node) {
|
|
|
732
769
|
case AST_ERB_UNLESS_NODE: return hb_string("ERBUnlessNode");
|
|
733
770
|
case AST_RUBY_RENDER_LOCAL_NODE: return hb_string("RubyRenderLocalNode");
|
|
734
771
|
case AST_ERB_RENDER_NODE: return hb_string("ERBRenderNode");
|
|
772
|
+
case AST_RUBY_STRICT_LOCAL_NODE: return hb_string("RubyStrictLocalNode");
|
|
773
|
+
case AST_ERB_STRICT_LOCALS_NODE: return hb_string("ERBStrictLocalsNode");
|
|
735
774
|
case AST_ERB_YIELD_NODE: return hb_string("ERBYieldNode");
|
|
736
775
|
case AST_ERB_IN_NODE: return hb_string("ERBInNode");
|
|
737
776
|
}
|
|
@@ -1069,6 +1108,9 @@ static void ast_free_erb_block_node(AST_ERB_BLOCK_NODE_T* erb_block_node, hb_all
|
|
|
1069
1108
|
|
|
1070
1109
|
hb_array_free(&erb_block_node->body);
|
|
1071
1110
|
}
|
|
1111
|
+
ast_node_free((AST_NODE_T*) erb_block_node->rescue_clause, allocator);
|
|
1112
|
+
ast_node_free((AST_NODE_T*) erb_block_node->else_clause, allocator);
|
|
1113
|
+
ast_node_free((AST_NODE_T*) erb_block_node->ensure_clause, allocator);
|
|
1072
1114
|
ast_node_free((AST_NODE_T*) erb_block_node->end_node, allocator);
|
|
1073
1115
|
|
|
1074
1116
|
ast_free_base_node(&erb_block_node->base, allocator);
|
|
@@ -1317,6 +1359,33 @@ static void ast_free_erb_render_node(AST_ERB_RENDER_NODE_T* erb_render_node, hb_
|
|
|
1317
1359
|
ast_free_base_node(&erb_render_node->base, allocator);
|
|
1318
1360
|
}
|
|
1319
1361
|
|
|
1362
|
+
static void ast_free_ruby_strict_local_node(AST_RUBY_STRICT_LOCAL_NODE_T* ruby_strict_local_node, hb_allocator_T* allocator) {
|
|
1363
|
+
if (ruby_strict_local_node->name != NULL) { token_free(ruby_strict_local_node->name, allocator); }
|
|
1364
|
+
ast_node_free((AST_NODE_T*) ruby_strict_local_node->default_value, allocator);
|
|
1365
|
+
|
|
1366
|
+
ast_free_base_node(&ruby_strict_local_node->base, allocator);
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
static void ast_free_erb_strict_locals_node(AST_ERB_STRICT_LOCALS_NODE_T* erb_strict_locals_node, hb_allocator_T* allocator) {
|
|
1370
|
+
if (erb_strict_locals_node->tag_opening != NULL) { token_free(erb_strict_locals_node->tag_opening, allocator); }
|
|
1371
|
+
if (erb_strict_locals_node->content != NULL) { token_free(erb_strict_locals_node->content, allocator); }
|
|
1372
|
+
if (erb_strict_locals_node->tag_closing != NULL) { token_free(erb_strict_locals_node->tag_closing, allocator); }
|
|
1373
|
+
if (erb_strict_locals_node->analyzed_ruby != NULL) {
|
|
1374
|
+
free_analyzed_ruby(erb_strict_locals_node->analyzed_ruby);
|
|
1375
|
+
}
|
|
1376
|
+
/* prism_node is a borrowed reference into the prism context, not freed here */
|
|
1377
|
+
if (erb_strict_locals_node->locals != NULL) {
|
|
1378
|
+
for (size_t i = 0; i < hb_array_size(erb_strict_locals_node->locals); i++) {
|
|
1379
|
+
AST_NODE_T* child = hb_array_get(erb_strict_locals_node->locals, i);
|
|
1380
|
+
if (child) { ast_node_free(child, allocator); }
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
hb_array_free(&erb_strict_locals_node->locals);
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
ast_free_base_node(&erb_strict_locals_node->base, allocator);
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1320
1389
|
static void ast_free_erb_yield_node(AST_ERB_YIELD_NODE_T* erb_yield_node, hb_allocator_T* allocator) {
|
|
1321
1390
|
if (erb_yield_node->tag_opening != NULL) { token_free(erb_yield_node->tag_opening, allocator); }
|
|
1322
1391
|
if (erb_yield_node->content != NULL) { token_free(erb_yield_node->content, allocator); }
|
|
@@ -1384,6 +1453,8 @@ void ast_node_free(AST_NODE_T* node, hb_allocator_T* allocator) {
|
|
|
1384
1453
|
case AST_ERB_UNLESS_NODE: ast_free_erb_unless_node((AST_ERB_UNLESS_NODE_T*) node, allocator); break;
|
|
1385
1454
|
case AST_RUBY_RENDER_LOCAL_NODE: ast_free_ruby_render_local_node((AST_RUBY_RENDER_LOCAL_NODE_T*) node, allocator); break;
|
|
1386
1455
|
case AST_ERB_RENDER_NODE: ast_free_erb_render_node((AST_ERB_RENDER_NODE_T*) node, allocator); break;
|
|
1456
|
+
case AST_RUBY_STRICT_LOCAL_NODE: ast_free_ruby_strict_local_node((AST_RUBY_STRICT_LOCAL_NODE_T*) node, allocator); break;
|
|
1457
|
+
case AST_ERB_STRICT_LOCALS_NODE: ast_free_erb_strict_locals_node((AST_ERB_STRICT_LOCALS_NODE_T*) node, allocator); break;
|
|
1387
1458
|
case AST_ERB_YIELD_NODE: ast_free_erb_yield_node((AST_ERB_YIELD_NODE_T*) node, allocator); break;
|
|
1388
1459
|
case AST_ERB_IN_NODE: ast_free_erb_in_node((AST_ERB_IN_NODE_T*) node, allocator); break;
|
|
1389
1460
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /home/runner/work/herb/herb/templates/src/ast_pretty_print.c.erb
|
|
2
|
+
// be modified manually. See /home/runner/work/herb/herb/templates/src/ast/ast_pretty_print.c.erb
|
|
3
3
|
|
|
4
4
|
#ifdef HERB_EXCLUDE_PRETTYPRINT
|
|
5
5
|
// Pretty print support excluded
|
|
6
6
|
#else
|
|
7
7
|
|
|
8
|
-
#include "include/analyze/helpers.h"
|
|
9
|
-
#include "include/ast_node.h"
|
|
10
|
-
#include "include/ast_nodes.h"
|
|
11
|
-
#include "include/errors.h"
|
|
12
|
-
#include "include/pretty_print.h"
|
|
13
|
-
#include "include/token_struct.h"
|
|
14
|
-
#include "include/util.h"
|
|
15
|
-
#include "include/
|
|
8
|
+
#include "../include/analyze/helpers.h"
|
|
9
|
+
#include "../include/ast/ast_node.h"
|
|
10
|
+
#include "../include/ast/ast_nodes.h"
|
|
11
|
+
#include "../include/errors.h"
|
|
12
|
+
#include "../include/ast/pretty_print.h"
|
|
13
|
+
#include "../include/lexer/token_struct.h"
|
|
14
|
+
#include "../include/util/util.h"
|
|
15
|
+
#include "../include/lib/hb_buffer.h"
|
|
16
16
|
|
|
17
17
|
#include <stdio.h>
|
|
18
18
|
#include <stdlib.h>
|
|
@@ -474,6 +474,51 @@ void ast_pretty_print_node(AST_NODE_T* node, const size_t indent, const size_t r
|
|
|
474
474
|
}
|
|
475
475
|
pretty_print_array(hb_string("body"), erb_block_node->body, indent, relative_indent, false, buffer);
|
|
476
476
|
|
|
477
|
+
pretty_print_label(hb_string("rescue_clause"), indent, relative_indent, false, buffer);
|
|
478
|
+
|
|
479
|
+
if (erb_block_node->rescue_clause) {
|
|
480
|
+
hb_buffer_append(buffer, "\n");
|
|
481
|
+
pretty_print_indent(buffer, indent);
|
|
482
|
+
pretty_print_indent(buffer, relative_indent + 1);
|
|
483
|
+
|
|
484
|
+
hb_buffer_append(buffer, "└── ");
|
|
485
|
+
ast_pretty_print_node((AST_NODE_T*) erb_block_node->rescue_clause, indent, relative_indent + 2, buffer);
|
|
486
|
+
} else {
|
|
487
|
+
hb_buffer_append(buffer, " ∅\n");
|
|
488
|
+
}
|
|
489
|
+
hb_buffer_append(buffer, "\n");
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
pretty_print_label(hb_string("else_clause"), indent, relative_indent, false, buffer);
|
|
493
|
+
|
|
494
|
+
if (erb_block_node->else_clause) {
|
|
495
|
+
hb_buffer_append(buffer, "\n");
|
|
496
|
+
pretty_print_indent(buffer, indent);
|
|
497
|
+
pretty_print_indent(buffer, relative_indent + 1);
|
|
498
|
+
|
|
499
|
+
hb_buffer_append(buffer, "└── ");
|
|
500
|
+
ast_pretty_print_node((AST_NODE_T*) erb_block_node->else_clause, indent, relative_indent + 2, buffer);
|
|
501
|
+
} else {
|
|
502
|
+
hb_buffer_append(buffer, " ∅\n");
|
|
503
|
+
}
|
|
504
|
+
hb_buffer_append(buffer, "\n");
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
pretty_print_label(hb_string("ensure_clause"), indent, relative_indent, false, buffer);
|
|
508
|
+
|
|
509
|
+
if (erb_block_node->ensure_clause) {
|
|
510
|
+
hb_buffer_append(buffer, "\n");
|
|
511
|
+
pretty_print_indent(buffer, indent);
|
|
512
|
+
pretty_print_indent(buffer, relative_indent + 1);
|
|
513
|
+
|
|
514
|
+
hb_buffer_append(buffer, "└── ");
|
|
515
|
+
ast_pretty_print_node((AST_NODE_T*) erb_block_node->ensure_clause, indent, relative_indent + 2, buffer);
|
|
516
|
+
} else {
|
|
517
|
+
hb_buffer_append(buffer, " ∅\n");
|
|
518
|
+
}
|
|
519
|
+
hb_buffer_append(buffer, "\n");
|
|
520
|
+
|
|
521
|
+
|
|
477
522
|
pretty_print_label(hb_string("end_node"), indent, relative_indent, true, buffer);
|
|
478
523
|
|
|
479
524
|
if (erb_block_node->end_node) {
|
|
@@ -930,6 +975,65 @@ void ast_pretty_print_node(AST_NODE_T* node, const size_t indent, const size_t r
|
|
|
930
975
|
pretty_print_array(hb_string("locals"), erb_render_node->locals, indent, relative_indent, true, buffer);
|
|
931
976
|
} break;
|
|
932
977
|
|
|
978
|
+
case AST_RUBY_STRICT_LOCAL_NODE: {
|
|
979
|
+
const AST_RUBY_STRICT_LOCAL_NODE_T* ruby_strict_local_node = (AST_RUBY_STRICT_LOCAL_NODE_T*) node;
|
|
980
|
+
|
|
981
|
+
pretty_print_errors(node, indent, relative_indent, false, buffer);
|
|
982
|
+
pretty_print_token_property(ruby_strict_local_node->name, hb_string("name"), indent, relative_indent, false, buffer);
|
|
983
|
+
|
|
984
|
+
pretty_print_label(hb_string("default_value"), indent, relative_indent, false, buffer);
|
|
985
|
+
|
|
986
|
+
if (ruby_strict_local_node->default_value) {
|
|
987
|
+
hb_buffer_append(buffer, "\n");
|
|
988
|
+
pretty_print_indent(buffer, indent);
|
|
989
|
+
pretty_print_indent(buffer, relative_indent + 1);
|
|
990
|
+
|
|
991
|
+
hb_buffer_append(buffer, "└── ");
|
|
992
|
+
ast_pretty_print_node((AST_NODE_T*) ruby_strict_local_node->default_value, indent, relative_indent + 2, buffer);
|
|
993
|
+
} else {
|
|
994
|
+
hb_buffer_append(buffer, " ∅\n");
|
|
995
|
+
}
|
|
996
|
+
hb_buffer_append(buffer, "\n");
|
|
997
|
+
|
|
998
|
+
pretty_print_boolean_property(hb_string("required"), ruby_strict_local_node->required, indent, relative_indent, false, buffer);
|
|
999
|
+
pretty_print_boolean_property(hb_string("double_splat"), ruby_strict_local_node->double_splat, indent, relative_indent, true, buffer);
|
|
1000
|
+
} break;
|
|
1001
|
+
|
|
1002
|
+
case AST_ERB_STRICT_LOCALS_NODE: {
|
|
1003
|
+
const AST_ERB_STRICT_LOCALS_NODE_T* erb_strict_locals_node = (AST_ERB_STRICT_LOCALS_NODE_T*) node;
|
|
1004
|
+
|
|
1005
|
+
pretty_print_errors(node, indent, relative_indent, false, buffer);
|
|
1006
|
+
pretty_print_token_property(erb_strict_locals_node->tag_opening, hb_string("tag_opening"), indent, relative_indent, false, buffer);
|
|
1007
|
+
pretty_print_token_property(erb_strict_locals_node->content, hb_string("content"), indent, relative_indent, false, buffer);
|
|
1008
|
+
pretty_print_token_property(erb_strict_locals_node->tag_closing, hb_string("tag_closing"), indent, relative_indent, false, buffer);
|
|
1009
|
+
if (erb_strict_locals_node->analyzed_ruby) {
|
|
1010
|
+
pretty_print_boolean_property(hb_string("if_node"), has_if_node(erb_strict_locals_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
1011
|
+
pretty_print_boolean_property(hb_string("elsif_node"), has_elsif_node(erb_strict_locals_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
1012
|
+
pretty_print_boolean_property(hb_string("else_node"), has_else_node(erb_strict_locals_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
1013
|
+
pretty_print_boolean_property(hb_string("end"), has_end(erb_strict_locals_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
1014
|
+
pretty_print_boolean_property(hb_string("block_node"), has_block_node(erb_strict_locals_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
1015
|
+
pretty_print_boolean_property(hb_string("block_closing"), has_block_closing(erb_strict_locals_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
1016
|
+
pretty_print_boolean_property(hb_string("case_node"), has_case_node(erb_strict_locals_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
1017
|
+
pretty_print_boolean_property(hb_string("when_node"), has_when_node(erb_strict_locals_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
1018
|
+
pretty_print_boolean_property(hb_string("for_node"), has_for_node(erb_strict_locals_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
1019
|
+
pretty_print_boolean_property(hb_string("while_node"), has_while_node(erb_strict_locals_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
1020
|
+
pretty_print_boolean_property(hb_string("until_node"), has_until_node(erb_strict_locals_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
1021
|
+
pretty_print_boolean_property(hb_string("begin_node"), has_begin_node(erb_strict_locals_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
1022
|
+
pretty_print_boolean_property(hb_string("rescue_node"), has_rescue_node(erb_strict_locals_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
1023
|
+
pretty_print_boolean_property(hb_string("ensure_node"), has_ensure_node(erb_strict_locals_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
1024
|
+
pretty_print_boolean_property(hb_string("unless_node"), has_unless_node(erb_strict_locals_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
1025
|
+
} else {
|
|
1026
|
+
pretty_print_label(hb_string("analyzed_ruby"), indent, relative_indent, false, buffer);
|
|
1027
|
+
hb_buffer_append(buffer, " ∅\n");
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
if (erb_strict_locals_node->prism_node.node != NULL) {
|
|
1031
|
+
pretty_print_label(hb_string("prism_node"), indent, relative_indent, false, buffer);
|
|
1032
|
+
hb_buffer_append(buffer, " (pm_node_t*)\n");
|
|
1033
|
+
}
|
|
1034
|
+
pretty_print_array(hb_string("locals"), erb_strict_locals_node->locals, indent, relative_indent, true, buffer);
|
|
1035
|
+
} break;
|
|
1036
|
+
|
|
933
1037
|
case AST_ERB_YIELD_NODE: {
|
|
934
1038
|
const AST_ERB_YIELD_NODE_T* erb_yield_node = (AST_ERB_YIELD_NODE_T*) node;
|
|
935
1039
|
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
// Pretty print support excluded
|
|
3
3
|
#else
|
|
4
4
|
|
|
5
|
-
# include "include/pretty_print.h"
|
|
6
|
-
# include "include/ast_nodes.h"
|
|
7
|
-
# include "include/ast_pretty_print.h"
|
|
8
|
-
# include "include/errors.h"
|
|
9
|
-
# include "include/token_struct.h"
|
|
10
|
-
# include "include/
|
|
11
|
-
# include "include/
|
|
12
|
-
# include "include/
|
|
13
|
-
# include "include/util/
|
|
5
|
+
# include "../include/ast/pretty_print.h"
|
|
6
|
+
# include "../include/ast/ast_nodes.h"
|
|
7
|
+
# include "../include/ast/ast_pretty_print.h"
|
|
8
|
+
# include "../include/errors.h"
|
|
9
|
+
# include "../include/lexer/token_struct.h"
|
|
10
|
+
# include "../include/lib/hb_allocator.h"
|
|
11
|
+
# include "../include/lib/hb_buffer.h"
|
|
12
|
+
# include "../include/lib/hb_string.h"
|
|
13
|
+
# include "../include/util/util.h"
|
|
14
14
|
|
|
15
15
|
# include <stdbool.h>
|
|
16
16
|
# include <stdio.h>
|