herb 0.8.9-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 (221) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +33 -11
  3. data/README.md +64 -34
  4. data/Rakefile +48 -40
  5. data/config.yml +323 -33
  6. data/ext/herb/error_helpers.c +384 -132
  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 +83 -14
  30. data/lib/herb/engine/debug_visitor.rb +51 -6
  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 +92 -33
  36. data/lib/herb/errors.rb +582 -87
  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 +8 -0
  57. data/sig/herb/engine/validator.rbs +5 -1
  58. data/sig/herb/engine.rbs +18 -2
  59. data/sig/herb/errors.rbs +268 -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 +57 -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} +79 -31
  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 +1099 -506
  97. data/src/extract.c +148 -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} +22 -17
  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 +154 -53
  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/string.h +11 -0
  146. data/src/include/util.h +6 -3
  147. data/src/include/version.h +1 -1
  148. data/src/io.c +3 -2
  149. data/src/lexer.c +42 -30
  150. data/src/lexer_peek_helpers.c +12 -74
  151. data/src/location.c +2 -2
  152. data/src/main.c +79 -66
  153. data/src/parser.c +784 -247
  154. data/src/parser_helpers.c +110 -23
  155. data/src/parser_match_tags.c +109 -48
  156. data/src/pretty_print.c +29 -24
  157. data/src/prism_helpers.c +30 -27
  158. data/src/ruby_parser.c +2 -0
  159. data/src/token.c +151 -66
  160. data/src/token_matchers.c +0 -1
  161. data/src/utf8.c +7 -6
  162. data/src/util/hb_allocator.c +341 -0
  163. data/src/util/hb_arena.c +81 -56
  164. data/src/util/hb_arena_debug.c +32 -17
  165. data/src/util/hb_array.c +30 -15
  166. data/src/util/hb_buffer.c +17 -21
  167. data/src/util/hb_narray.c +22 -7
  168. data/src/util/hb_string.c +49 -35
  169. data/src/util.c +21 -11
  170. data/src/visitor.c +47 -0
  171. data/templates/ext/herb/error_helpers.c.erb +24 -11
  172. data/templates/ext/herb/error_helpers.h.erb +1 -0
  173. data/templates/ext/herb/nodes.c.erb +50 -16
  174. data/templates/ext/herb/nodes.h.erb +1 -0
  175. data/templates/java/error_helpers.c.erb +1 -1
  176. data/templates/java/nodes.c.erb +30 -8
  177. data/templates/java/org/herb/ast/Errors.java.erb +24 -1
  178. data/templates/java/org/herb/ast/Nodes.java.erb +80 -21
  179. data/templates/javascript/packages/core/src/errors.ts.erb +16 -3
  180. data/templates/javascript/packages/core/src/node-type-guards.ts.erb +3 -1
  181. data/templates/javascript/packages/core/src/nodes.ts.erb +109 -32
  182. data/templates/javascript/packages/node/extension/error_helpers.cpp.erb +13 -4
  183. data/templates/javascript/packages/node/extension/nodes.cpp.erb +43 -4
  184. data/templates/lib/herb/ast/nodes.rb.erb +88 -31
  185. data/templates/lib/herb/errors.rb.erb +15 -3
  186. data/templates/lib/herb/visitor.rb.erb +2 -2
  187. data/templates/rust/src/ast/nodes.rs.erb +97 -44
  188. data/templates/rust/src/errors.rs.erb +2 -1
  189. data/templates/rust/src/nodes.rs.erb +167 -15
  190. data/templates/rust/src/union_types.rs.erb +60 -0
  191. data/templates/rust/src/visitor.rs.erb +81 -0
  192. data/templates/src/{analyze_missing_end.c.erb → analyze/missing_end.c.erb} +9 -6
  193. data/templates/src/{analyze_transform.c.erb → analyze/transform.c.erb} +2 -2
  194. data/templates/src/ast_nodes.c.erb +34 -26
  195. data/templates/src/ast_pretty_print.c.erb +24 -5
  196. data/templates/src/errors.c.erb +60 -54
  197. data/templates/src/include/ast_nodes.h.erb +6 -2
  198. data/templates/src/include/ast_pretty_print.h.erb +5 -0
  199. data/templates/src/include/errors.h.erb +15 -11
  200. data/templates/src/include/util/hb_foreach.h.erb +20 -0
  201. data/templates/src/parser_match_tags.c.erb +10 -4
  202. data/templates/src/visitor.c.erb +2 -2
  203. data/templates/template.rb +204 -29
  204. data/templates/wasm/error_helpers.cpp.erb +9 -5
  205. data/templates/wasm/nodes.cpp.erb +41 -4
  206. data/vendor/prism/config.yml +4 -4
  207. data/vendor/prism/include/prism/ast.h +4 -4
  208. data/vendor/prism/include/prism/version.h +2 -2
  209. data/vendor/prism/src/prism.c +1 -1
  210. data/vendor/prism/templates/java/org/prism/Loader.java.erb +1 -1
  211. data/vendor/prism/templates/javascript/src/deserialize.js.erb +1 -1
  212. data/vendor/prism/templates/lib/prism/node.rb.erb +23 -15
  213. data/vendor/prism/templates/lib/prism/serialize.rb.erb +1 -1
  214. data/vendor/prism/templates/rbi/prism/node.rbi.erb +3 -0
  215. data/vendor/prism/templates/sig/prism/node.rbs.erb +3 -0
  216. data/vendor/prism/templates/sig/prism.rbs.erb +9 -10
  217. metadata +58 -16
  218. data/src/analyze.c +0 -1594
  219. data/src/element_source.c +0 -12
  220. data/src/include/util/hb_system.h +0 -9
  221. data/src/util/hb_system.c +0 -30
data/lib/herb/range.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  # typed: true
3
3
 
4
4
  module Herb
5
+ #: type serialized_range = [Integer, Integer]
5
6
  class Range
6
7
  attr_reader :from #: Integer
7
8
  attr_reader :to #: Integer
data/lib/herb/token.rb CHANGED
@@ -2,6 +2,12 @@
2
2
  # typed: true
3
3
 
4
4
  module Herb
5
+ #: type serialized_token = {
6
+ #| value: String,
7
+ #| range: serialized_range?,
8
+ #| location: serialized_location?,
9
+ #| type: String
10
+ #| }
5
11
  class Token
6
12
  include Colors
7
13
 
@@ -25,7 +31,7 @@ module Herb
25
31
  range: range&.to_a,
26
32
  location: location&.to_hash,
27
33
  type: type,
28
- } #: Herb::serialized_token
34
+ }
29
35
  end
30
36
 
31
37
  #: (?untyped) -> String
data/lib/herb/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # typed: true
3
3
 
4
4
  module Herb
5
- VERSION = "0.8.9"
5
+ VERSION = "0.9.0"
6
6
  end
data/lib/herb/visitor.rb CHANGED
@@ -8,12 +8,12 @@ module Herb
8
8
  class Visitor
9
9
  include AST::Helpers
10
10
 
11
- #: (Herb::AST::Node) -> void
11
+ #: (Herb::AST::Node?) -> void
12
12
  def visit(node)
13
13
  node&.accept(self)
14
14
  end
15
15
 
16
- #: (Array[Herb::AST::Node]) -> void
16
+ #: (Array[Herb::AST::Node?]) -> void
17
17
  def visit_all(nodes)
18
18
  nodes.each { |node| node&.accept(self) }
19
19
  end
@@ -38,16 +38,36 @@ module Herb
38
38
  visit_child_nodes(node)
39
39
  end
40
40
 
41
+ #: (Herb::AST::HTMLConditionalOpenTagNode) -> void
42
+ def visit_html_conditional_open_tag_node(node)
43
+ visit_child_nodes(node)
44
+ end
45
+
41
46
  #: (Herb::AST::HTMLCloseTagNode) -> void
42
47
  def visit_html_close_tag_node(node)
43
48
  visit_child_nodes(node)
44
49
  end
45
50
 
51
+ #: (Herb::AST::HTMLOmittedCloseTagNode) -> void
52
+ def visit_html_omitted_close_tag_node(node)
53
+ visit_child_nodes(node)
54
+ end
55
+
56
+ #: (Herb::AST::HTMLVirtualCloseTagNode) -> void
57
+ def visit_html_virtual_close_tag_node(node)
58
+ visit_child_nodes(node)
59
+ end
60
+
46
61
  #: (Herb::AST::HTMLElementNode) -> void
47
62
  def visit_html_element_node(node)
48
63
  visit_child_nodes(node)
49
64
  end
50
65
 
66
+ #: (Herb::AST::HTMLConditionalElementNode) -> void
67
+ def visit_html_conditional_element_node(node)
68
+ visit_child_nodes(node)
69
+ end
70
+
51
71
  #: (Herb::AST::HTMLAttributeValueNode) -> void
52
72
  def visit_html_attribute_value_node(node)
53
73
  visit_child_nodes(node)
@@ -63,6 +83,21 @@ module Herb
63
83
  visit_child_nodes(node)
64
84
  end
65
85
 
86
+ #: (Herb::AST::RubyLiteralNode) -> void
87
+ def visit_ruby_literal_node(node)
88
+ visit_child_nodes(node)
89
+ end
90
+
91
+ #: (Herb::AST::RubyHTMLAttributesSplatNode) -> void
92
+ def visit_ruby_html_attributes_splat_node(node)
93
+ visit_child_nodes(node)
94
+ end
95
+
96
+ #: (Herb::AST::ERBOpenTagNode) -> void
97
+ def visit_erb_open_tag_node(node)
98
+ visit_child_nodes(node)
99
+ end
100
+
66
101
  #: (Herb::AST::HTMLTextNode) -> void
67
102
  def visit_html_text_node(node)
68
103
  visit_child_nodes(node)
data/lib/herb/warnings.rb CHANGED
@@ -3,9 +3,14 @@
3
3
 
4
4
  module Herb
5
5
  module Warnings
6
+ #: type serialized_warning = {
7
+ #| type: String,
8
+ #| location: serialized_location?,
9
+ #| message: String
10
+ #| }
6
11
  class Warning
7
12
  attr_reader :type #: String
8
- attr_reader :location #: Location
13
+ attr_reader :location #: Location?
9
14
  attr_reader :message #: String
10
15
 
11
16
  #: (String, Location, String) -> void
data/lib/herb.rb CHANGED
@@ -11,6 +11,7 @@ require_relative "herb/token_list"
11
11
 
12
12
  require_relative "herb/result"
13
13
  require_relative "herb/lex_result"
14
+ require_relative "herb/parser_options"
14
15
  require_relative "herb/parse_result"
15
16
 
16
17
  require_relative "herb/ast"
@@ -23,6 +24,7 @@ require_relative "herb/warnings"
23
24
 
24
25
  require_relative "herb/cli"
25
26
  require_relative "herb/project"
27
+ require_relative "herb/configuration"
26
28
 
27
29
  require_relative "herb/version"
28
30
 
@@ -33,12 +35,12 @@ begin
33
35
  major, minor, _patch = RUBY_VERSION.split(".") #: [String, String, String]
34
36
 
35
37
  if RUBY_PATCHLEVEL == -1
36
- require_relative "herb/herb"
38
+ require "herb/herb"
37
39
  else
38
40
  begin
39
- require_relative "herb/#{major}.#{minor}/herb"
41
+ require "herb/#{major}.#{minor}/herb"
40
42
  rescue LoadError
41
- require_relative "herb/herb"
43
+ require "herb/herb"
42
44
  end
43
45
  end
44
46
  rescue LoadError => e
@@ -64,4 +66,34 @@ rescue LoadError => e
64
66
  end
65
67
 
66
68
  module Herb
69
+ class << self
70
+ #: (String path, ?arena_stats: bool) -> LexResult
71
+ def lex_file(path, **options)
72
+ lex(File.read(path), **options)
73
+ end
74
+
75
+ #: (String path, ?track_whitespace: bool, ?analyze: bool, ?strict: bool, ?arena_stats: bool) -> ParseResult
76
+ def parse_file(path, **options)
77
+ parse(File.read(path), **options)
78
+ end
79
+
80
+ #: (String source) -> Prism::ParseResult
81
+ def parse_ruby(source)
82
+ require "prism"
83
+
84
+ Prism.parse(source)
85
+ end
86
+
87
+ def configuration(project_path = nil)
88
+ @configuration ||= Configuration.load(project_path)
89
+ end
90
+
91
+ def configure(project_path = nil)
92
+ @configuration = Configuration.load(project_path)
93
+ end
94
+
95
+ def reset_configuration!
96
+ @configuration = nil
97
+ end
98
+ end
67
99
  end
@@ -3,8 +3,8 @@
3
3
  module Herb
4
4
  module AST
5
5
  module Helpers
6
- # : (Herb::AST::Node) -> bool
7
- def erb_outputs?: (Herb::AST::Node) -> bool
6
+ # : (Herb::AST::Node?) -> bool
7
+ def erb_outputs?: (Herb::AST::Node?) -> bool
8
8
 
9
9
  # : (String) -> bool
10
10
  def erb_comment?: (String) -> bool
@@ -1,6 +1,11 @@
1
1
  # Generated from lib/herb/ast/node.rb with RBS::Inline
2
2
 
3
3
  module Herb
4
+ # : type serialized_node = {
5
+ # | type: String,
6
+ # | location: serialized_location?,
7
+ # | errors: Array[serialized_error]
8
+ # | }
4
9
  module AST
5
10
  class Node
6
11
  attr_reader type: String
@@ -9,8 +14,13 @@ module Herb
9
14
 
10
15
  attr_reader errors: Array[Herb::Errors::Error]
11
16
 
12
- # : (String, Location, Array[Herb::Errors::Error]) -> void
13
- def initialize: (String, Location, Array[Herb::Errors::Error]) -> void
17
+ attr_reader source: String?
18
+
19
+ # : (String, Location, ?Array[Herb::Errors::Error]) -> void
20
+ def initialize: (String, Location, ?Array[Herb::Errors::Error]) -> void
21
+
22
+ # : (String?) -> void
23
+ def source=: (String?) -> void
14
24
 
15
25
  # : () -> serialized_node
16
26
  def to_hash: () -> serialized_node