@herb-tools/node 0.6.1 → 0.7.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.
Files changed (42) hide show
  1. package/binding.gyp +1 -0
  2. package/dist/herb-node.esm.js +1 -1
  3. package/extension/error_helpers.cpp +1 -1
  4. package/extension/error_helpers.h +1 -1
  5. package/extension/libherb/ast_nodes.c +3 -2
  6. package/extension/libherb/ast_nodes.h +4 -2
  7. package/extension/libherb/ast_pretty_print.c +3 -2
  8. package/extension/libherb/ast_pretty_print.h +1 -1
  9. package/extension/libherb/element_source.c +11 -0
  10. package/extension/libherb/element_source.h +13 -0
  11. package/extension/libherb/errors.c +1 -1
  12. package/extension/libherb/errors.h +1 -1
  13. package/extension/libherb/include/ast_nodes.h +4 -2
  14. package/extension/libherb/include/ast_pretty_print.h +1 -1
  15. package/extension/libherb/include/element_source.h +13 -0
  16. package/extension/libherb/include/errors.h +1 -1
  17. package/extension/libherb/include/version.h +1 -1
  18. package/extension/libherb/parser.c +17 -0
  19. package/extension/libherb/parser_helpers.c +1 -0
  20. package/extension/libherb/version.h +1 -1
  21. package/extension/libherb/visitor.c +1 -1
  22. package/extension/nodes.cpp +4 -1
  23. package/extension/nodes.h +1 -1
  24. package/extension/prism/include/prism/ast.h +275 -49
  25. package/extension/prism/include/prism/diagnostic.h +4 -0
  26. package/extension/prism/include/prism/options.h +43 -3
  27. package/extension/prism/include/prism/regexp.h +2 -2
  28. package/extension/prism/include/prism/util/pm_buffer.h +8 -0
  29. package/extension/prism/include/prism/util/pm_integer.h +4 -0
  30. package/extension/prism/include/prism/util/pm_list.h +6 -0
  31. package/extension/prism/include/prism/util/pm_string.h +12 -2
  32. package/extension/prism/include/prism/version.h +3 -3
  33. package/extension/prism/include/prism.h +39 -14
  34. package/extension/prism/src/diagnostic.c +7 -1
  35. package/extension/prism/src/node.c +2 -0
  36. package/extension/prism/src/options.c +2 -2
  37. package/extension/prism/src/prettyprint.c +2 -0
  38. package/extension/prism/src/prism.c +248 -130
  39. package/extension/prism/src/serialize.c +2 -0
  40. package/extension/prism/src/token_type.c +36 -34
  41. package/package.json +2 -2
  42. package/src/util.ts +1 -1
package/binding.gyp CHANGED
@@ -18,6 +18,7 @@
18
18
  "./extension/libherb/ast_nodes.c",
19
19
  "./extension/libherb/ast_pretty_print.c",
20
20
  "./extension/libherb/buffer.c",
21
+ "./extension/libherb/element_source.c",
21
22
  "./extension/libherb/errors.c",
22
23
  "./extension/libherb/extract.c",
23
24
  "./extension/libherb/herb.c",
@@ -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.6.1";
9
+ var version = "0.7.1";
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.6.1/templates/javascript/packages/node/extension/error_helpers.cpp.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.1/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.6.1/templates/javascript/packages/node/extension/error_helpers.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.1/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
@@ -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.6.1/templates/src/ast_nodes.c.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.1/templates/src/ast_nodes.c.erb
3
3
 
4
4
  #include <stdio.h>
5
5
  #include <stdbool.h>
@@ -62,7 +62,7 @@ AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, to
62
62
  return html_close_tag_node;
63
63
  }
64
64
 
65
- AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, token_T* tag_name, array_T* body, struct AST_HTML_CLOSE_TAG_NODE_STRUCT* close_tag, bool is_void, position_T* start_position, position_T* end_position, array_T* errors) {
65
+ AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, token_T* tag_name, array_T* body, struct AST_HTML_CLOSE_TAG_NODE_STRUCT* close_tag, bool is_void, element_source_t source, position_T* start_position, position_T* end_position, array_T* errors) {
66
66
  AST_HTML_ELEMENT_NODE_T* html_element_node = malloc(sizeof(AST_HTML_ELEMENT_NODE_T));
67
67
 
68
68
  ast_node_init(&html_element_node->base, AST_HTML_ELEMENT_NODE, start_position, end_position, errors);
@@ -72,6 +72,7 @@ AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NOD
72
72
  html_element_node->body = body;
73
73
  html_element_node->close_tag = close_tag;
74
74
  html_element_node->is_void = is_void;
75
+ html_element_node->source = source;
75
76
 
76
77
  return html_element_node;
77
78
  }
@@ -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.6.1/templates/src/include/ast_nodes.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.1/templates/src/include/ast_nodes.h.erb
3
3
 
4
4
  #ifndef HERB_AST_NODES_H
5
5
  #define HERB_AST_NODES_H
@@ -13,6 +13,7 @@
13
13
  #include "location.h"
14
14
  #include "token_struct.h"
15
15
  #include "analyzed_ruby.h"
16
+ #include "element_source.h"
16
17
 
17
18
  typedef enum {
18
19
  AST_DOCUMENT_NODE,
@@ -90,6 +91,7 @@ typedef struct AST_HTML_ELEMENT_NODE_STRUCT {
90
91
  array_T* body;
91
92
  struct AST_HTML_CLOSE_TAG_NODE_STRUCT* close_tag;
92
93
  bool is_void;
94
+ element_source_t source;
93
95
  } AST_HTML_ELEMENT_NODE_T;
94
96
 
95
97
  typedef struct AST_HTML_ATTRIBUTE_VALUE_NODE_STRUCT {
@@ -309,7 +311,7 @@ AST_DOCUMENT_NODE_T* ast_document_node_init(array_T* children, position_T* start
309
311
  AST_LITERAL_NODE_T* ast_literal_node_init(const char* content, position_T* start_position, position_T* end_position, array_T* errors);
310
312
  AST_HTML_OPEN_TAG_NODE_T* ast_html_open_tag_node_init(token_T* tag_opening, token_T* tag_name, token_T* tag_closing, array_T* children, bool is_void, position_T* start_position, position_T* end_position, array_T* errors);
311
313
  AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, token_T* tag_name, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors);
312
- AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, token_T* tag_name, array_T* body, struct AST_HTML_CLOSE_TAG_NODE_STRUCT* close_tag, bool is_void, position_T* start_position, position_T* end_position, array_T* errors);
314
+ AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, token_T* tag_name, array_T* body, struct AST_HTML_CLOSE_TAG_NODE_STRUCT* close_tag, bool is_void, element_source_t source, position_T* start_position, position_T* end_position, array_T* errors);
313
315
  AST_HTML_ATTRIBUTE_VALUE_NODE_T* ast_html_attribute_value_node_init(token_T* open_quote, array_T* children, token_T* close_quote, bool quoted, position_T* start_position, position_T* end_position, array_T* errors);
314
316
  AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(array_T* children, position_T* start_position, position_T* end_position, array_T* errors);
315
317
  AST_HTML_ATTRIBUTE_NODE_T* ast_html_attribute_node_init(struct AST_HTML_ATTRIBUTE_NAME_NODE_STRUCT* name, token_T* equals, struct AST_HTML_ATTRIBUTE_VALUE_NODE_STRUCT* value, position_T* start_position, position_T* end_position, array_T* errors);
@@ -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.6.1/templates/src/ast_pretty_print.c.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.1/templates/src/ast_pretty_print.c.erb
3
3
 
4
4
  #include "include/ast_node.h"
5
5
  #include "include/ast_nodes.h"
@@ -98,7 +98,8 @@ void ast_pretty_print_node(AST_NODE_T* node, const size_t indent, const size_t r
98
98
  }
99
99
  buffer_append(buffer, "\n");
100
100
 
101
- pretty_print_boolean_property("is_void", html_element_node->is_void, indent, relative_indent, true, buffer);
101
+ pretty_print_boolean_property("is_void", html_element_node->is_void, indent, relative_indent, false, buffer);
102
+ pretty_print_string_property(element_source_to_string(html_element_node->source), "source", indent, relative_indent, true, buffer);
102
103
  } break;
103
104
 
104
105
  case AST_HTML_ATTRIBUTE_VALUE_NODE: {
@@ -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.6.1/templates/src/include/ast_pretty_print.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.1/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
@@ -0,0 +1,11 @@
1
+ #include "include/element_source.h"
2
+
3
+ const char* element_source_to_string(element_source_t source) {
4
+ switch (source) {
5
+ case ELEMENT_SOURCE_HTML: return "HTML";
6
+ case ELEMENT_SOURCE_ACTIONVIEW: return "ActionView";
7
+ case ELEMENT_SOURCE_HAML: return "Haml";
8
+ case ELEMENT_SOURCE_SLIM: return "Slim";
9
+ default: return "Unknown";
10
+ }
11
+ }
@@ -0,0 +1,13 @@
1
+ #ifndef HERB_ELEMENT_SOURCE_H
2
+ #define HERB_ELEMENT_SOURCE_H
3
+
4
+ typedef enum {
5
+ ELEMENT_SOURCE_HTML,
6
+ ELEMENT_SOURCE_ACTIONVIEW,
7
+ ELEMENT_SOURCE_HAML,
8
+ ELEMENT_SOURCE_SLIM
9
+ } element_source_t;
10
+
11
+ const char* element_source_to_string(element_source_t source);
12
+
13
+ #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.6.1/templates/src/errors.c.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.1/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.6.1/templates/src/include/errors.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.1/templates/src/include/errors.h.erb
3
3
 
4
4
  #ifndef HERB_ERRORS_H
5
5
  #define HERB_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.6.1/templates/src/include/ast_nodes.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.1/templates/src/include/ast_nodes.h.erb
3
3
 
4
4
  #ifndef HERB_AST_NODES_H
5
5
  #define HERB_AST_NODES_H
@@ -13,6 +13,7 @@
13
13
  #include "location.h"
14
14
  #include "token_struct.h"
15
15
  #include "analyzed_ruby.h"
16
+ #include "element_source.h"
16
17
 
17
18
  typedef enum {
18
19
  AST_DOCUMENT_NODE,
@@ -90,6 +91,7 @@ typedef struct AST_HTML_ELEMENT_NODE_STRUCT {
90
91
  array_T* body;
91
92
  struct AST_HTML_CLOSE_TAG_NODE_STRUCT* close_tag;
92
93
  bool is_void;
94
+ element_source_t source;
93
95
  } AST_HTML_ELEMENT_NODE_T;
94
96
 
95
97
  typedef struct AST_HTML_ATTRIBUTE_VALUE_NODE_STRUCT {
@@ -309,7 +311,7 @@ AST_DOCUMENT_NODE_T* ast_document_node_init(array_T* children, position_T* start
309
311
  AST_LITERAL_NODE_T* ast_literal_node_init(const char* content, position_T* start_position, position_T* end_position, array_T* errors);
310
312
  AST_HTML_OPEN_TAG_NODE_T* ast_html_open_tag_node_init(token_T* tag_opening, token_T* tag_name, token_T* tag_closing, array_T* children, bool is_void, position_T* start_position, position_T* end_position, array_T* errors);
311
313
  AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, token_T* tag_name, array_T* children, token_T* tag_closing, position_T* start_position, position_T* end_position, array_T* errors);
312
- AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, token_T* tag_name, array_T* body, struct AST_HTML_CLOSE_TAG_NODE_STRUCT* close_tag, bool is_void, position_T* start_position, position_T* end_position, array_T* errors);
314
+ AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, token_T* tag_name, array_T* body, struct AST_HTML_CLOSE_TAG_NODE_STRUCT* close_tag, bool is_void, element_source_t source, position_T* start_position, position_T* end_position, array_T* errors);
313
315
  AST_HTML_ATTRIBUTE_VALUE_NODE_T* ast_html_attribute_value_node_init(token_T* open_quote, array_T* children, token_T* close_quote, bool quoted, position_T* start_position, position_T* end_position, array_T* errors);
314
316
  AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(array_T* children, position_T* start_position, position_T* end_position, array_T* errors);
315
317
  AST_HTML_ATTRIBUTE_NODE_T* ast_html_attribute_node_init(struct AST_HTML_ATTRIBUTE_NAME_NODE_STRUCT* name, token_T* equals, struct AST_HTML_ATTRIBUTE_VALUE_NODE_STRUCT* value, position_T* start_position, position_T* end_position, array_T* errors);
@@ -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.6.1/templates/src/include/ast_pretty_print.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.1/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
@@ -0,0 +1,13 @@
1
+ #ifndef HERB_ELEMENT_SOURCE_H
2
+ #define HERB_ELEMENT_SOURCE_H
3
+
4
+ typedef enum {
5
+ ELEMENT_SOURCE_HTML,
6
+ ELEMENT_SOURCE_ACTIONVIEW,
7
+ ELEMENT_SOURCE_HAML,
8
+ ELEMENT_SOURCE_SLIM
9
+ } element_source_t;
10
+
11
+ const char* element_source_to_string(element_source_t source);
12
+
13
+ #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.6.1/templates/src/include/errors.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.1/templates/src/include/errors.h.erb
3
3
 
4
4
  #ifndef HERB_ERRORS_H
5
5
  #define HERB_ERRORS_H
@@ -1,6 +1,6 @@
1
1
  #ifndef HERB_VERSION_H
2
2
  #define HERB_VERSION_H
3
3
 
4
- #define HERB_VERSION "0.6.1"
4
+ #define HERB_VERSION "0.7.1"
5
5
 
6
6
  #endif
@@ -805,6 +805,20 @@ static AST_HTML_OPEN_TAG_NODE_T* parser_parse_html_open_tag(parser_T* parser) {
805
805
  continue;
806
806
  }
807
807
 
808
+ if (parser->current_token->type == TOKEN_COLON) {
809
+ lexer_T lexer_copy = *parser->lexer;
810
+ token_T* next_token = lexer_next_token(&lexer_copy);
811
+
812
+ if (next_token && next_token->type == TOKEN_IDENTIFIER) {
813
+ token_free(next_token);
814
+ array_append(children, parser_parse_html_attribute(parser));
815
+
816
+ continue;
817
+ }
818
+
819
+ token_free(next_token);
820
+ }
821
+
808
822
  parser_append_unexpected_error(
809
823
  parser,
810
824
  "Unexpected Token",
@@ -910,6 +924,7 @@ static AST_HTML_ELEMENT_NODE_T* parser_parse_html_self_closing_element(
910
924
  NULL,
911
925
  NULL,
912
926
  true,
927
+ ELEMENT_SOURCE_HTML,
913
928
  open_tag->base.location->start,
914
929
  open_tag->base.location->end,
915
930
  NULL
@@ -958,6 +973,7 @@ static AST_HTML_ELEMENT_NODE_T* parser_parse_html_regular_element(
958
973
  body,
959
974
  close_tag,
960
975
  false,
976
+ ELEMENT_SOURCE_HTML,
961
977
  open_tag->base.location->start,
962
978
  close_tag->base.location->end,
963
979
  errors
@@ -988,6 +1004,7 @@ static AST_HTML_ELEMENT_NODE_T* parser_parse_html_element(parser_T* parser) {
988
1004
  NULL,
989
1005
  NULL,
990
1006
  false,
1007
+ ELEMENT_SOURCE_HTML,
991
1008
  open_tag->base.location->start,
992
1009
  open_tag->base.location->end,
993
1010
  errors
@@ -173,6 +173,7 @@ AST_HTML_ELEMENT_NODE_T* parser_handle_missing_close_tag(
173
173
  body,
174
174
  NULL,
175
175
  false,
176
+ ELEMENT_SOURCE_HTML,
176
177
  open_tag->base.location->start,
177
178
  open_tag->base.location->end,
178
179
  errors
@@ -1,6 +1,6 @@
1
1
  #ifndef HERB_VERSION_H
2
2
  #define HERB_VERSION_H
3
3
 
4
- #define HERB_VERSION "0.6.1"
4
+ #define HERB_VERSION "0.7.1"
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.6.1/templates/src/visitor.c.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.1/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.6.1/templates/javascript/packages/node/extension/nodes.cpp.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.1/templates/javascript/packages/node/extension/nodes.cpp.erb
3
3
 
4
4
  #include <node_api.h>
5
5
  #include "error_helpers.h"
@@ -174,6 +174,9 @@ napi_value html_element_nodeNodeFromCStruct(napi_env env, AST_HTML_ELEMENT_NODE_
174
174
  napi_get_boolean(env, html_element_node->is_void, &is_void);
175
175
  napi_set_named_property(env, result, "is_void", is_void);
176
176
 
177
+ napi_value source = CreateString(env, element_source_to_string(html_element_node->source));
178
+ napi_set_named_property(env, result, "source", source);
179
+
177
180
 
178
181
  return result;
179
182
  }
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.6.1/templates/javascript/packages/node/extension/nodes.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.1/templates/javascript/packages/node/extension/nodes.h.erb
3
3
 
4
4
  #ifndef HERB_EXTENSION_NODES_H
5
5
  #define HERB_EXTENSION_NODES_H