@herb-tools/node 0.7.2 → 0.7.4

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.
@@ -6,7 +6,7 @@ import { createRequire } from 'module';
6
6
  import { fileURLToPath } from 'url';
7
7
 
8
8
  var name = "@herb-tools/node";
9
- var version = "0.7.2";
9
+ var version = "0.7.4";
10
10
  var packageJSON = {
11
11
  name: name,
12
12
  version: version};
@@ -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-0.7.2/templates/javascript/packages/node/extension/error_helpers.cpp.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.4/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-0.7.2/templates/javascript/packages/node/extension/error_helpers.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.4/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
@@ -54,7 +54,7 @@ static bool analyze_erb_content(const AST_NODE_T* node, void* data) {
54
54
  if (strcmp(opening, "<%%") != 0 && strcmp(opening, "<%%=") != 0 && strcmp(opening, "<%#") != 0) {
55
55
  analyzed_ruby_T* analyzed = herb_analyze_ruby(erb_content_node->content->value);
56
56
 
57
- if (false) { pretty_print_analyed_ruby(analyzed, erb_content_node->content->value); }
57
+ if (false) { pretty_print_analyzed_ruby(analyzed, erb_content_node->content->value); }
58
58
 
59
59
  erb_content_node->parsed = true;
60
60
  erb_content_node->valid = analyzed->valid;
@@ -1107,7 +1107,8 @@ void herb_analyze_parse_errors(AST_DOCUMENT_NODE_T* document, const char* source
1107
1107
  char* extracted_ruby = herb_extract_ruby_with_semicolons(source);
1108
1108
 
1109
1109
  pm_parser_t parser;
1110
- pm_parser_init(&parser, (const uint8_t*) extracted_ruby, strlen(extracted_ruby), NULL);
1110
+ pm_options_t options = { 0, .partial_script = true };
1111
+ pm_parser_init(&parser, (const uint8_t*) extracted_ruby, strlen(extracted_ruby), &options);
1111
1112
 
1112
1113
  pm_node_t* root = pm_parse(&parser);
1113
1114
 
@@ -1115,16 +1116,11 @@ void herb_analyze_parse_errors(AST_DOCUMENT_NODE_T* document, const char* source
1115
1116
  error = (const pm_diagnostic_t*) error->node.next) {
1116
1117
 
1117
1118
  RUBY_PARSE_ERROR_T* parse_error = ruby_parse_error_from_prism_error(error, (AST_NODE_T*) document, source, &parser);
1118
-
1119
- // TODO: ideally this shouldn't be hard-coded
1120
- if (strcmp(parse_error->diagnostic_id, "invalid_yield") == 0) {
1121
- error_free((ERROR_T*) parse_error);
1122
- } else {
1123
- array_append(document->base.errors, parse_error);
1124
- }
1119
+ array_append(document->base.errors, parse_error);
1125
1120
  }
1126
1121
 
1127
1122
  pm_node_destroy(&parser, root);
1128
1123
  pm_parser_free(&parser);
1124
+ pm_options_free(&options);
1129
1125
  free(extracted_ruby);
1130
1126
  }
@@ -91,9 +91,12 @@ bool search_if_nodes(const pm_node_t* node, void* data) {
91
91
  if (node->type == PM_IF_NODE) {
92
92
  const pm_if_node_t* if_node = (const pm_if_node_t*) node;
93
93
 
94
- // Handle ternary
95
- if (if_node->if_keyword_loc.start != NULL && if_node->if_keyword_loc.end != NULL) {
94
+ bool has_if_keyword = if_node->if_keyword_loc.start != NULL && if_node->if_keyword_loc.end != NULL;
95
+ bool has_end_keyword = if_node->end_keyword_loc.start != NULL && if_node->end_keyword_loc.end != NULL;
96
+
97
+ if (has_if_keyword && has_end_keyword) {
96
98
  analyzed->has_if_node = true;
99
+
97
100
  return true;
98
101
  }
99
102
  }
@@ -198,12 +201,20 @@ bool search_unless_nodes(const pm_node_t* node, void* data) {
198
201
  analyzed_ruby_T* analyzed = (analyzed_ruby_T*) data;
199
202
 
200
203
  if (node->type == PM_UNLESS_NODE) {
201
- analyzed->has_unless_node = true;
202
- return true;
203
- } else {
204
- pm_visit_child_nodes(node, search_unless_nodes, analyzed);
204
+ const pm_unless_node_t* unless_node = (const pm_unless_node_t*) node;
205
+
206
+ bool has_if_keyword = unless_node->keyword_loc.start != NULL && unless_node->keyword_loc.end != NULL;
207
+ bool has_end_keyword = unless_node->end_keyword_loc.start != NULL && unless_node->end_keyword_loc.end != NULL;
208
+
209
+ if (has_if_keyword && has_end_keyword) {
210
+ analyzed->has_unless_node = true;
211
+
212
+ return true;
213
+ }
205
214
  }
206
215
 
216
+ pm_visit_child_nodes(node, search_unless_nodes, analyzed);
217
+
207
218
  return false;
208
219
  }
209
220
 
@@ -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-0.7.2/templates/src/ast_nodes.c.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.4/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-0.7.2/templates/src/include/ast_nodes.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.4/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-0.7.2/templates/src/ast_pretty_print.c.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.4/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-0.7.2/templates/src/include/ast_pretty_print.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.4/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-0.7.2/templates/src/errors.c.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.4/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-0.7.2/templates/src/include/errors.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.4/templates/src/include/errors.h.erb
3
3
 
4
4
  #ifndef HERB_ERRORS_H
5
5
  #define HERB_ERRORS_H
@@ -29,9 +29,9 @@ array_T* herb_lex(const char* source) {
29
29
 
30
30
  AST_DOCUMENT_NODE_T* herb_parse(const char* source, parser_options_T* options) {
31
31
  lexer_T* lexer = lexer_init(source);
32
- parser_T* parser = parser_init(lexer, options);
32
+ parser_T* parser = herb_parser_init(lexer, options);
33
33
 
34
- AST_DOCUMENT_NODE_T* document = parser_parse(parser);
34
+ AST_DOCUMENT_NODE_T* document = herb_parser_parse(parser);
35
35
 
36
36
  parser_free(parser);
37
37
 
@@ -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-0.7.2/templates/src/include/ast_nodes.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.4/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-0.7.2/templates/src/include/ast_pretty_print.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.4/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-0.7.2/templates/src/include/errors.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.4/templates/src/include/errors.h.erb
3
3
 
4
4
  #ifndef HERB_ERRORS_H
5
5
  #define HERB_ERRORS_H
@@ -28,9 +28,9 @@ typedef struct PARSER_STRUCT {
28
28
  parser_options_T* options;
29
29
  } parser_T;
30
30
 
31
- parser_T* parser_init(lexer_T* lexer, parser_options_T* options);
31
+ parser_T* herb_parser_init(lexer_T* lexer, parser_options_T* options);
32
32
 
33
- AST_DOCUMENT_NODE_T* parser_parse(parser_T* parser);
33
+ AST_DOCUMENT_NODE_T* herb_parser_parse(parser_T* parser);
34
34
 
35
35
  size_t parser_sizeof(void);
36
36
 
@@ -88,6 +88,6 @@ void pretty_print_array(
88
88
 
89
89
  void pretty_print_errors(AST_NODE_T* node, size_t indent, size_t relative_indent, bool last_property, buffer_T* buffer);
90
90
 
91
- void pretty_print_analyed_ruby(analyzed_ruby_T* analyzed, const char* source);
91
+ void pretty_print_analyzed_ruby(analyzed_ruby_T* analyzed, const char* source);
92
92
 
93
93
  #endif
@@ -1,6 +1,6 @@
1
1
  #ifndef HERB_VERSION_H
2
2
  #define HERB_VERSION_H
3
3
 
4
- #define HERB_VERSION "0.7.2"
4
+ #define HERB_VERSION "0.7.4"
5
5
 
6
6
  #endif
@@ -31,7 +31,7 @@ size_t parser_sizeof(void) {
31
31
  return sizeof(struct PARSER_STRUCT);
32
32
  }
33
33
 
34
- parser_T* parser_init(lexer_T* lexer, parser_options_T* options) {
34
+ parser_T* herb_parser_init(lexer_T* lexer, parser_options_T* options) {
35
35
  parser_T* parser = calloc(1, parser_sizeof());
36
36
 
37
37
  parser->lexer = lexer;
@@ -1131,6 +1131,7 @@ static void parser_parse_in_data_state(parser_T* parser, array_T* children, arra
1131
1131
  parser,
1132
1132
  TOKEN_AMPERSAND,
1133
1133
  TOKEN_AT,
1134
+ TOKEN_BACKTICK,
1134
1135
  TOKEN_CHARACTER,
1135
1136
  TOKEN_COLON,
1136
1137
  TOKEN_DASH,
@@ -1222,7 +1223,7 @@ static AST_DOCUMENT_NODE_T* parser_parse_document(parser_T* parser) {
1222
1223
  return document_node;
1223
1224
  }
1224
1225
 
1225
- AST_DOCUMENT_NODE_T* parser_parse(parser_T* parser) {
1226
+ AST_DOCUMENT_NODE_T* herb_parser_parse(parser_T* parser) {
1226
1227
  return parser_parse_document(parser);
1227
1228
  }
1228
1229
 
@@ -28,9 +28,9 @@ typedef struct PARSER_STRUCT {
28
28
  parser_options_T* options;
29
29
  } parser_T;
30
30
 
31
- parser_T* parser_init(lexer_T* lexer, parser_options_T* options);
31
+ parser_T* herb_parser_init(lexer_T* lexer, parser_options_T* options);
32
32
 
33
- AST_DOCUMENT_NODE_T* parser_parse(parser_T* parser);
33
+ AST_DOCUMENT_NODE_T* herb_parser_parse(parser_T* parser);
34
34
 
35
35
  size_t parser_sizeof(void);
36
36
 
@@ -254,7 +254,7 @@ void pretty_print_string_property(
254
254
  }
255
255
  }
256
256
 
257
- void pretty_print_analyed_ruby(analyzed_ruby_T* analyzed, const char* source) {
257
+ void pretty_print_analyzed_ruby(analyzed_ruby_T* analyzed, const char* source) {
258
258
  printf(
259
259
  "------------------------\nanalyzed (%p)\n------------------------\n%s\n------------------------\n if: %i\n "
260
260
  " elsif: %i\n else: %i\n end: %i\n block: %i\n block_closing: %i\n case: %i\n when: %i\n for: "
@@ -88,6 +88,6 @@ void pretty_print_array(
88
88
 
89
89
  void pretty_print_errors(AST_NODE_T* node, size_t indent, size_t relative_indent, bool last_property, buffer_T* buffer);
90
90
 
91
- void pretty_print_analyed_ruby(analyzed_ruby_T* analyzed, const char* source);
91
+ void pretty_print_analyzed_ruby(analyzed_ruby_T* analyzed, const char* source);
92
92
 
93
93
  #endif
@@ -1,6 +1,6 @@
1
1
  #ifndef HERB_VERSION_H
2
2
  #define HERB_VERSION_H
3
3
 
4
- #define HERB_VERSION "0.7.2"
4
+ #define HERB_VERSION "0.7.4"
5
5
 
6
6
  #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-0.7.2/templates/src/visitor.c.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.4/templates/src/visitor.c.erb
3
3
 
4
4
  #include <stdio.h>
5
5
 
@@ -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-0.7.2/templates/javascript/packages/node/extension/nodes.cpp.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.4/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-0.7.2/templates/javascript/packages/node/extension/nodes.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.4/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.7.2",
3
+ "version": "0.7.4",
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.7.2",
51
+ "@herb-tools/core": "0.7.4",
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"