@herb-tools/node 0.7.5 → 0.8.0
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.
- package/binding.gyp +8 -4
- package/dist/herb-node.esm.js +6 -6
- package/dist/herb-node.esm.js.map +1 -1
- package/extension/error_helpers.cpp +67 -9
- package/extension/error_helpers.h +4 -2
- package/extension/extension_helpers.cpp +12 -5
- package/extension/extension_helpers.h +4 -2
- package/extension/herb.cpp +10 -42
- package/extension/libherb/analyze.c +420 -171
- package/extension/libherb/analyze.h +10 -2
- package/extension/libherb/analyze_helpers.c +5 -0
- package/extension/libherb/analyze_helpers.h +3 -0
- package/extension/libherb/analyze_missing_end.c +147 -0
- package/extension/libherb/analyze_transform.c +196 -0
- package/extension/libherb/analyzed_ruby.c +23 -2
- package/extension/libherb/analyzed_ruby.h +4 -2
- package/extension/libherb/ast_node.c +5 -5
- package/extension/libherb/ast_node.h +2 -2
- package/extension/libherb/ast_nodes.c +180 -180
- package/extension/libherb/ast_nodes.h +68 -67
- package/extension/libherb/ast_pretty_print.c +233 -233
- package/extension/libherb/ast_pretty_print.h +3 -3
- package/extension/libherb/element_source.c +7 -6
- package/extension/libherb/element_source.h +3 -1
- package/extension/libherb/errors.c +247 -127
- package/extension/libherb/errors.h +31 -15
- package/extension/libherb/extract.c +92 -34
- package/extension/libherb/extract.h +4 -4
- package/extension/libherb/herb.c +37 -49
- package/extension/libherb/herb.h +6 -7
- package/extension/libherb/html_util.c +34 -96
- package/extension/libherb/html_util.h +4 -5
- package/extension/libherb/include/analyze.h +10 -2
- package/extension/libherb/include/analyze_helpers.h +3 -0
- package/extension/libherb/include/analyzed_ruby.h +4 -2
- package/extension/libherb/include/ast_node.h +2 -2
- package/extension/libherb/include/ast_nodes.h +68 -67
- package/extension/libherb/include/ast_pretty_print.h +3 -3
- package/extension/libherb/include/element_source.h +3 -1
- package/extension/libherb/include/errors.h +31 -15
- package/extension/libherb/include/extract.h +4 -4
- package/extension/libherb/include/herb.h +6 -7
- package/extension/libherb/include/html_util.h +4 -5
- package/extension/libherb/include/lexer.h +1 -3
- package/extension/libherb/include/lexer_peek_helpers.h +14 -14
- package/extension/libherb/include/lexer_struct.h +3 -2
- package/extension/libherb/include/macros.h +4 -0
- package/extension/libherb/include/parser.h +12 -6
- package/extension/libherb/include/parser_helpers.h +25 -15
- package/extension/libherb/include/pretty_print.h +38 -28
- package/extension/libherb/include/token.h +5 -8
- package/extension/libherb/include/utf8.h +3 -2
- package/extension/libherb/include/util/hb_arena.h +31 -0
- package/extension/libherb/include/util/hb_arena_debug.h +8 -0
- package/extension/libherb/include/util/hb_array.h +33 -0
- package/extension/libherb/include/util/hb_buffer.h +34 -0
- package/extension/libherb/include/util/hb_string.h +29 -0
- package/extension/libherb/include/util/hb_system.h +9 -0
- package/extension/libherb/include/util.h +3 -14
- package/extension/libherb/include/version.h +1 -1
- package/extension/libherb/include/visitor.h +1 -1
- package/extension/libherb/io.c +7 -4
- package/extension/libherb/lexer.c +61 -88
- package/extension/libherb/lexer.h +1 -3
- package/extension/libherb/lexer_peek_helpers.c +35 -37
- package/extension/libherb/lexer_peek_helpers.h +14 -14
- package/extension/libherb/lexer_struct.h +3 -2
- package/extension/libherb/macros.h +4 -0
- package/extension/libherb/main.c +19 -23
- package/extension/libherb/parser.c +282 -201
- package/extension/libherb/parser.h +12 -6
- package/extension/libherb/parser_helpers.c +46 -40
- package/extension/libherb/parser_helpers.h +25 -15
- package/extension/libherb/parser_match_tags.c +316 -0
- package/extension/libherb/pretty_print.c +82 -106
- package/extension/libherb/pretty_print.h +38 -28
- package/extension/libherb/token.c +18 -65
- package/extension/libherb/token.h +5 -8
- package/extension/libherb/utf8.c +4 -4
- package/extension/libherb/utf8.h +3 -2
- package/extension/libherb/util/hb_arena.c +179 -0
- package/extension/libherb/util/hb_arena.h +31 -0
- package/extension/libherb/util/hb_arena_debug.c +237 -0
- package/extension/libherb/util/hb_arena_debug.h +8 -0
- package/extension/libherb/{array.c → util/hb_array.c} +26 -27
- package/extension/libherb/util/hb_array.h +33 -0
- package/extension/libherb/util/hb_buffer.c +203 -0
- package/extension/libherb/util/hb_buffer.h +34 -0
- package/extension/libherb/util/hb_string.c +85 -0
- package/extension/libherb/util/hb_string.h +29 -0
- package/extension/libherb/util/hb_system.c +30 -0
- package/extension/libherb/util/hb_system.h +9 -0
- package/extension/libherb/util.c +29 -99
- package/extension/libherb/util.h +3 -14
- package/extension/libherb/version.h +1 -1
- package/extension/libherb/visitor.c +55 -55
- package/extension/libherb/visitor.h +1 -1
- package/extension/nodes.cpp +40 -40
- package/extension/nodes.h +2 -2
- package/extension/prism/include/prism/ast.h +31 -1
- package/extension/prism/include/prism/diagnostic.h +1 -0
- package/extension/prism/include/prism/version.h +3 -3
- package/extension/prism/src/diagnostic.c +3 -1
- package/extension/prism/src/prism.c +130 -71
- package/extension/prism/src/util/pm_string.c +6 -8
- package/package.json +3 -3
- package/extension/libherb/array.h +0 -33
- package/extension/libherb/buffer.c +0 -241
- package/extension/libherb/buffer.h +0 -39
- package/extension/libherb/include/array.h +0 -33
- package/extension/libherb/include/buffer.h +0 -39
- package/extension/libherb/include/json.h +0 -28
- package/extension/libherb/include/memory.h +0 -12
- package/extension/libherb/json.c +0 -205
- package/extension/libherb/json.h +0 -28
- package/extension/libherb/memory.c +0 -53
- package/extension/libherb/memory.h +0 -12
package/extension/libherb/main.c
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
#include "include/ast_node.h"
|
|
5
5
|
#include "include/ast_nodes.h"
|
|
6
6
|
#include "include/ast_pretty_print.h"
|
|
7
|
-
#include "include/buffer.h"
|
|
8
7
|
#include "include/extract.h"
|
|
9
8
|
#include "include/herb.h"
|
|
10
9
|
#include "include/io.h"
|
|
11
10
|
#include "include/ruby_parser.h"
|
|
11
|
+
#include "include/util/hb_buffer.h"
|
|
12
12
|
|
|
13
13
|
#include <stdio.h>
|
|
14
14
|
#include <string.h>
|
|
@@ -39,7 +39,6 @@ int main(const int argc, char* argv[]) {
|
|
|
39
39
|
printf("Herb 🌿 Powerful and seamless HTML-aware ERB parsing and tooling.\n\n");
|
|
40
40
|
|
|
41
41
|
printf("./herb lex [file] - Lex a file\n");
|
|
42
|
-
printf("./herb lex_json [file] - Lex a file and return the result as json.\n");
|
|
43
42
|
printf("./herb parse [file] - Parse a file\n");
|
|
44
43
|
printf("./herb ruby [file] - Extract Ruby from a file\n");
|
|
45
44
|
printf("./herb html [file] - Extract HTML from a file\n");
|
|
@@ -53,9 +52,9 @@ int main(const int argc, char* argv[]) {
|
|
|
53
52
|
return 1;
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
|
|
55
|
+
hb_buffer_T output;
|
|
57
56
|
|
|
58
|
-
if (!
|
|
57
|
+
if (!hb_buffer_init(&output, 4096)) { return 1; }
|
|
59
58
|
|
|
60
59
|
char* source = herb_read_file(argv[2]);
|
|
61
60
|
|
|
@@ -74,7 +73,7 @@ int main(const int argc, char* argv[]) {
|
|
|
74
73
|
print_time_diff(start, end, "visiting");
|
|
75
74
|
|
|
76
75
|
ast_node_free((AST_NODE_T*) root);
|
|
77
|
-
|
|
76
|
+
free(output.value);
|
|
78
77
|
free(source);
|
|
79
78
|
|
|
80
79
|
return 0;
|
|
@@ -87,18 +86,7 @@ int main(const int argc, char* argv[]) {
|
|
|
87
86
|
printf("%s\n", output.value);
|
|
88
87
|
print_time_diff(start, end, "lexing");
|
|
89
88
|
|
|
90
|
-
|
|
91
|
-
free(source);
|
|
92
|
-
|
|
93
|
-
return 0;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (strcmp(argv[1], "lex_json") == 0) {
|
|
97
|
-
herb_lex_json_to_buffer(source, &output);
|
|
98
|
-
|
|
99
|
-
printf("%s\n", output.value);
|
|
100
|
-
|
|
101
|
-
buffer_free(&output);
|
|
89
|
+
free(output.value);
|
|
102
90
|
free(source);
|
|
103
91
|
|
|
104
92
|
return 0;
|
|
@@ -106,15 +94,23 @@ int main(const int argc, char* argv[]) {
|
|
|
106
94
|
|
|
107
95
|
if (strcmp(argv[1], "parse") == 0) {
|
|
108
96
|
AST_DOCUMENT_NODE_T* root = herb_parse(source, NULL);
|
|
97
|
+
|
|
98
|
+
herb_analyze_parse_tree(root, source);
|
|
99
|
+
|
|
109
100
|
clock_gettime(CLOCK_MONOTONIC, &end);
|
|
110
101
|
|
|
111
|
-
|
|
112
|
-
|
|
102
|
+
int silent = 0;
|
|
103
|
+
if (argc > 3 && strcmp(argv[3], "--silent") == 0) { silent = 1; }
|
|
104
|
+
|
|
105
|
+
if (!silent) {
|
|
106
|
+
ast_pretty_print_node((AST_NODE_T*) root, 0, 0, &output);
|
|
107
|
+
printf("%s\n", output.value);
|
|
113
108
|
|
|
114
|
-
|
|
109
|
+
print_time_diff(start, end, "parsing");
|
|
110
|
+
}
|
|
115
111
|
|
|
116
112
|
ast_node_free((AST_NODE_T*) root);
|
|
117
|
-
|
|
113
|
+
free(output.value);
|
|
118
114
|
free(source);
|
|
119
115
|
|
|
120
116
|
return 0;
|
|
@@ -127,7 +123,7 @@ int main(const int argc, char* argv[]) {
|
|
|
127
123
|
printf("%s\n", output.value);
|
|
128
124
|
print_time_diff(start, end, "extracting Ruby");
|
|
129
125
|
|
|
130
|
-
|
|
126
|
+
free(output.value);
|
|
131
127
|
free(source);
|
|
132
128
|
|
|
133
129
|
return 0;
|
|
@@ -140,7 +136,7 @@ int main(const int argc, char* argv[]) {
|
|
|
140
136
|
printf("%s\n", output.value);
|
|
141
137
|
print_time_diff(start, end, "extracting HTML");
|
|
142
138
|
|
|
143
|
-
|
|
139
|
+
free(output.value);
|
|
144
140
|
free(source);
|
|
145
141
|
|
|
146
142
|
return 0;
|