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.
- checksums.yaml +7 -0
- data/License.txt +21 -0
- data/Makefile +121 -0
- data/README.md +166 -0
- data/Rakefile +184 -0
- data/exe/herb +5 -0
- data/ext/herb/error_helpers.c +302 -0
- data/ext/herb/error_helpers.h +15 -0
- data/ext/herb/extconf.rb +75 -0
- data/ext/herb/extension.c +110 -0
- data/ext/herb/extension.h +6 -0
- data/ext/herb/extension_helpers.c +117 -0
- data/ext/herb/extension_helpers.h +24 -0
- data/ext/herb/nodes.c +936 -0
- data/ext/herb/nodes.h +12 -0
- data/herb.gemspec +49 -0
- 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/node.rb +61 -0
- data/lib/herb/ast/nodes.rb +1542 -0
- data/lib/herb/ast.rb +6 -0
- data/lib/herb/cli.rb +164 -0
- data/lib/herb/errors.rb +352 -0
- data/lib/herb/lex_result.rb +20 -0
- data/lib/herb/libherb/array.rb +48 -0
- data/lib/herb/libherb/ast_node.rb +47 -0
- data/lib/herb/libherb/buffer.rb +53 -0
- data/lib/herb/libherb/extract_result.rb +17 -0
- data/lib/herb/libherb/lex_result.rb +29 -0
- data/lib/herb/libherb/libherb.rb +49 -0
- data/lib/herb/libherb/parse_result.rb +17 -0
- data/lib/herb/libherb/token.rb +43 -0
- data/lib/herb/libherb.rb +32 -0
- data/lib/herb/location.rb +42 -0
- data/lib/herb/parse_result.rb +26 -0
- data/lib/herb/position.rb +36 -0
- data/lib/herb/project.rb +361 -0
- data/lib/herb/range.rb +40 -0
- data/lib/herb/result.rb +21 -0
- data/lib/herb/token.rb +43 -0
- data/lib/herb/token_list.rb +11 -0
- data/lib/herb/version.rb +5 -0
- data/lib/herb.rb +32 -0
- data/src/analyze.c +989 -0
- data/src/analyze_helpers.c +241 -0
- data/src/analyzed_ruby.c +35 -0
- data/src/array.c +137 -0
- data/src/ast_node.c +81 -0
- data/src/ast_nodes.c +866 -0
- data/src/ast_pretty_print.c +588 -0
- data/src/buffer.c +199 -0
- data/src/errors.c +740 -0
- data/src/extract.c +110 -0
- data/src/herb.c +103 -0
- data/src/html_util.c +143 -0
- data/src/include/analyze.h +36 -0
- data/src/include/analyze_helpers.h +43 -0
- data/src/include/analyzed_ruby.h +33 -0
- data/src/include/array.h +33 -0
- data/src/include/ast_node.h +35 -0
- data/src/include/ast_nodes.h +303 -0
- data/src/include/ast_pretty_print.h +17 -0
- data/src/include/buffer.h +36 -0
- data/src/include/errors.h +125 -0
- data/src/include/extract.h +20 -0
- data/src/include/herb.h +32 -0
- data/src/include/html_util.h +13 -0
- data/src/include/io.h +9 -0
- data/src/include/json.h +28 -0
- data/src/include/lexer.h +13 -0
- data/src/include/lexer_peek_helpers.h +23 -0
- data/src/include/lexer_struct.h +32 -0
- data/src/include/location.h +25 -0
- data/src/include/macros.h +10 -0
- data/src/include/memory.h +12 -0
- data/src/include/parser.h +22 -0
- data/src/include/parser_helpers.h +33 -0
- data/src/include/position.h +22 -0
- data/src/include/pretty_print.h +53 -0
- data/src/include/prism_helpers.h +18 -0
- data/src/include/range.h +23 -0
- data/src/include/ruby_parser.h +6 -0
- data/src/include/token.h +25 -0
- data/src/include/token_matchers.h +21 -0
- data/src/include/token_struct.h +51 -0
- data/src/include/util.h +25 -0
- data/src/include/version.h +6 -0
- data/src/include/visitor.h +11 -0
- data/src/io.c +30 -0
- data/src/json.c +205 -0
- data/src/lexer.c +284 -0
- data/src/lexer_peek_helpers.c +59 -0
- data/src/location.c +41 -0
- data/src/main.c +162 -0
- data/src/memory.c +53 -0
- data/src/parser.c +704 -0
- data/src/parser_helpers.c +161 -0
- data/src/position.c +33 -0
- data/src/pretty_print.c +242 -0
- data/src/prism_helpers.c +50 -0
- data/src/range.c +38 -0
- data/src/ruby_parser.c +47 -0
- data/src/token.c +194 -0
- data/src/token_matchers.c +32 -0
- data/src/util.c +128 -0
- data/src/visitor.c +321 -0
- 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
|