herb 0.1.0-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.
Files changed (110) hide show
  1. checksums.yaml +7 -0
  2. data/License.txt +21 -0
  3. data/Makefile +121 -0
  4. data/README.md +166 -0
  5. data/Rakefile +184 -0
  6. data/exe/herb +5 -0
  7. data/ext/herb/error_helpers.c +302 -0
  8. data/ext/herb/error_helpers.h +15 -0
  9. data/ext/herb/extconf.rb +75 -0
  10. data/ext/herb/extension.c +110 -0
  11. data/ext/herb/extension.h +6 -0
  12. data/ext/herb/extension_helpers.c +117 -0
  13. data/ext/herb/extension_helpers.h +24 -0
  14. data/ext/herb/nodes.c +936 -0
  15. data/ext/herb/nodes.h +12 -0
  16. data/herb.gemspec +49 -0
  17. data/lib/herb/3.0/herb.so +0 -0
  18. data/lib/herb/3.1/herb.so +0 -0
  19. data/lib/herb/3.2/herb.so +0 -0
  20. data/lib/herb/3.3/herb.so +0 -0
  21. data/lib/herb/3.4/herb.so +0 -0
  22. data/lib/herb/ast/node.rb +61 -0
  23. data/lib/herb/ast/nodes.rb +1542 -0
  24. data/lib/herb/ast.rb +6 -0
  25. data/lib/herb/cli.rb +164 -0
  26. data/lib/herb/errors.rb +352 -0
  27. data/lib/herb/lex_result.rb +20 -0
  28. data/lib/herb/libherb/array.rb +48 -0
  29. data/lib/herb/libherb/ast_node.rb +47 -0
  30. data/lib/herb/libherb/buffer.rb +53 -0
  31. data/lib/herb/libherb/extract_result.rb +17 -0
  32. data/lib/herb/libherb/lex_result.rb +29 -0
  33. data/lib/herb/libherb/libherb.rb +49 -0
  34. data/lib/herb/libherb/parse_result.rb +17 -0
  35. data/lib/herb/libherb/token.rb +43 -0
  36. data/lib/herb/libherb.rb +32 -0
  37. data/lib/herb/location.rb +42 -0
  38. data/lib/herb/parse_result.rb +26 -0
  39. data/lib/herb/position.rb +36 -0
  40. data/lib/herb/project.rb +361 -0
  41. data/lib/herb/range.rb +40 -0
  42. data/lib/herb/result.rb +21 -0
  43. data/lib/herb/token.rb +43 -0
  44. data/lib/herb/token_list.rb +11 -0
  45. data/lib/herb/version.rb +5 -0
  46. data/lib/herb.rb +32 -0
  47. data/src/analyze.c +989 -0
  48. data/src/analyze_helpers.c +241 -0
  49. data/src/analyzed_ruby.c +35 -0
  50. data/src/array.c +137 -0
  51. data/src/ast_node.c +81 -0
  52. data/src/ast_nodes.c +866 -0
  53. data/src/ast_pretty_print.c +588 -0
  54. data/src/buffer.c +199 -0
  55. data/src/errors.c +740 -0
  56. data/src/extract.c +110 -0
  57. data/src/herb.c +103 -0
  58. data/src/html_util.c +143 -0
  59. data/src/include/analyze.h +36 -0
  60. data/src/include/analyze_helpers.h +43 -0
  61. data/src/include/analyzed_ruby.h +33 -0
  62. data/src/include/array.h +33 -0
  63. data/src/include/ast_node.h +35 -0
  64. data/src/include/ast_nodes.h +303 -0
  65. data/src/include/ast_pretty_print.h +17 -0
  66. data/src/include/buffer.h +36 -0
  67. data/src/include/errors.h +125 -0
  68. data/src/include/extract.h +20 -0
  69. data/src/include/herb.h +32 -0
  70. data/src/include/html_util.h +13 -0
  71. data/src/include/io.h +9 -0
  72. data/src/include/json.h +28 -0
  73. data/src/include/lexer.h +13 -0
  74. data/src/include/lexer_peek_helpers.h +23 -0
  75. data/src/include/lexer_struct.h +32 -0
  76. data/src/include/location.h +25 -0
  77. data/src/include/macros.h +10 -0
  78. data/src/include/memory.h +12 -0
  79. data/src/include/parser.h +22 -0
  80. data/src/include/parser_helpers.h +33 -0
  81. data/src/include/position.h +22 -0
  82. data/src/include/pretty_print.h +53 -0
  83. data/src/include/prism_helpers.h +18 -0
  84. data/src/include/range.h +23 -0
  85. data/src/include/ruby_parser.h +6 -0
  86. data/src/include/token.h +25 -0
  87. data/src/include/token_matchers.h +21 -0
  88. data/src/include/token_struct.h +51 -0
  89. data/src/include/util.h +25 -0
  90. data/src/include/version.h +6 -0
  91. data/src/include/visitor.h +11 -0
  92. data/src/io.c +30 -0
  93. data/src/json.c +205 -0
  94. data/src/lexer.c +284 -0
  95. data/src/lexer_peek_helpers.c +59 -0
  96. data/src/location.c +41 -0
  97. data/src/main.c +162 -0
  98. data/src/memory.c +53 -0
  99. data/src/parser.c +704 -0
  100. data/src/parser_helpers.c +161 -0
  101. data/src/position.c +33 -0
  102. data/src/pretty_print.c +242 -0
  103. data/src/prism_helpers.c +50 -0
  104. data/src/range.c +38 -0
  105. data/src/ruby_parser.c +47 -0
  106. data/src/token.c +194 -0
  107. data/src/token_matchers.c +32 -0
  108. data/src/util.c +128 -0
  109. data/src/visitor.c +321 -0
  110. metadata +159 -0
data/ext/herb/nodes.h ADDED
@@ -0,0 +1,12 @@
1
+ // NOTE: This file is generated by the templates/template.rb script and should not
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release/templates/ext/herb/nodes.h.erb
3
+
4
+ #ifndef HERB_EXTENSION_NODES_H
5
+ #define HERB_EXTENSION_NODES_H
6
+
7
+ #include "../../src/include/herb.h"
8
+ #include <ruby.h>
9
+
10
+ VALUE rb_node_from_c_struct(AST_NODE_T* node);
11
+
12
+ #endif
data/herb.gemspec ADDED
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require_relative "lib/herb/version"
5
+ rescue LoadError
6
+ puts "WARNING: Could not load Herb::VERSION"
7
+ end
8
+
9
+ Gem::Specification.new do |spec|
10
+ spec.name = "herb"
11
+ spec.version = defined?(Herb::VERSION) ? Herb::VERSION : "0.0.0"
12
+ spec.authors = ["Marco Roth"]
13
+ spec.email = ["marco.roth@intergga.ch"]
14
+
15
+ spec.summary = "Powerful and seamless HTML-aware ERB parsing."
16
+ spec.description = spec.summary
17
+ spec.homepage = "https://herb-tools.dev"
18
+ spec.license = "MIT"
19
+
20
+ spec.required_ruby_version = ">= 3.0.0"
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.files = Dir[
24
+ "herb.gemspec",
25
+ "License.txt",
26
+ "Makefile",
27
+ "Rakefile",
28
+ "README.md",
29
+ "lib/**/*.rb",
30
+ "src/**/*.{c,h}",
31
+ "ext/**/*.{c,h}",
32
+ "exe/*"
33
+ ]
34
+
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
37
+ spec.extensions = ["ext/herb/extconf.rb"]
38
+
39
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
40
+ spec.metadata["rubygems_mfa_required"] = "true"
41
+
42
+ spec.metadata["homepage_uri"] = "https://herb-tools.dev"
43
+ spec.metadata["changelog_uri"] = "https://github.com/marcoroth/herb/releases"
44
+ spec.metadata["source_code_uri"] = "https://github.com/marcoroth/herb"
45
+ spec.metadata["bug_tracker_uri"] = "https://github.com/marcoroth/herb/issues"
46
+ spec.metadata["documentation_uri"] = "https://docs.herb-tools.dev"
47
+
48
+ # spec.add_dependency "ffi"
49
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Herb
4
+ module AST
5
+ class Node
6
+ attr_reader :type, :location, :errors
7
+
8
+ def initialize(type, location, errors = [])
9
+ @type = type
10
+ @location = location
11
+ @errors = errors
12
+ end
13
+
14
+ def to_hash
15
+ {
16
+ type: type,
17
+ location: location&.to_hash,
18
+ errors: errors.map(&:to_hash),
19
+ }
20
+ end
21
+
22
+ def node_name
23
+ self.class.name.split("::").last
24
+ end
25
+
26
+ def to_json(*args)
27
+ to_hash.to_json(*args)
28
+ end
29
+
30
+ def inspect_errors(prefix: " ")
31
+ return "" if errors.empty?
32
+
33
+ "├── errors: #{inspect_array(errors, item_name: "error", prefix: prefix)}"
34
+ end
35
+
36
+ def inspect_array(array, item_name: "item", prefix: " ")
37
+ output = +""
38
+
39
+ if array.any?
40
+ output += "(#{array.count} #{array.count == 1 ? item_name : "#{item_name}s"})"
41
+ output += "\n"
42
+
43
+ items = array.map { |item|
44
+ if array.last == item
45
+ "└── #{item.tree_inspect.gsub(/^/, " ").lstrip}"
46
+ else
47
+ "├── #{item.tree_inspect.gsub(/^/, "│ ")}".gsub("├── │ ", "├──")
48
+ end
49
+ }
50
+
51
+ output += items.join.gsub(/^/, prefix)
52
+ else
53
+ output += "[]"
54
+ output += "\n"
55
+ end
56
+
57
+ output
58
+ end
59
+ end
60
+ end
61
+ end