@herb-tools/node 0.8.10 → 0.9.1
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 +27 -8
- package/dist/herb-node.cjs +41 -12
- package/dist/herb-node.cjs.map +1 -1
- package/dist/herb-node.esm.js +8 -1
- package/dist/herb-node.esm.js.map +1 -1
- package/dist/types/node-backend.d.ts +3 -1
- package/extension/error_helpers.cpp +598 -73
- package/extension/error_helpers.h +20 -3
- package/extension/extension_helpers.cpp +40 -35
- package/extension/extension_helpers.h +2 -2
- package/extension/herb.cpp +194 -64
- package/extension/libherb/analyze/action_view/attribute_extraction_helpers.c +303 -0
- package/extension/libherb/analyze/action_view/attribute_extraction_helpers.h +36 -0
- package/extension/libherb/analyze/action_view/content_tag.c +78 -0
- package/extension/libherb/analyze/action_view/link_to.c +167 -0
- package/extension/libherb/analyze/action_view/registry.c +83 -0
- package/extension/libherb/analyze/action_view/tag.c +70 -0
- package/extension/libherb/analyze/action_view/tag_helper_handler.h +43 -0
- package/extension/libherb/analyze/action_view/tag_helper_node_builders.c +305 -0
- package/extension/libherb/analyze/action_view/tag_helper_node_builders.h +70 -0
- package/extension/libherb/analyze/action_view/tag_helpers.c +815 -0
- package/extension/libherb/analyze/action_view/tag_helpers.h +38 -0
- package/extension/libherb/analyze/action_view/turbo_frame_tag.c +88 -0
- package/extension/libherb/analyze/analyze.c +885 -0
- package/extension/libherb/{include → analyze}/analyze.h +14 -4
- package/extension/libherb/{analyzed_ruby.c → analyze/analyzed_ruby.c} +13 -11
- package/extension/libherb/{analyzed_ruby.h → analyze/analyzed_ruby.h} +3 -3
- package/extension/libherb/analyze/builders.c +343 -0
- package/extension/libherb/analyze/builders.h +27 -0
- package/extension/libherb/analyze/conditional_elements.c +594 -0
- package/extension/libherb/analyze/conditional_elements.h +9 -0
- package/extension/libherb/analyze/conditional_open_tags.c +640 -0
- package/extension/libherb/analyze/conditional_open_tags.h +9 -0
- package/extension/libherb/analyze/control_type.c +250 -0
- package/extension/libherb/analyze/control_type.h +14 -0
- package/extension/libherb/{analyze_helpers.c → analyze/helpers.c} +48 -23
- package/extension/libherb/{analyze_helpers.h → analyze/helpers.h} +4 -2
- package/extension/libherb/analyze/invalid_structures.c +193 -0
- package/extension/libherb/analyze/invalid_structures.h +11 -0
- package/extension/libherb/{analyze_missing_end.c → analyze/missing_end.c} +33 -22
- package/extension/libherb/analyze/parse_errors.c +84 -0
- package/extension/libherb/analyze/prism_annotate.c +399 -0
- package/extension/libherb/analyze/prism_annotate.h +16 -0
- package/extension/libherb/analyze/render_nodes.c +761 -0
- package/extension/libherb/analyze/render_nodes.h +11 -0
- package/extension/libherb/{analyze_transform.c → analyze/transform.c} +24 -3
- package/extension/libherb/ast_node.c +17 -7
- package/extension/libherb/ast_node.h +11 -5
- package/extension/libherb/ast_nodes.c +760 -388
- package/extension/libherb/ast_nodes.h +155 -39
- package/extension/libherb/ast_pretty_print.c +265 -7
- package/extension/libherb/ast_pretty_print.h +6 -1
- package/extension/libherb/element_source.h +3 -8
- package/extension/libherb/errors.c +1455 -520
- package/extension/libherb/errors.h +207 -56
- package/extension/libherb/extract.c +145 -49
- package/extension/libherb/extract.h +21 -5
- package/extension/libherb/herb.c +52 -34
- package/extension/libherb/herb.h +18 -6
- package/extension/libherb/herb_prism_node.h +13 -0
- package/extension/libherb/html_util.c +241 -12
- package/extension/libherb/html_util.h +7 -2
- package/extension/libherb/include/analyze/action_view/attribute_extraction_helpers.h +36 -0
- package/extension/libherb/include/analyze/action_view/tag_helper_handler.h +43 -0
- package/extension/libherb/include/analyze/action_view/tag_helper_node_builders.h +70 -0
- package/extension/libherb/include/analyze/action_view/tag_helpers.h +38 -0
- package/extension/libherb/{analyze.h → include/analyze/analyze.h} +14 -4
- package/extension/libherb/include/{analyzed_ruby.h → analyze/analyzed_ruby.h} +3 -3
- package/extension/libherb/include/analyze/builders.h +27 -0
- package/extension/libherb/include/analyze/conditional_elements.h +9 -0
- package/extension/libherb/include/analyze/conditional_open_tags.h +9 -0
- package/extension/libherb/include/analyze/control_type.h +14 -0
- package/extension/libherb/include/{analyze_helpers.h → analyze/helpers.h} +4 -2
- package/extension/libherb/include/analyze/invalid_structures.h +11 -0
- package/extension/libherb/include/analyze/prism_annotate.h +16 -0
- package/extension/libherb/include/analyze/render_nodes.h +11 -0
- package/extension/libherb/include/ast_node.h +11 -5
- package/extension/libherb/include/ast_nodes.h +155 -39
- package/extension/libherb/include/ast_pretty_print.h +6 -1
- package/extension/libherb/include/element_source.h +3 -8
- package/extension/libherb/include/errors.h +207 -56
- package/extension/libherb/include/extract.h +21 -5
- package/extension/libherb/include/herb.h +18 -6
- package/extension/libherb/include/herb_prism_node.h +13 -0
- package/extension/libherb/include/html_util.h +7 -2
- package/extension/libherb/include/io.h +3 -1
- package/extension/libherb/include/lex_helpers.h +29 -0
- package/extension/libherb/include/lexer.h +1 -1
- package/extension/libherb/include/lexer_peek_helpers.h +87 -13
- package/extension/libherb/include/lexer_struct.h +2 -0
- package/extension/libherb/include/location.h +2 -1
- package/extension/libherb/include/parser.h +28 -2
- package/extension/libherb/include/parser_helpers.h +19 -3
- package/extension/libherb/include/pretty_print.h +10 -5
- package/extension/libherb/include/prism_context.h +45 -0
- package/extension/libherb/include/prism_helpers.h +10 -7
- package/extension/libherb/include/prism_serialized.h +12 -0
- package/extension/libherb/include/token.h +16 -4
- package/extension/libherb/include/token_struct.h +10 -3
- package/extension/libherb/include/utf8.h +2 -1
- package/extension/libherb/include/util/hb_allocator.h +78 -0
- package/extension/libherb/include/util/hb_arena.h +6 -1
- package/extension/libherb/include/util/hb_arena_debug.h +12 -1
- package/extension/libherb/include/util/hb_array.h +7 -3
- package/extension/libherb/include/util/hb_buffer.h +6 -4
- package/extension/libherb/include/util/hb_foreach.h +79 -0
- package/extension/libherb/include/util/hb_narray.h +8 -4
- package/extension/libherb/include/util/hb_string.h +56 -9
- package/extension/libherb/include/util.h +6 -3
- package/extension/libherb/include/version.h +1 -1
- package/extension/libherb/io.c +3 -2
- package/extension/libherb/io.h +3 -1
- package/extension/libherb/lex_helpers.h +29 -0
- package/extension/libherb/lexer.c +42 -30
- package/extension/libherb/lexer.h +1 -1
- package/extension/libherb/lexer_peek_helpers.c +12 -74
- package/extension/libherb/lexer_peek_helpers.h +87 -13
- package/extension/libherb/lexer_struct.h +2 -0
- package/extension/libherb/location.c +2 -2
- package/extension/libherb/location.h +2 -1
- package/extension/libherb/main.c +53 -28
- package/extension/libherb/parser.c +784 -247
- package/extension/libherb/parser.h +28 -2
- package/extension/libherb/parser_helpers.c +110 -23
- package/extension/libherb/parser_helpers.h +19 -3
- package/extension/libherb/parser_match_tags.c +130 -49
- package/extension/libherb/pretty_print.c +29 -24
- package/extension/libherb/pretty_print.h +10 -5
- package/extension/libherb/prism_context.h +45 -0
- package/extension/libherb/prism_helpers.c +30 -27
- package/extension/libherb/prism_helpers.h +10 -7
- package/extension/libherb/prism_serialized.h +12 -0
- package/extension/libherb/ruby_parser.c +2 -0
- package/extension/libherb/token.c +151 -66
- package/extension/libherb/token.h +16 -4
- package/extension/libherb/token_matchers.c +0 -1
- package/extension/libherb/token_struct.h +10 -3
- package/extension/libherb/utf8.c +7 -6
- package/extension/libherb/utf8.h +2 -1
- package/extension/libherb/util/hb_allocator.c +341 -0
- package/extension/libherb/util/hb_allocator.h +78 -0
- package/extension/libherb/util/hb_arena.c +81 -56
- package/extension/libherb/util/hb_arena.h +6 -1
- package/extension/libherb/util/hb_arena_debug.c +32 -17
- package/extension/libherb/util/hb_arena_debug.h +12 -1
- package/extension/libherb/util/hb_array.c +30 -15
- package/extension/libherb/util/hb_array.h +7 -3
- package/extension/libherb/util/hb_buffer.c +17 -21
- package/extension/libherb/util/hb_buffer.h +6 -4
- package/extension/libherb/util/hb_foreach.h +79 -0
- package/extension/libherb/util/hb_narray.c +22 -7
- package/extension/libherb/util/hb_narray.h +8 -4
- package/extension/libherb/util/hb_string.c +49 -35
- package/extension/libherb/util/hb_string.h +56 -9
- package/extension/libherb/util.c +21 -11
- package/extension/libherb/util.h +6 -3
- package/extension/libherb/version.h +1 -1
- package/extension/libherb/visitor.c +68 -1
- package/extension/nodes.cpp +593 -6
- package/extension/nodes.h +10 -1
- package/package.json +12 -8
- package/src/node-backend.ts +11 -1
- package/dist/types/index-cjs.d.cts +0 -1
- package/extension/libherb/analyze.c +0 -1608
- package/extension/libherb/element_source.c +0 -12
- package/extension/libherb/include/util/hb_system.h +0 -9
- package/extension/libherb/util/hb_system.c +0 -30
- package/extension/libherb/util/hb_system.h +0 -9
- package/src/index-cjs.cts +0 -22
- /package/dist/types/{index-esm.d.mts → index.d.ts} +0 -0
- /package/src/{index-esm.mts → index.ts} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
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-0.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/src/analyze/transform.c.erb
|
|
3
3
|
|
|
4
|
-
#include "include/analyze.h"
|
|
5
|
-
#include "include/visitor.h"
|
|
4
|
+
#include "../include/analyze/analyze.h"
|
|
5
|
+
#include "../include/visitor.h"
|
|
6
6
|
|
|
7
7
|
bool transform_erb_nodes(const AST_NODE_T* node, void* data) {
|
|
8
8
|
analyze_ruby_context_T* context = (analyze_ruby_context_T*) data;
|
|
@@ -36,6 +36,13 @@ bool transform_erb_nodes(const AST_NODE_T* node, void* data) {
|
|
|
36
36
|
hb_array_free(&old_array);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
if (node->type == AST_HTML_CONDITIONAL_ELEMENT_NODE) {
|
|
40
|
+
AST_HTML_CONDITIONAL_ELEMENT_NODE_T* html_conditional_element_node = (AST_HTML_CONDITIONAL_ELEMENT_NODE_T*) node;
|
|
41
|
+
hb_array_T* old_array = html_conditional_element_node->body;
|
|
42
|
+
html_conditional_element_node->body = rewrite_node_array((AST_NODE_T*) node, html_conditional_element_node->body, context);
|
|
43
|
+
hb_array_free(&old_array);
|
|
44
|
+
}
|
|
45
|
+
|
|
39
46
|
if (node->type == AST_HTML_ATTRIBUTE_VALUE_NODE) {
|
|
40
47
|
AST_HTML_ATTRIBUTE_VALUE_NODE_T* html_attribute_value_node = (AST_HTML_ATTRIBUTE_VALUE_NODE_T*) node;
|
|
41
48
|
hb_array_T* old_array = html_attribute_value_node->children;
|
|
@@ -50,6 +57,13 @@ bool transform_erb_nodes(const AST_NODE_T* node, void* data) {
|
|
|
50
57
|
hb_array_free(&old_array);
|
|
51
58
|
}
|
|
52
59
|
|
|
60
|
+
if (node->type == AST_ERB_OPEN_TAG_NODE) {
|
|
61
|
+
AST_ERB_OPEN_TAG_NODE_T* erb_open_tag_node = (AST_ERB_OPEN_TAG_NODE_T*) node;
|
|
62
|
+
hb_array_T* old_array = erb_open_tag_node->children;
|
|
63
|
+
erb_open_tag_node->children = rewrite_node_array((AST_NODE_T*) node, erb_open_tag_node->children, context);
|
|
64
|
+
hb_array_free(&old_array);
|
|
65
|
+
}
|
|
66
|
+
|
|
53
67
|
if (node->type == AST_HTML_COMMENT_NODE) {
|
|
54
68
|
AST_HTML_COMMENT_NODE_T* html_comment_node = (AST_HTML_COMMENT_NODE_T*) node;
|
|
55
69
|
hb_array_T* old_array = html_comment_node->children;
|
|
@@ -183,6 +197,13 @@ bool transform_erb_nodes(const AST_NODE_T* node, void* data) {
|
|
|
183
197
|
hb_array_free(&old_array);
|
|
184
198
|
}
|
|
185
199
|
|
|
200
|
+
if (node->type == AST_ERB_RENDER_NODE) {
|
|
201
|
+
AST_ERB_RENDER_NODE_T* erb_render_node = (AST_ERB_RENDER_NODE_T*) node;
|
|
202
|
+
hb_array_T* old_array = erb_render_node->locals;
|
|
203
|
+
erb_render_node->locals = rewrite_node_array((AST_NODE_T*) node, erb_render_node->locals, context);
|
|
204
|
+
hb_array_free(&old_array);
|
|
205
|
+
}
|
|
206
|
+
|
|
186
207
|
if (node->type == AST_ERB_IN_NODE) {
|
|
187
208
|
AST_ERB_IN_NODE_T* erb_in_node = (AST_ERB_IN_NODE_T*) node;
|
|
188
209
|
hb_array_T* old_array = erb_in_node->statements;
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
#include "include/ast_nodes.h"
|
|
3
3
|
#include "include/errors.h"
|
|
4
4
|
#include "include/position.h"
|
|
5
|
-
#include "include/token.h"
|
|
6
5
|
#include "include/util.h"
|
|
6
|
+
#include "include/util/hb_allocator.h"
|
|
7
|
+
#include "include/util/hb_string.h"
|
|
7
8
|
#include "include/visitor.h"
|
|
8
9
|
|
|
9
10
|
#include <prism.h>
|
|
@@ -14,7 +15,14 @@ size_t ast_node_sizeof(void) {
|
|
|
14
15
|
return sizeof(struct AST_NODE_STRUCT);
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
void ast_node_init(
|
|
18
|
+
void ast_node_init(
|
|
19
|
+
AST_NODE_T* node,
|
|
20
|
+
const ast_node_type_T type,
|
|
21
|
+
position_T start,
|
|
22
|
+
position_T end,
|
|
23
|
+
hb_array_T* errors,
|
|
24
|
+
hb_allocator_T* allocator
|
|
25
|
+
) {
|
|
18
26
|
if (!node) { return; }
|
|
19
27
|
|
|
20
28
|
node->type = type;
|
|
@@ -22,18 +30,20 @@ void ast_node_init(AST_NODE_T* node, const ast_node_type_T type, position_T star
|
|
|
22
30
|
node->location.end = end;
|
|
23
31
|
|
|
24
32
|
if (errors == NULL) {
|
|
25
|
-
node->errors = hb_array_init(
|
|
33
|
+
node->errors = hb_array_init(0, allocator);
|
|
26
34
|
} else {
|
|
27
35
|
node->errors = errors;
|
|
28
36
|
}
|
|
29
37
|
}
|
|
30
38
|
|
|
31
|
-
AST_LITERAL_NODE_T* ast_literal_node_init_from_token(const token_T* token) {
|
|
32
|
-
AST_LITERAL_NODE_T* literal =
|
|
39
|
+
AST_LITERAL_NODE_T* ast_literal_node_init_from_token(const token_T* token, hb_allocator_T* allocator) {
|
|
40
|
+
AST_LITERAL_NODE_T* literal = hb_allocator_alloc(allocator, sizeof(AST_LITERAL_NODE_T));
|
|
33
41
|
|
|
34
|
-
|
|
42
|
+
if (!literal) { return NULL; }
|
|
35
43
|
|
|
36
|
-
literal->
|
|
44
|
+
ast_node_init(&literal->base, AST_LITERAL_NODE, token->location.start, token->location.end, NULL, allocator);
|
|
45
|
+
|
|
46
|
+
literal->content = hb_string_copy(token->value, allocator);
|
|
37
47
|
|
|
38
48
|
return literal;
|
|
39
49
|
}
|
|
@@ -5,19 +5,25 @@
|
|
|
5
5
|
#include "errors.h"
|
|
6
6
|
#include "position.h"
|
|
7
7
|
#include "token_struct.h"
|
|
8
|
+
#include "util/hb_allocator.h"
|
|
8
9
|
|
|
9
|
-
void ast_node_init(
|
|
10
|
-
|
|
10
|
+
void ast_node_init(
|
|
11
|
+
AST_NODE_T* node,
|
|
12
|
+
ast_node_type_T type,
|
|
13
|
+
position_T start,
|
|
14
|
+
position_T end,
|
|
15
|
+
hb_array_T* errors,
|
|
16
|
+
hb_allocator_T* allocator
|
|
17
|
+
);
|
|
18
|
+
void ast_node_free(AST_NODE_T* node, hb_allocator_T* allocator);
|
|
11
19
|
|
|
12
|
-
AST_LITERAL_NODE_T* ast_literal_node_init_from_token(const token_T* token);
|
|
20
|
+
AST_LITERAL_NODE_T* ast_literal_node_init_from_token(const token_T* token, hb_allocator_T* allocator);
|
|
13
21
|
|
|
14
22
|
size_t ast_node_sizeof(void);
|
|
15
23
|
size_t ast_node_child_count(AST_NODE_T* node);
|
|
16
24
|
|
|
17
25
|
ast_node_type_T ast_node_type(const AST_NODE_T* node);
|
|
18
26
|
|
|
19
|
-
char* ast_node_name(AST_NODE_T* node);
|
|
20
|
-
|
|
21
27
|
void ast_node_set_start(AST_NODE_T* node, position_T position);
|
|
22
28
|
void ast_node_set_end(AST_NODE_T* node, position_T position);
|
|
23
29
|
|