herb 0.8.7-x86_64-linux-gnu → 0.8.8-x86_64-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/Rakefile +7 -0
- data/config.yml +12 -0
- data/ext/herb/extconf.rb +0 -4
- data/ext/herb/nodes.c +17 -9
- 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/nodes.rb +32 -8
- data/lib/herb/engine/debug_visitor.rb +1 -1
- data/lib/herb/version.rb +1 -1
- data/lib/herb.rb +30 -3
- data/sig/herb/ast/nodes.rbs +16 -8
- data/sig/serialized_ast_nodes.rbs +4 -0
- data/src/analyze.c +110 -15
- data/src/analyze_helpers.c +80 -12
- data/src/analyzed_ruby.c +1 -0
- data/src/ast_nodes.c +12 -4
- data/src/ast_pretty_print.c +52 -0
- data/src/include/analyze_helpers.h +7 -0
- data/src/include/analyzed_ruby.h +1 -0
- data/src/include/ast_nodes.h +8 -4
- data/src/include/location.h +4 -0
- data/src/include/prism_helpers.h +6 -0
- data/src/include/version.h +1 -1
- data/src/location.c +16 -0
- data/src/prism_helpers.c +188 -0
- data/templates/ext/herb/nodes.c.erb +2 -0
- data/templates/java/nodes.c.erb +3 -1
- data/templates/java/org/herb/ast/Nodes.java.erb +11 -0
- data/templates/javascript/packages/core/src/nodes.ts.erb +14 -0
- data/templates/javascript/packages/node/extension/nodes.cpp.erb +9 -0
- data/templates/lib/herb/ast/nodes.rb.erb +4 -0
- data/templates/rust/src/ast/nodes.rs.erb +10 -0
- data/templates/rust/src/nodes.rs.erb +4 -0
- data/templates/src/ast_nodes.c.erb +4 -0
- data/templates/src/ast_pretty_print.c.erb +14 -0
- data/templates/template.rb +11 -0
- data/templates/wasm/nodes.cpp.erb +6 -0
- data/vendor/prism/include/prism/version.h +2 -2
- data/vendor/prism/src/prism.c +48 -27
- data/vendor/prism/templates/java/org/prism/Loader.java.erb +1 -1
- data/vendor/prism/templates/javascript/src/deserialize.js.erb +1 -1
- data/vendor/prism/templates/lib/prism/compiler.rb.erb +2 -2
- data/vendor/prism/templates/lib/prism/node.rb.erb +24 -1
- data/vendor/prism/templates/lib/prism/serialize.rb.erb +1 -1
- data/vendor/prism/templates/lib/prism/visitor.rb.erb +2 -2
- data/vendor/prism/templates/sig/prism/node.rbs.erb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c6032d5c4fe9a02ecb37700f9f652cfeee17db41145b7d1aefecce3681b65401
|
|
4
|
+
data.tar.gz: 8b2b4cb98aa7ae626a88440cf7d570887e644296446343f412100c1fe8adb32c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 37dddbb69bbe521479a9a7da83a2fa2e2f803705c620f99df3e11eebd9eadf306bff464da87ae134ef5a528137c3544e6331e1d619a7e93321547a08041f6c6d
|
|
7
|
+
data.tar.gz: 78d52a028705b93be08302a28f364f6fb7e66e4184c2d6f35bf60390c7f41daff8309746a7dd5d8fd45bdb94a2bba880079d3e8300727b1b603319301d18ad45
|
data/Rakefile
CHANGED
|
@@ -159,6 +159,13 @@ namespace :prism do
|
|
|
159
159
|
puts "Vendoring '#{file}' Prism file to #{vendored_file_path}"
|
|
160
160
|
FileUtils.cp_r(prism_bundle_path + "/#{file}", prism_vendor_path)
|
|
161
161
|
end
|
|
162
|
+
|
|
163
|
+
prism_ast_header = "#{prism_vendor_path}/include/prism/ast.h"
|
|
164
|
+
|
|
165
|
+
unless File.exist?(prism_ast_header)
|
|
166
|
+
puts "Generating Prism template files..."
|
|
167
|
+
system("ruby #{prism_vendor_path}/templates/template.rb", exception: true)
|
|
168
|
+
end
|
|
162
169
|
end
|
|
163
170
|
|
|
164
171
|
desc "Clean vendored Prism in vendor/prism/"
|
data/config.yml
CHANGED
|
@@ -425,6 +425,9 @@ nodes:
|
|
|
425
425
|
- name: tag_closing
|
|
426
426
|
type: token
|
|
427
427
|
|
|
428
|
+
- name: then_keyword
|
|
429
|
+
type: location
|
|
430
|
+
|
|
428
431
|
# - name: predicate
|
|
429
432
|
# type: prism_node
|
|
430
433
|
|
|
@@ -479,6 +482,9 @@ nodes:
|
|
|
479
482
|
- name: tag_closing
|
|
480
483
|
type: token
|
|
481
484
|
|
|
485
|
+
- name: then_keyword
|
|
486
|
+
type: location
|
|
487
|
+
|
|
482
488
|
# - name: conditions
|
|
483
489
|
# type: array
|
|
484
490
|
# kind: prism_node
|
|
@@ -699,6 +705,9 @@ nodes:
|
|
|
699
705
|
- name: tag_closing
|
|
700
706
|
type: token
|
|
701
707
|
|
|
708
|
+
- name: then_keyword
|
|
709
|
+
type: location
|
|
710
|
+
|
|
702
711
|
# - name: predicate
|
|
703
712
|
# type: prism_node
|
|
704
713
|
|
|
@@ -736,6 +745,9 @@ nodes:
|
|
|
736
745
|
- name: tag_closing
|
|
737
746
|
type: token
|
|
738
747
|
|
|
748
|
+
- name: then_keyword
|
|
749
|
+
type: location
|
|
750
|
+
|
|
739
751
|
- name: statements
|
|
740
752
|
type: array
|
|
741
753
|
kind: Node
|
data/ext/herb/extconf.rb
CHANGED
data/ext/herb/nodes.c
CHANGED
|
@@ -464,7 +464,7 @@ static VALUE rb_erb_content_node_from_c_struct(AST_ERB_CONTENT_NODE_T* erb_conte
|
|
|
464
464
|
VALUE erb_content_node_tag_opening = rb_token_from_c_struct(erb_content_node->tag_opening);
|
|
465
465
|
VALUE erb_content_node_content = rb_token_from_c_struct(erb_content_node->content);
|
|
466
466
|
VALUE erb_content_node_tag_closing = rb_token_from_c_struct(erb_content_node->tag_closing);
|
|
467
|
-
/* #<Herb::Template::AnalyzedRubyField:
|
|
467
|
+
/* #<Herb::Template::AnalyzedRubyField:0x00007f0381d4abf8 @name="analyzed_ruby", @options={kind: nil}> */
|
|
468
468
|
VALUE erb_content_node_analyzed_ruby = Qnil;
|
|
469
469
|
VALUE erb_content_node_parsed = (erb_content_node->parsed) ? Qtrue : Qfalse;
|
|
470
470
|
VALUE erb_content_node_valid = (erb_content_node->valid) ? Qtrue : Qfalse;
|
|
@@ -566,23 +566,25 @@ static VALUE rb_erb_if_node_from_c_struct(AST_ERB_IF_NODE_T* erb_if_node) {
|
|
|
566
566
|
VALUE erb_if_node_tag_opening = rb_token_from_c_struct(erb_if_node->tag_opening);
|
|
567
567
|
VALUE erb_if_node_content = rb_token_from_c_struct(erb_if_node->content);
|
|
568
568
|
VALUE erb_if_node_tag_closing = rb_token_from_c_struct(erb_if_node->tag_closing);
|
|
569
|
+
VALUE erb_if_node_then_keyword = (erb_if_node->then_keyword != NULL) ? rb_location_from_c_struct(*erb_if_node->then_keyword) : Qnil;
|
|
569
570
|
VALUE erb_if_node_statements = rb_nodes_array_from_c_array(erb_if_node->statements);
|
|
570
571
|
VALUE erb_if_node_subsequent = rb_node_from_c_struct((AST_NODE_T*) erb_if_node->subsequent);
|
|
571
572
|
VALUE erb_if_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_if_node->end_node);
|
|
572
573
|
|
|
573
|
-
VALUE args[
|
|
574
|
+
VALUE args[10] = {
|
|
574
575
|
type,
|
|
575
576
|
location,
|
|
576
577
|
errors,
|
|
577
578
|
erb_if_node_tag_opening,
|
|
578
579
|
erb_if_node_content,
|
|
579
580
|
erb_if_node_tag_closing,
|
|
581
|
+
erb_if_node_then_keyword,
|
|
580
582
|
erb_if_node_statements,
|
|
581
583
|
erb_if_node_subsequent,
|
|
582
584
|
erb_if_node_end_node
|
|
583
585
|
};
|
|
584
586
|
|
|
585
|
-
return rb_class_new_instance(
|
|
587
|
+
return rb_class_new_instance(10, args, ERBIfNode);
|
|
586
588
|
};
|
|
587
589
|
|
|
588
590
|
static VALUE rb_erb_block_node_from_c_struct(AST_ERB_BLOCK_NODE_T* erb_block_node) {
|
|
@@ -638,19 +640,21 @@ static VALUE rb_erb_when_node_from_c_struct(AST_ERB_WHEN_NODE_T* erb_when_node)
|
|
|
638
640
|
VALUE erb_when_node_tag_opening = rb_token_from_c_struct(erb_when_node->tag_opening);
|
|
639
641
|
VALUE erb_when_node_content = rb_token_from_c_struct(erb_when_node->content);
|
|
640
642
|
VALUE erb_when_node_tag_closing = rb_token_from_c_struct(erb_when_node->tag_closing);
|
|
643
|
+
VALUE erb_when_node_then_keyword = (erb_when_node->then_keyword != NULL) ? rb_location_from_c_struct(*erb_when_node->then_keyword) : Qnil;
|
|
641
644
|
VALUE erb_when_node_statements = rb_nodes_array_from_c_array(erb_when_node->statements);
|
|
642
645
|
|
|
643
|
-
VALUE args[
|
|
646
|
+
VALUE args[8] = {
|
|
644
647
|
type,
|
|
645
648
|
location,
|
|
646
649
|
errors,
|
|
647
650
|
erb_when_node_tag_opening,
|
|
648
651
|
erb_when_node_content,
|
|
649
652
|
erb_when_node_tag_closing,
|
|
653
|
+
erb_when_node_then_keyword,
|
|
650
654
|
erb_when_node_statements
|
|
651
655
|
};
|
|
652
656
|
|
|
653
|
-
return rb_class_new_instance(
|
|
657
|
+
return rb_class_new_instance(8, args, ERBWhenNode);
|
|
654
658
|
};
|
|
655
659
|
|
|
656
660
|
static VALUE rb_erb_case_node_from_c_struct(AST_ERB_CASE_NODE_T* erb_case_node) {
|
|
@@ -963,23 +967,25 @@ static VALUE rb_erb_unless_node_from_c_struct(AST_ERB_UNLESS_NODE_T* erb_unless_
|
|
|
963
967
|
VALUE erb_unless_node_tag_opening = rb_token_from_c_struct(erb_unless_node->tag_opening);
|
|
964
968
|
VALUE erb_unless_node_content = rb_token_from_c_struct(erb_unless_node->content);
|
|
965
969
|
VALUE erb_unless_node_tag_closing = rb_token_from_c_struct(erb_unless_node->tag_closing);
|
|
970
|
+
VALUE erb_unless_node_then_keyword = (erb_unless_node->then_keyword != NULL) ? rb_location_from_c_struct(*erb_unless_node->then_keyword) : Qnil;
|
|
966
971
|
VALUE erb_unless_node_statements = rb_nodes_array_from_c_array(erb_unless_node->statements);
|
|
967
972
|
VALUE erb_unless_node_else_clause = rb_node_from_c_struct((AST_NODE_T*) erb_unless_node->else_clause);
|
|
968
973
|
VALUE erb_unless_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_unless_node->end_node);
|
|
969
974
|
|
|
970
|
-
VALUE args[
|
|
975
|
+
VALUE args[10] = {
|
|
971
976
|
type,
|
|
972
977
|
location,
|
|
973
978
|
errors,
|
|
974
979
|
erb_unless_node_tag_opening,
|
|
975
980
|
erb_unless_node_content,
|
|
976
981
|
erb_unless_node_tag_closing,
|
|
982
|
+
erb_unless_node_then_keyword,
|
|
977
983
|
erb_unless_node_statements,
|
|
978
984
|
erb_unless_node_else_clause,
|
|
979
985
|
erb_unless_node_end_node
|
|
980
986
|
};
|
|
981
987
|
|
|
982
|
-
return rb_class_new_instance(
|
|
988
|
+
return rb_class_new_instance(10, args, ERBUnlessNode);
|
|
983
989
|
};
|
|
984
990
|
|
|
985
991
|
static VALUE rb_erb_yield_node_from_c_struct(AST_ERB_YIELD_NODE_T* erb_yield_node) {
|
|
@@ -1031,19 +1037,21 @@ static VALUE rb_erb_in_node_from_c_struct(AST_ERB_IN_NODE_T* erb_in_node) {
|
|
|
1031
1037
|
VALUE erb_in_node_tag_opening = rb_token_from_c_struct(erb_in_node->tag_opening);
|
|
1032
1038
|
VALUE erb_in_node_content = rb_token_from_c_struct(erb_in_node->content);
|
|
1033
1039
|
VALUE erb_in_node_tag_closing = rb_token_from_c_struct(erb_in_node->tag_closing);
|
|
1040
|
+
VALUE erb_in_node_then_keyword = (erb_in_node->then_keyword != NULL) ? rb_location_from_c_struct(*erb_in_node->then_keyword) : Qnil;
|
|
1034
1041
|
VALUE erb_in_node_statements = rb_nodes_array_from_c_array(erb_in_node->statements);
|
|
1035
1042
|
|
|
1036
|
-
VALUE args[
|
|
1043
|
+
VALUE args[8] = {
|
|
1037
1044
|
type,
|
|
1038
1045
|
location,
|
|
1039
1046
|
errors,
|
|
1040
1047
|
erb_in_node_tag_opening,
|
|
1041
1048
|
erb_in_node_content,
|
|
1042
1049
|
erb_in_node_tag_closing,
|
|
1050
|
+
erb_in_node_then_keyword,
|
|
1043
1051
|
erb_in_node_statements
|
|
1044
1052
|
};
|
|
1045
1053
|
|
|
1046
|
-
return rb_class_new_instance(
|
|
1054
|
+
return rb_class_new_instance(8, args, ERBInNode);
|
|
1047
1055
|
};
|
|
1048
1056
|
|
|
1049
1057
|
|
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/4.0/herb.so
CHANGED
|
Binary file
|
data/lib/herb/ast/nodes.rb
CHANGED
|
@@ -1277,16 +1277,18 @@ module Herb
|
|
|
1277
1277
|
attr_reader :tag_opening #: Herb::Token
|
|
1278
1278
|
attr_reader :content #: Herb::Token
|
|
1279
1279
|
attr_reader :tag_closing #: Herb::Token
|
|
1280
|
+
attr_reader :then_keyword #: Herb::Location
|
|
1280
1281
|
attr_reader :statements #: Array[Herb::AST::Node]
|
|
1281
1282
|
attr_reader :subsequent #: Herb::AST::Node
|
|
1282
1283
|
attr_reader :end_node #: Herb::AST::ERBEndNode
|
|
1283
1284
|
|
|
1284
|
-
#: (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Array[Herb::AST::Node], Herb::AST::Node, Herb::AST::ERBEndNode) -> void
|
|
1285
|
-
def initialize(type, location, errors, tag_opening, content, tag_closing, statements, subsequent, end_node)
|
|
1285
|
+
#: (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Herb::Location, Array[Herb::AST::Node], Herb::AST::Node, Herb::AST::ERBEndNode) -> void
|
|
1286
|
+
def initialize(type, location, errors, tag_opening, content, tag_closing, then_keyword, statements, subsequent, end_node)
|
|
1286
1287
|
super(type, location, errors)
|
|
1287
1288
|
@tag_opening = tag_opening
|
|
1288
1289
|
@content = content
|
|
1289
1290
|
@tag_closing = tag_closing
|
|
1291
|
+
@then_keyword = then_keyword
|
|
1290
1292
|
@statements = statements
|
|
1291
1293
|
@subsequent = subsequent
|
|
1292
1294
|
@end_node = end_node
|
|
@@ -1298,6 +1300,7 @@ module Herb
|
|
|
1298
1300
|
tag_opening: tag_opening,
|
|
1299
1301
|
content: content,
|
|
1300
1302
|
tag_closing: tag_closing,
|
|
1303
|
+
then_keyword: then_keyword,
|
|
1301
1304
|
statements: statements,
|
|
1302
1305
|
subsequent: subsequent,
|
|
1303
1306
|
end_node: end_node,
|
|
@@ -1348,6 +1351,9 @@ module Herb
|
|
|
1348
1351
|
output += white("├── tag_closing: ")
|
|
1349
1352
|
output += tag_closing ? tag_closing.tree_inspect : magenta("∅")
|
|
1350
1353
|
output += "\n"
|
|
1354
|
+
output += white("├── then_keyword: ")
|
|
1355
|
+
output += then_keyword ? dimmed("(location: #{then_keyword.tree_inspect})") : magenta("∅")
|
|
1356
|
+
output += "\n"
|
|
1351
1357
|
output += white("├── statements: ")
|
|
1352
1358
|
output += inspect_array(statements, prefix: "│ ", indent: indent, depth: depth + 1, depth_limit: depth_limit)
|
|
1353
1359
|
output += white("├── subsequent: ")
|
|
@@ -1468,14 +1474,16 @@ module Herb
|
|
|
1468
1474
|
attr_reader :tag_opening #: Herb::Token
|
|
1469
1475
|
attr_reader :content #: Herb::Token
|
|
1470
1476
|
attr_reader :tag_closing #: Herb::Token
|
|
1477
|
+
attr_reader :then_keyword #: Herb::Location
|
|
1471
1478
|
attr_reader :statements #: Array[Herb::AST::Node]
|
|
1472
1479
|
|
|
1473
|
-
#: (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Array[Herb::AST::Node]) -> void
|
|
1474
|
-
def initialize(type, location, errors, tag_opening, content, tag_closing, statements)
|
|
1480
|
+
#: (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Herb::Location, Array[Herb::AST::Node]) -> void
|
|
1481
|
+
def initialize(type, location, errors, tag_opening, content, tag_closing, then_keyword, statements)
|
|
1475
1482
|
super(type, location, errors)
|
|
1476
1483
|
@tag_opening = tag_opening
|
|
1477
1484
|
@content = content
|
|
1478
1485
|
@tag_closing = tag_closing
|
|
1486
|
+
@then_keyword = then_keyword
|
|
1479
1487
|
@statements = statements
|
|
1480
1488
|
end
|
|
1481
1489
|
|
|
@@ -1485,6 +1493,7 @@ module Herb
|
|
|
1485
1493
|
tag_opening: tag_opening,
|
|
1486
1494
|
content: content,
|
|
1487
1495
|
tag_closing: tag_closing,
|
|
1496
|
+
then_keyword: then_keyword,
|
|
1488
1497
|
statements: statements,
|
|
1489
1498
|
}) #: Herb::serialized_erb_when_node
|
|
1490
1499
|
end
|
|
@@ -1533,6 +1542,9 @@ module Herb
|
|
|
1533
1542
|
output += white("├── tag_closing: ")
|
|
1534
1543
|
output += tag_closing ? tag_closing.tree_inspect : magenta("∅")
|
|
1535
1544
|
output += "\n"
|
|
1545
|
+
output += white("├── then_keyword: ")
|
|
1546
|
+
output += then_keyword ? dimmed("(location: #{then_keyword.tree_inspect})") : magenta("∅")
|
|
1547
|
+
output += "\n"
|
|
1536
1548
|
output += white("└── statements: ")
|
|
1537
1549
|
output += inspect_array(statements, prefix: " ", indent: indent, depth: depth + 1, depth_limit: depth_limit)
|
|
1538
1550
|
output += "\n"
|
|
@@ -2321,16 +2333,18 @@ module Herb
|
|
|
2321
2333
|
attr_reader :tag_opening #: Herb::Token
|
|
2322
2334
|
attr_reader :content #: Herb::Token
|
|
2323
2335
|
attr_reader :tag_closing #: Herb::Token
|
|
2336
|
+
attr_reader :then_keyword #: Herb::Location
|
|
2324
2337
|
attr_reader :statements #: Array[Herb::AST::Node]
|
|
2325
2338
|
attr_reader :else_clause #: Herb::AST::ERBElseNode
|
|
2326
2339
|
attr_reader :end_node #: Herb::AST::ERBEndNode
|
|
2327
2340
|
|
|
2328
|
-
#: (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Array[Herb::AST::Node], Herb::AST::ERBElseNode, Herb::AST::ERBEndNode) -> void
|
|
2329
|
-
def initialize(type, location, errors, tag_opening, content, tag_closing, statements, else_clause, end_node)
|
|
2341
|
+
#: (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Herb::Location, Array[Herb::AST::Node], Herb::AST::ERBElseNode, Herb::AST::ERBEndNode) -> void
|
|
2342
|
+
def initialize(type, location, errors, tag_opening, content, tag_closing, then_keyword, statements, else_clause, end_node)
|
|
2330
2343
|
super(type, location, errors)
|
|
2331
2344
|
@tag_opening = tag_opening
|
|
2332
2345
|
@content = content
|
|
2333
2346
|
@tag_closing = tag_closing
|
|
2347
|
+
@then_keyword = then_keyword
|
|
2334
2348
|
@statements = statements
|
|
2335
2349
|
@else_clause = else_clause
|
|
2336
2350
|
@end_node = end_node
|
|
@@ -2342,6 +2356,7 @@ module Herb
|
|
|
2342
2356
|
tag_opening: tag_opening,
|
|
2343
2357
|
content: content,
|
|
2344
2358
|
tag_closing: tag_closing,
|
|
2359
|
+
then_keyword: then_keyword,
|
|
2345
2360
|
statements: statements,
|
|
2346
2361
|
else_clause: else_clause,
|
|
2347
2362
|
end_node: end_node,
|
|
@@ -2392,6 +2407,9 @@ module Herb
|
|
|
2392
2407
|
output += white("├── tag_closing: ")
|
|
2393
2408
|
output += tag_closing ? tag_closing.tree_inspect : magenta("∅")
|
|
2394
2409
|
output += "\n"
|
|
2410
|
+
output += white("├── then_keyword: ")
|
|
2411
|
+
output += then_keyword ? dimmed("(location: #{then_keyword.tree_inspect})") : magenta("∅")
|
|
2412
|
+
output += "\n"
|
|
2395
2413
|
output += white("├── statements: ")
|
|
2396
2414
|
output += inspect_array(statements, prefix: "│ ", indent: indent, depth: depth + 1, depth_limit: depth_limit)
|
|
2397
2415
|
output += white("├── else_clause: ")
|
|
@@ -2496,14 +2514,16 @@ module Herb
|
|
|
2496
2514
|
attr_reader :tag_opening #: Herb::Token
|
|
2497
2515
|
attr_reader :content #: Herb::Token
|
|
2498
2516
|
attr_reader :tag_closing #: Herb::Token
|
|
2517
|
+
attr_reader :then_keyword #: Herb::Location
|
|
2499
2518
|
attr_reader :statements #: Array[Herb::AST::Node]
|
|
2500
2519
|
|
|
2501
|
-
#: (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Array[Herb::AST::Node]) -> void
|
|
2502
|
-
def initialize(type, location, errors, tag_opening, content, tag_closing, statements)
|
|
2520
|
+
#: (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Herb::Location, Array[Herb::AST::Node]) -> void
|
|
2521
|
+
def initialize(type, location, errors, tag_opening, content, tag_closing, then_keyword, statements)
|
|
2503
2522
|
super(type, location, errors)
|
|
2504
2523
|
@tag_opening = tag_opening
|
|
2505
2524
|
@content = content
|
|
2506
2525
|
@tag_closing = tag_closing
|
|
2526
|
+
@then_keyword = then_keyword
|
|
2507
2527
|
@statements = statements
|
|
2508
2528
|
end
|
|
2509
2529
|
|
|
@@ -2513,6 +2533,7 @@ module Herb
|
|
|
2513
2533
|
tag_opening: tag_opening,
|
|
2514
2534
|
content: content,
|
|
2515
2535
|
tag_closing: tag_closing,
|
|
2536
|
+
then_keyword: then_keyword,
|
|
2516
2537
|
statements: statements,
|
|
2517
2538
|
}) #: Herb::serialized_erb_in_node
|
|
2518
2539
|
end
|
|
@@ -2561,6 +2582,9 @@ module Herb
|
|
|
2561
2582
|
output += white("├── tag_closing: ")
|
|
2562
2583
|
output += tag_closing ? tag_closing.tree_inspect : magenta("∅")
|
|
2563
2584
|
output += "\n"
|
|
2585
|
+
output += white("├── then_keyword: ")
|
|
2586
|
+
output += then_keyword ? dimmed("(location: #{then_keyword.tree_inspect})") : magenta("∅")
|
|
2587
|
+
output += "\n"
|
|
2564
2588
|
output += white("└── statements: ")
|
|
2565
2589
|
output += inspect_array(statements, prefix: " ", indent: indent, depth: depth + 1, depth_limit: depth_limit)
|
|
2566
2590
|
output += "\n"
|
|
@@ -301,7 +301,7 @@ module Herb
|
|
|
301
301
|
end
|
|
302
302
|
|
|
303
303
|
def in_excluded_context?
|
|
304
|
-
excluded_tags = ["script", "style", "head", "textarea", "pre"]
|
|
304
|
+
excluded_tags = ["script", "style", "head", "textarea", "pre", "svg", "math"]
|
|
305
305
|
return true if excluded_tags.any? { |tag| @element_stack.include?(tag) }
|
|
306
306
|
|
|
307
307
|
return true if @erb_block_stack.any? { |node| javascript_tag?(node.content.value.strip) }
|
data/lib/herb/version.rb
CHANGED
data/lib/herb.rb
CHANGED
|
@@ -31,9 +31,36 @@ require_relative "herb/engine"
|
|
|
31
31
|
|
|
32
32
|
begin
|
|
33
33
|
major, minor, _patch = RUBY_VERSION.split(".") #: [String, String, String]
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
|
|
35
|
+
if RUBY_PATCHLEVEL == -1
|
|
36
|
+
require_relative "herb/herb"
|
|
37
|
+
else
|
|
38
|
+
begin
|
|
39
|
+
require_relative "herb/#{major}.#{minor}/herb"
|
|
40
|
+
rescue LoadError
|
|
41
|
+
require_relative "herb/herb"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
rescue LoadError => e
|
|
45
|
+
raise LoadError, <<~MESSAGE
|
|
46
|
+
Failed to load the Herb native extension.
|
|
47
|
+
|
|
48
|
+
Tried to load: #{e.message.split(" -- ").last}
|
|
49
|
+
|
|
50
|
+
This can happen when:
|
|
51
|
+
1. You're using a preview/development version of Ruby (RUBY_PATCHLEVEL=#{RUBY_PATCHLEVEL})
|
|
52
|
+
2. The native extension wasn't compiled during gem installation
|
|
53
|
+
3. Required build tools (C compiler) were missing during installation
|
|
54
|
+
|
|
55
|
+
To fix, try reinstalling with source compilation:
|
|
56
|
+
gem install herb --platform ruby
|
|
57
|
+
|
|
58
|
+
If compilation fails, install a C compiler first:
|
|
59
|
+
- macOS: xcode-select --install
|
|
60
|
+
- Ubuntu/Debian: apt-get install build-essential
|
|
61
|
+
- Fedora/RHEL: dnf install make gcc
|
|
62
|
+
- Alpine: apk add build-base
|
|
63
|
+
MESSAGE
|
|
37
64
|
end
|
|
38
65
|
|
|
39
66
|
module Herb
|
data/sig/herb/ast/nodes.rbs
CHANGED
|
@@ -540,14 +540,16 @@ module Herb
|
|
|
540
540
|
|
|
541
541
|
attr_reader tag_closing: Herb::Token
|
|
542
542
|
|
|
543
|
+
attr_reader then_keyword: Herb::Location
|
|
544
|
+
|
|
543
545
|
attr_reader statements: Array[Herb::AST::Node]
|
|
544
546
|
|
|
545
547
|
attr_reader subsequent: Herb::AST::Node
|
|
546
548
|
|
|
547
549
|
attr_reader end_node: Herb::AST::ERBEndNode
|
|
548
550
|
|
|
549
|
-
# : (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Array[Herb::AST::Node], Herb::AST::Node, Herb::AST::ERBEndNode) -> void
|
|
550
|
-
def initialize: (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Array[Herb::AST::Node], Herb::AST::Node, Herb::AST::ERBEndNode) -> void
|
|
551
|
+
# : (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Herb::Location, Array[Herb::AST::Node], Herb::AST::Node, Herb::AST::ERBEndNode) -> void
|
|
552
|
+
def initialize: (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Herb::Location, Array[Herb::AST::Node], Herb::AST::Node, Herb::AST::ERBEndNode) -> void
|
|
551
553
|
|
|
552
554
|
# : () -> serialized_erb_if_node
|
|
553
555
|
def to_hash: () -> serialized_erb_if_node
|
|
@@ -612,10 +614,12 @@ module Herb
|
|
|
612
614
|
|
|
613
615
|
attr_reader tag_closing: Herb::Token
|
|
614
616
|
|
|
617
|
+
attr_reader then_keyword: Herb::Location
|
|
618
|
+
|
|
615
619
|
attr_reader statements: Array[Herb::AST::Node]
|
|
616
620
|
|
|
617
|
-
# : (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Array[Herb::AST::Node]) -> void
|
|
618
|
-
def initialize: (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Array[Herb::AST::Node]) -> void
|
|
621
|
+
# : (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Herb::Location, Array[Herb::AST::Node]) -> void
|
|
622
|
+
def initialize: (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Herb::Location, Array[Herb::AST::Node]) -> void
|
|
619
623
|
|
|
620
624
|
# : () -> serialized_erb_when_node
|
|
621
625
|
def to_hash: () -> serialized_erb_when_node
|
|
@@ -937,14 +941,16 @@ module Herb
|
|
|
937
941
|
|
|
938
942
|
attr_reader tag_closing: Herb::Token
|
|
939
943
|
|
|
944
|
+
attr_reader then_keyword: Herb::Location
|
|
945
|
+
|
|
940
946
|
attr_reader statements: Array[Herb::AST::Node]
|
|
941
947
|
|
|
942
948
|
attr_reader else_clause: Herb::AST::ERBElseNode
|
|
943
949
|
|
|
944
950
|
attr_reader end_node: Herb::AST::ERBEndNode
|
|
945
951
|
|
|
946
|
-
# : (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Array[Herb::AST::Node], Herb::AST::ERBElseNode, Herb::AST::ERBEndNode) -> void
|
|
947
|
-
def initialize: (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Array[Herb::AST::Node], Herb::AST::ERBElseNode, Herb::AST::ERBEndNode) -> void
|
|
952
|
+
# : (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Herb::Location, Array[Herb::AST::Node], Herb::AST::ERBElseNode, Herb::AST::ERBEndNode) -> void
|
|
953
|
+
def initialize: (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Herb::Location, Array[Herb::AST::Node], Herb::AST::ERBElseNode, Herb::AST::ERBEndNode) -> void
|
|
948
954
|
|
|
949
955
|
# : () -> serialized_erb_unless_node
|
|
950
956
|
def to_hash: () -> serialized_erb_unless_node
|
|
@@ -1005,10 +1011,12 @@ module Herb
|
|
|
1005
1011
|
|
|
1006
1012
|
attr_reader tag_closing: Herb::Token
|
|
1007
1013
|
|
|
1014
|
+
attr_reader then_keyword: Herb::Location
|
|
1015
|
+
|
|
1008
1016
|
attr_reader statements: Array[Herb::AST::Node]
|
|
1009
1017
|
|
|
1010
|
-
# : (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Array[Herb::AST::Node]) -> void
|
|
1011
|
-
def initialize: (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Array[Herb::AST::Node]) -> void
|
|
1018
|
+
# : (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Herb::Location, Array[Herb::AST::Node]) -> void
|
|
1019
|
+
def initialize: (String, Location, Array[Herb::Errors::Error], Herb::Token, Herb::Token, Herb::Token, Herb::Location, Array[Herb::AST::Node]) -> void
|
|
1012
1020
|
|
|
1013
1021
|
# : () -> serialized_erb_in_node
|
|
1014
1022
|
def to_hash: () -> serialized_erb_in_node
|
|
@@ -112,6 +112,7 @@ module Herb
|
|
|
112
112
|
tag_opening: Herb::Token,
|
|
113
113
|
content: Herb::Token,
|
|
114
114
|
tag_closing: Herb::Token,
|
|
115
|
+
then_keyword: Herb::Location,
|
|
115
116
|
statements: Array[Herb::AST::Node],
|
|
116
117
|
subsequent: Herb::AST::Node,
|
|
117
118
|
end_node: Herb::AST::ERBEndNode,
|
|
@@ -129,6 +130,7 @@ module Herb
|
|
|
129
130
|
tag_opening: Herb::Token,
|
|
130
131
|
content: Herb::Token,
|
|
131
132
|
tag_closing: Herb::Token,
|
|
133
|
+
then_keyword: Herb::Location,
|
|
132
134
|
statements: Array[Herb::AST::Node],
|
|
133
135
|
}
|
|
134
136
|
|
|
@@ -206,6 +208,7 @@ module Herb
|
|
|
206
208
|
tag_opening: Herb::Token,
|
|
207
209
|
content: Herb::Token,
|
|
208
210
|
tag_closing: Herb::Token,
|
|
211
|
+
then_keyword: Herb::Location,
|
|
209
212
|
statements: Array[Herb::AST::Node],
|
|
210
213
|
else_clause: Herb::AST::ERBElseNode,
|
|
211
214
|
end_node: Herb::AST::ERBEndNode,
|
|
@@ -221,6 +224,7 @@ module Herb
|
|
|
221
224
|
tag_opening: Herb::Token,
|
|
222
225
|
content: Herb::Token,
|
|
223
226
|
tag_closing: Herb::Token,
|
|
227
|
+
then_keyword: Herb::Location,
|
|
224
228
|
statements: Array[Herb::AST::Node],
|
|
225
229
|
}
|
|
226
230
|
|