@herb-tools/node 0.4.0 → 0.4.2
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/dist/herb-node.esm.js +1 -1
- package/extension/error_helpers.cpp +1 -1
- package/extension/error_helpers.h +1 -1
- package/extension/libherb/analyze.c +20 -5
- package/extension/libherb/analyze_helpers.c +6 -2
- package/extension/libherb/analyze_helpers.h +1 -1
- package/extension/libherb/ast_nodes.c +1 -1
- package/extension/libherb/ast_nodes.h +1 -1
- package/extension/libherb/ast_pretty_print.c +1 -1
- package/extension/libherb/ast_pretty_print.h +1 -1
- package/extension/libherb/errors.c +1 -1
- package/extension/libherb/errors.h +1 -1
- package/extension/libherb/include/analyze_helpers.h +1 -1
- package/extension/libherb/include/ast_nodes.h +1 -1
- package/extension/libherb/include/ast_pretty_print.h +1 -1
- package/extension/libherb/include/errors.h +1 -1
- package/extension/libherb/include/token_struct.h +1 -0
- package/extension/libherb/include/version.h +1 -1
- package/extension/libherb/lexer.c +1 -0
- package/extension/libherb/token.c +1 -0
- package/extension/libherb/token_struct.h +1 -0
- package/extension/libherb/version.h +1 -1
- package/extension/libherb/visitor.c +1 -1
- package/extension/nodes.cpp +1 -1
- package/extension/nodes.h +1 -1
- package/package.json +2 -2
package/dist/herb-node.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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/templates/javascript/packages/node/extension/error_helpers.cpp.erb
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-6/templates/javascript/packages/node/extension/error_helpers.cpp.erb
|
|
3
3
|
|
|
4
4
|
#include <node_api.h>
|
|
5
5
|
#include "error_helpers.h"
|
|
@@ -1,5 +1,5 @@
|
|
|
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/templates/javascript/packages/node/extension/error_helpers.h.erb
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-6/templates/javascript/packages/node/extension/error_helpers.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_EXTENSION_ERRORS_H
|
|
5
5
|
#define HERB_EXTENSION_ERRORS_H
|
|
@@ -39,7 +39,7 @@ static analyzed_ruby_T* herb_analyze_ruby(char* source) {
|
|
|
39
39
|
search_in_nodes(analyzed);
|
|
40
40
|
search_rescue_nodes(analyzed);
|
|
41
41
|
search_ensure_nodes(analyzed);
|
|
42
|
-
search_yield_nodes(analyzed);
|
|
42
|
+
search_yield_nodes(analyzed->root, analyzed);
|
|
43
43
|
search_block_closing_nodes(analyzed);
|
|
44
44
|
|
|
45
45
|
return analyzed;
|
|
@@ -95,8 +95,13 @@ static control_type_t detect_control_type(AST_ERB_CONTENT_NODE_T* erb_node) {
|
|
|
95
95
|
|
|
96
96
|
if (!ruby) { return CONTROL_TYPE_UNKNOWN; }
|
|
97
97
|
|
|
98
|
-
if (ruby->valid) {
|
|
98
|
+
if (ruby->valid) {
|
|
99
|
+
if (has_yield_node(ruby)) { return CONTROL_TYPE_YIELD; }
|
|
100
|
+
return CONTROL_TYPE_UNKNOWN;
|
|
101
|
+
}
|
|
99
102
|
|
|
103
|
+
if (has_yield_node(ruby)) { return CONTROL_TYPE_YIELD; }
|
|
104
|
+
if (has_block_node(ruby)) { return CONTROL_TYPE_BLOCK; }
|
|
100
105
|
if (has_if_node(ruby)) { return CONTROL_TYPE_IF; }
|
|
101
106
|
if (has_elsif_node(ruby)) { return CONTROL_TYPE_ELSIF; }
|
|
102
107
|
if (has_else_node(ruby)) { return CONTROL_TYPE_ELSE; }
|
|
@@ -112,8 +117,6 @@ static control_type_t detect_control_type(AST_ERB_CONTENT_NODE_T* erb_node) {
|
|
|
112
117
|
if (has_while_node(ruby)) { return CONTROL_TYPE_WHILE; }
|
|
113
118
|
if (has_until_node(ruby)) { return CONTROL_TYPE_UNTIL; }
|
|
114
119
|
if (has_for_node(ruby)) { return CONTROL_TYPE_FOR; }
|
|
115
|
-
if (has_block_node(ruby)) { return CONTROL_TYPE_BLOCK; }
|
|
116
|
-
if (has_yield_node(ruby)) { return CONTROL_TYPE_YIELD; }
|
|
117
120
|
if (has_block_closing(ruby)) { return CONTROL_TYPE_BLOCK_CLOSE; }
|
|
118
121
|
|
|
119
122
|
return CONTROL_TYPE_UNKNOWN;
|
|
@@ -1020,10 +1023,22 @@ static array_T* rewrite_node_array(AST_NODE_T* node, array_T* array, analyze_rub
|
|
|
1020
1023
|
case CONTROL_TYPE_UNTIL:
|
|
1021
1024
|
case CONTROL_TYPE_FOR:
|
|
1022
1025
|
case CONTROL_TYPE_BLOCK:
|
|
1023
|
-
case CONTROL_TYPE_YIELD:
|
|
1024
1026
|
index = process_control_structure(node, array, index, new_array, context, type);
|
|
1025
1027
|
continue;
|
|
1026
1028
|
|
|
1029
|
+
case CONTROL_TYPE_YIELD: {
|
|
1030
|
+
AST_NODE_T* yield_node = create_control_node(erb_node, array_init(8), NULL, NULL, type);
|
|
1031
|
+
|
|
1032
|
+
if (yield_node) {
|
|
1033
|
+
array_append(new_array, yield_node);
|
|
1034
|
+
} else {
|
|
1035
|
+
array_append(new_array, item);
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
index++;
|
|
1039
|
+
break;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1027
1042
|
default:
|
|
1028
1043
|
array_append(new_array, item);
|
|
1029
1044
|
index++;
|
|
@@ -279,10 +279,14 @@ bool search_ensure_nodes(analyzed_ruby_T* analyzed) {
|
|
|
279
279
|
return false;
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
bool search_yield_nodes(
|
|
283
|
-
|
|
282
|
+
bool search_yield_nodes(const pm_node_t* node, void* data) {
|
|
283
|
+
analyzed_ruby_T* analyzed = (analyzed_ruby_T*) data;
|
|
284
|
+
|
|
285
|
+
if (node->type == PM_YIELD_NODE) {
|
|
284
286
|
analyzed->has_yield_node = true;
|
|
285
287
|
return true;
|
|
288
|
+
} else {
|
|
289
|
+
pm_visit_child_nodes(node, search_yield_nodes, analyzed);
|
|
286
290
|
}
|
|
287
291
|
|
|
288
292
|
return false;
|
|
@@ -44,6 +44,6 @@ bool search_when_nodes(analyzed_ruby_T* analyzed);
|
|
|
44
44
|
bool search_in_nodes(analyzed_ruby_T* analyzed);
|
|
45
45
|
bool search_rescue_nodes(analyzed_ruby_T* analyzed);
|
|
46
46
|
bool search_ensure_nodes(analyzed_ruby_T* analyzed);
|
|
47
|
-
bool search_yield_nodes(
|
|
47
|
+
bool search_yield_nodes(const pm_node_t* node, void* data);
|
|
48
48
|
|
|
49
49
|
#endif
|
|
@@ -1,5 +1,5 @@
|
|
|
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/templates/src/ast_nodes.c.erb
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-6/templates/src/ast_nodes.c.erb
|
|
3
3
|
|
|
4
4
|
#include <stdio.h>
|
|
5
5
|
#include <stdbool.h>
|
|
@@ -1,5 +1,5 @@
|
|
|
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/templates/src/include/ast_nodes.h.erb
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-6/templates/src/include/ast_nodes.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_AST_NODES_H
|
|
5
5
|
#define HERB_AST_NODES_H
|
|
@@ -1,5 +1,5 @@
|
|
|
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/templates/src/ast_pretty_print.c.erb
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-6/templates/src/ast_pretty_print.c.erb
|
|
3
3
|
|
|
4
4
|
#include "include/ast_node.h"
|
|
5
5
|
#include "include/ast_nodes.h"
|
|
@@ -1,5 +1,5 @@
|
|
|
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/templates/src/include/ast_pretty_print.h.erb
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-6/templates/src/include/ast_pretty_print.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_AST_PRETTY_PRINT_H
|
|
5
5
|
#define HERB_AST_PRETTY_PRINT_H
|
|
@@ -1,5 +1,5 @@
|
|
|
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/templates/src/errors.c.erb
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-6/templates/src/errors.c.erb
|
|
3
3
|
|
|
4
4
|
#include "include/array.h"
|
|
5
5
|
#include "include/errors.h"
|
|
@@ -1,5 +1,5 @@
|
|
|
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/templates/src/include/errors.h.erb
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-6/templates/src/include/errors.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_ERRORS_H
|
|
5
5
|
#define HERB_ERRORS_H
|
|
@@ -44,6 +44,6 @@ bool search_when_nodes(analyzed_ruby_T* analyzed);
|
|
|
44
44
|
bool search_in_nodes(analyzed_ruby_T* analyzed);
|
|
45
45
|
bool search_rescue_nodes(analyzed_ruby_T* analyzed);
|
|
46
46
|
bool search_ensure_nodes(analyzed_ruby_T* analyzed);
|
|
47
|
-
bool search_yield_nodes(
|
|
47
|
+
bool search_yield_nodes(const pm_node_t* node, void* data);
|
|
48
48
|
|
|
49
49
|
#endif
|
|
@@ -1,5 +1,5 @@
|
|
|
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/templates/src/include/ast_nodes.h.erb
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-6/templates/src/include/ast_nodes.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_AST_NODES_H
|
|
5
5
|
#define HERB_AST_NODES_H
|
|
@@ -1,5 +1,5 @@
|
|
|
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/templates/src/include/ast_pretty_print.h.erb
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-6/templates/src/include/ast_pretty_print.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_AST_PRETTY_PRINT_H
|
|
5
5
|
#define HERB_AST_PRETTY_PRINT_H
|
|
@@ -1,5 +1,5 @@
|
|
|
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/templates/src/include/errors.h.erb
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-6/templates/src/include/errors.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_ERRORS_H
|
|
5
5
|
#define HERB_ERRORS_H
|
|
@@ -269,6 +269,7 @@ token_T* lexer_next_token(lexer_T* lexer) {
|
|
|
269
269
|
case '>': return lexer_advance_current(lexer, TOKEN_HTML_TAG_END);
|
|
270
270
|
case '_': return lexer_advance_current(lexer, TOKEN_UNDERSCORE);
|
|
271
271
|
case ':': return lexer_advance_current(lexer, TOKEN_COLON);
|
|
272
|
+
case '@': return lexer_advance_current(lexer, TOKEN_AT);
|
|
272
273
|
case ';': return lexer_advance_current(lexer, TOKEN_SEMICOLON);
|
|
273
274
|
case '&': return lexer_advance_current(lexer, TOKEN_AMPERSAND);
|
|
274
275
|
case '!': return lexer_advance_current(lexer, TOKEN_EXCLAMATION);
|
|
@@ -61,6 +61,7 @@ const char* token_type_to_string(const token_type_T type) {
|
|
|
61
61
|
case TOKEN_SLASH: return "TOKEN_SLASH";
|
|
62
62
|
case TOKEN_SEMICOLON: return "TOKEN_SEMICOLON";
|
|
63
63
|
case TOKEN_COLON: return "TOKEN_COLON";
|
|
64
|
+
case TOKEN_AT: return "TOKEN_AT";
|
|
64
65
|
case TOKEN_LT: return "TOKEN_LT";
|
|
65
66
|
case TOKEN_PERCENT: return "TOKEN_PERCENT";
|
|
66
67
|
case TOKEN_AMPERSAND: return "TOKEN_AMPERSAND";
|
|
@@ -1,5 +1,5 @@
|
|
|
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/templates/src/visitor.c.erb
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-6/templates/src/visitor.c.erb
|
|
3
3
|
|
|
4
4
|
#include <stdio.h>
|
|
5
5
|
|
package/extension/nodes.cpp
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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/templates/javascript/packages/node/extension/nodes.cpp.erb
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-6/templates/javascript/packages/node/extension/nodes.cpp.erb
|
|
3
3
|
|
|
4
4
|
#include <node_api.h>
|
|
5
5
|
#include "error_helpers.h"
|
package/extension/nodes.h
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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/templates/javascript/packages/node/extension/nodes.h.erb
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-6/templates/javascript/packages/node/extension/nodes.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_EXTENSION_NODES_H
|
|
5
5
|
#define HERB_EXTENSION_NODES_H
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herb-tools/node",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Native Node.js addon for HTML-aware ERB parsing using Herb.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"host": "https://github.com/marcoroth/herb/releases/download/"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@herb-tools/core": "0.4.
|
|
51
|
+
"@herb-tools/core": "0.4.2",
|
|
52
52
|
"@mapbox/node-pre-gyp": "^2.0.0",
|
|
53
53
|
"node-addon-api": "^5.1.0",
|
|
54
54
|
"node-pre-gyp-github": "^2.0.0"
|