@herb-tools/node 0.7.4 → 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.
Files changed (131) hide show
  1. package/binding.gyp +8 -5
  2. package/dist/herb-node.esm.js +6 -6
  3. package/dist/herb-node.esm.js.map +1 -1
  4. package/extension/error_helpers.cpp +67 -9
  5. package/extension/error_helpers.h +4 -2
  6. package/extension/extension_helpers.cpp +20 -31
  7. package/extension/extension_helpers.h +7 -5
  8. package/extension/herb.cpp +10 -42
  9. package/extension/libherb/analyze.c +461 -249
  10. package/extension/libherb/analyze.h +10 -2
  11. package/extension/libherb/analyze_helpers.c +5 -0
  12. package/extension/libherb/analyze_helpers.h +3 -0
  13. package/extension/libherb/analyze_missing_end.c +147 -0
  14. package/extension/libherb/analyze_transform.c +196 -0
  15. package/extension/libherb/analyzed_ruby.c +23 -2
  16. package/extension/libherb/analyzed_ruby.h +4 -2
  17. package/extension/libherb/ast_node.c +14 -17
  18. package/extension/libherb/ast_node.h +4 -4
  19. package/extension/libherb/ast_nodes.c +180 -182
  20. package/extension/libherb/ast_nodes.h +69 -68
  21. package/extension/libherb/ast_pretty_print.c +233 -233
  22. package/extension/libherb/ast_pretty_print.h +3 -3
  23. package/extension/libherb/element_source.c +7 -6
  24. package/extension/libherb/element_source.h +3 -1
  25. package/extension/libherb/errors.c +273 -153
  26. package/extension/libherb/errors.h +43 -27
  27. package/extension/libherb/extract.c +92 -34
  28. package/extension/libherb/extract.h +4 -4
  29. package/extension/libherb/herb.c +37 -49
  30. package/extension/libherb/herb.h +6 -7
  31. package/extension/libherb/html_util.c +34 -96
  32. package/extension/libherb/html_util.h +4 -5
  33. package/extension/libherb/include/analyze.h +10 -2
  34. package/extension/libherb/include/analyze_helpers.h +3 -0
  35. package/extension/libherb/include/analyzed_ruby.h +4 -2
  36. package/extension/libherb/include/ast_node.h +4 -4
  37. package/extension/libherb/include/ast_nodes.h +69 -68
  38. package/extension/libherb/include/ast_pretty_print.h +3 -3
  39. package/extension/libherb/include/element_source.h +3 -1
  40. package/extension/libherb/include/errors.h +43 -27
  41. package/extension/libherb/include/extract.h +4 -4
  42. package/extension/libherb/include/herb.h +6 -7
  43. package/extension/libherb/include/html_util.h +4 -5
  44. package/extension/libherb/include/lexer.h +1 -3
  45. package/extension/libherb/include/lexer_peek_helpers.h +21 -19
  46. package/extension/libherb/include/lexer_struct.h +12 -10
  47. package/extension/libherb/include/location.h +10 -13
  48. package/extension/libherb/include/macros.h +4 -0
  49. package/extension/libherb/include/parser.h +12 -6
  50. package/extension/libherb/include/parser_helpers.h +26 -16
  51. package/extension/libherb/include/position.h +3 -14
  52. package/extension/libherb/include/pretty_print.h +38 -28
  53. package/extension/libherb/include/prism_helpers.h +1 -1
  54. package/extension/libherb/include/range.h +4 -13
  55. package/extension/libherb/include/token.h +5 -11
  56. package/extension/libherb/include/token_struct.h +2 -2
  57. package/extension/libherb/include/utf8.h +3 -2
  58. package/extension/libherb/include/util/hb_arena.h +31 -0
  59. package/extension/libherb/include/util/hb_arena_debug.h +8 -0
  60. package/extension/libherb/include/util/hb_array.h +33 -0
  61. package/extension/libherb/include/util/hb_buffer.h +34 -0
  62. package/extension/libherb/include/util/hb_string.h +29 -0
  63. package/extension/libherb/include/util/hb_system.h +9 -0
  64. package/extension/libherb/include/util.h +3 -14
  65. package/extension/libherb/include/version.h +1 -1
  66. package/extension/libherb/include/visitor.h +1 -1
  67. package/extension/libherb/io.c +7 -4
  68. package/extension/libherb/lexer.c +62 -88
  69. package/extension/libherb/lexer.h +1 -3
  70. package/extension/libherb/lexer_peek_helpers.c +42 -38
  71. package/extension/libherb/lexer_peek_helpers.h +21 -19
  72. package/extension/libherb/lexer_struct.h +12 -10
  73. package/extension/libherb/location.c +9 -37
  74. package/extension/libherb/location.h +10 -13
  75. package/extension/libherb/macros.h +4 -0
  76. package/extension/libherb/main.c +19 -23
  77. package/extension/libherb/parser.c +373 -313
  78. package/extension/libherb/parser.h +12 -6
  79. package/extension/libherb/parser_helpers.c +60 -54
  80. package/extension/libherb/parser_helpers.h +26 -16
  81. package/extension/libherb/parser_match_tags.c +316 -0
  82. package/extension/libherb/position.h +3 -14
  83. package/extension/libherb/pretty_print.c +88 -117
  84. package/extension/libherb/pretty_print.h +38 -28
  85. package/extension/libherb/prism_helpers.c +7 -7
  86. package/extension/libherb/prism_helpers.h +1 -1
  87. package/extension/libherb/range.c +2 -35
  88. package/extension/libherb/range.h +4 -13
  89. package/extension/libherb/token.c +36 -87
  90. package/extension/libherb/token.h +5 -11
  91. package/extension/libherb/token_struct.h +2 -2
  92. package/extension/libherb/utf8.c +4 -4
  93. package/extension/libherb/utf8.h +3 -2
  94. package/extension/libherb/util/hb_arena.c +179 -0
  95. package/extension/libherb/util/hb_arena.h +31 -0
  96. package/extension/libherb/util/hb_arena_debug.c +237 -0
  97. package/extension/libherb/util/hb_arena_debug.h +8 -0
  98. package/extension/libherb/{array.c → util/hb_array.c} +26 -27
  99. package/extension/libherb/util/hb_array.h +33 -0
  100. package/extension/libherb/util/hb_buffer.c +203 -0
  101. package/extension/libherb/util/hb_buffer.h +34 -0
  102. package/extension/libherb/util/hb_string.c +85 -0
  103. package/extension/libherb/util/hb_string.h +29 -0
  104. package/extension/libherb/util/hb_system.c +30 -0
  105. package/extension/libherb/util/hb_system.h +9 -0
  106. package/extension/libherb/util.c +29 -99
  107. package/extension/libherb/util.h +3 -14
  108. package/extension/libherb/version.h +1 -1
  109. package/extension/libherb/visitor.c +55 -55
  110. package/extension/libherb/visitor.h +1 -1
  111. package/extension/nodes.cpp +40 -40
  112. package/extension/nodes.h +2 -2
  113. package/extension/prism/include/prism/ast.h +31 -1
  114. package/extension/prism/include/prism/diagnostic.h +1 -0
  115. package/extension/prism/include/prism/version.h +3 -3
  116. package/extension/prism/src/diagnostic.c +3 -1
  117. package/extension/prism/src/prism.c +130 -71
  118. package/extension/prism/src/util/pm_string.c +6 -8
  119. package/package.json +3 -3
  120. package/extension/libherb/array.h +0 -33
  121. package/extension/libherb/buffer.c +0 -232
  122. package/extension/libherb/buffer.h +0 -39
  123. package/extension/libherb/include/array.h +0 -33
  124. package/extension/libherb/include/buffer.h +0 -39
  125. package/extension/libherb/include/json.h +0 -28
  126. package/extension/libherb/include/memory.h +0 -12
  127. package/extension/libherb/json.c +0 -205
  128. package/extension/libherb/json.h +0 -28
  129. package/extension/libherb/memory.c +0 -53
  130. package/extension/libherb/memory.h +0 -12
  131. package/extension/libherb/position.c +0 -33
@@ -0,0 +1,85 @@
1
+ #include "../include/util/hb_string.h"
2
+ #include "../include/macros.h"
3
+
4
+ #include <stdlib.h>
5
+ #include <string.h>
6
+ #include <strings.h>
7
+
8
+ hb_string_T hb_string(const char* null_terminated_c_string) {
9
+ hb_string_T string;
10
+
11
+ string.data = (char*) null_terminated_c_string;
12
+ string.length = (uint32_t) strlen(null_terminated_c_string);
13
+
14
+ return string;
15
+ }
16
+
17
+ hb_string_T hb_string_slice(hb_string_T string, uint32_t offset) {
18
+ hb_string_T slice;
19
+ if (string.length < offset) {
20
+ slice.data = NULL;
21
+ slice.length = 0;
22
+
23
+ return slice;
24
+ }
25
+
26
+ slice.data = string.data + offset;
27
+ slice.length = string.length - offset;
28
+
29
+ return slice;
30
+ }
31
+
32
+ bool hb_string_equals(hb_string_T a, hb_string_T b) {
33
+ if (a.length != b.length) { return false; }
34
+
35
+ return strncmp(a.data, b.data, a.length) == 0;
36
+ }
37
+
38
+ bool hb_string_equals_case_insensitive(hb_string_T a, hb_string_T b) {
39
+ if (a.length != b.length) { return false; }
40
+
41
+ return strncasecmp(a.data, b.data, a.length) == 0;
42
+ }
43
+
44
+ bool hb_string_starts_with(hb_string_T string, hb_string_T expected_prefix) {
45
+ if (hb_string_is_empty(string) || hb_string_is_empty(expected_prefix)) { return false; }
46
+ if (string.length < expected_prefix.length) { return false; }
47
+
48
+ return strncmp(string.data, expected_prefix.data, expected_prefix.length) == 0;
49
+ }
50
+
51
+ bool hb_string_is_empty(hb_string_T string) {
52
+ return string.length == 0;
53
+ }
54
+
55
+ hb_string_T hb_string_truncate(hb_string_T string, uint32_t max_length) {
56
+ hb_string_T truncated_string = { .data = string.data, .length = MIN(string.length, max_length) };
57
+
58
+ return truncated_string;
59
+ }
60
+
61
+ hb_string_T hb_string_range(hb_string_T string, uint32_t from, uint32_t to) {
62
+ return hb_string_truncate(hb_string_slice(string, from), to - from);
63
+ }
64
+
65
+ char* hb_string_to_c_string_using_malloc(hb_string_T string) {
66
+ size_t string_length_in_bytes = sizeof(char) * (string.length);
67
+ char* buffer = malloc(string_length_in_bytes + sizeof(char) * 1);
68
+
69
+ if (!hb_string_is_empty(string)) { memcpy(buffer, string.data, string_length_in_bytes); }
70
+
71
+ buffer[string_length_in_bytes] = '\0';
72
+
73
+ return buffer;
74
+ }
75
+
76
+ char* hb_string_to_c_string(hb_arena_T* allocator, hb_string_T string) {
77
+ size_t string_length_in_bytes = sizeof(char) * (string.length);
78
+ char* buffer = hb_arena_alloc(allocator, string_length_in_bytes + sizeof(char) * 1);
79
+
80
+ if (!hb_string_is_empty(string)) { memcpy(buffer, string.data, string_length_in_bytes); }
81
+
82
+ buffer[string_length_in_bytes] = '\0';
83
+
84
+ return buffer;
85
+ }
@@ -0,0 +1,29 @@
1
+ #ifndef HERB_STRING_H
2
+ #define HERB_STRING_H
3
+
4
+ #include <stdbool.h>
5
+ #include <stddef.h>
6
+ #include <stdint.h>
7
+
8
+ #include "hb_arena.h"
9
+
10
+ typedef struct HB_STRING_STRUCT {
11
+ char* data;
12
+ uint32_t length;
13
+ } hb_string_T;
14
+
15
+ hb_string_T hb_string(const char* null_terminated_c_string);
16
+ hb_string_T hb_string_slice(hb_string_T string, uint32_t offset);
17
+ bool hb_string_equals(hb_string_T a, hb_string_T b);
18
+ bool hb_string_equals_case_insensitive(hb_string_T a, hb_string_T b);
19
+ bool hb_string_starts_with(hb_string_T string, hb_string_T expected_prefix);
20
+ bool hb_string_is_empty(hb_string_T string);
21
+ hb_string_T hb_string_truncate(hb_string_T string, uint32_t max_length);
22
+
23
+ hb_string_T hb_string_range(hb_string_T string, uint32_t from, uint32_t to);
24
+
25
+ char* hb_string_to_c_string_using_malloc(hb_string_T string);
26
+
27
+ char* hb_string_to_c_string(hb_arena_T* allocator, hb_string_T string);
28
+
29
+ #endif
@@ -0,0 +1,30 @@
1
+ #include "../include/util/hb_system.h"
2
+
3
+ #ifdef __linux__
4
+ #define _GNU_SOURCE
5
+ #endif
6
+
7
+ #ifdef HB_USE_MALLOC
8
+ #include <stdlib.h>
9
+ #else
10
+ #include <sys/mman.h>
11
+ #endif
12
+
13
+ void* hb_system_allocate_memory(size_t size) {
14
+ #ifdef HB_USE_MALLOC
15
+ return malloc(size);
16
+ #else
17
+ void* memory = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
18
+ if (memory == MAP_FAILED) { return NULL; }
19
+
20
+ return memory;
21
+ #endif
22
+ }
23
+
24
+ void hb_system_free_memory(void* ptr, size_t size) {
25
+ #ifdef HB_USE_MALLOC
26
+ free(ptr);
27
+ #else
28
+ munmap(ptr, size);
29
+ #endif
30
+ }
@@ -0,0 +1,9 @@
1
+ #ifndef HERB_SYSTEM_H
2
+ #define HERB_SYSTEM_H
3
+
4
+ #include <stddef.h>
5
+
6
+ void* hb_system_allocate_memory(size_t size);
7
+ void hb_system_free_memory(void* ptr, size_t size);
8
+
9
+ #endif
@@ -1,118 +1,55 @@
1
1
  #include "include/util.h"
2
+ #include "include/util/hb_buffer.h"
3
+ #include "include/util/hb_string.h"
2
4
 
3
- #include <ctype.h>
4
5
  #include <stdio.h>
5
6
  #include <stdlib.h>
6
7
  #include <string.h>
7
8
 
8
- int is_whitespace(const int character) {
9
- return character == ' ' || character == '\t';
9
+ int is_newline(int character) {
10
+ return character == '\n' || character == '\r';
10
11
  }
11
12
 
12
- int is_newline(const int character) {
13
- return character == 13 || character == 10;
14
- }
15
-
16
- int count_in_string(const char* string, const char character) {
17
- int count = 0;
13
+ hb_string_T escape_newlines(hb_string_T input) {
14
+ hb_buffer_T buffer;
18
15
 
19
- while (*string != '\0') {
20
- if (*string == character) { count++; }
16
+ hb_buffer_init(&buffer, input.length);
21
17
 
22
- string++;
23
- }
24
-
25
- return count;
26
- }
27
-
28
- int count_newlines(const char* string) {
29
- int count = 0;
30
-
31
- while (*string) {
32
- if (*string == '\r') {
33
- count++;
34
- if (*(string + 1) == '\n') { string++; }
35
- } else if (*string == '\n') {
36
- count++;
18
+ for (size_t i = 0; i < input.length; ++i) {
19
+ switch (input.data[i]) {
20
+ case '\n': {
21
+ hb_buffer_append_char(&buffer, '\\');
22
+ hb_buffer_append_char(&buffer, 'n');
23
+ } break;
24
+ case '\r': {
25
+ hb_buffer_append_char(&buffer, '\\');
26
+ hb_buffer_append_char(&buffer, 'r');
27
+ } break;
28
+ default: {
29
+ hb_buffer_append_char(&buffer, input.data[i]);
30
+ }
37
31
  }
38
-
39
- string++;
40
32
  }
41
33
 
42
- return count;
34
+ return hb_string(buffer.value);
43
35
  }
44
36
 
45
- char* replace_char(char* string, const char find, const char replace) {
46
- char* original_string = string;
47
-
48
- while (*string != '\0') {
49
- if (*string == find) { *string = replace; }
37
+ static hb_string_T wrap_string(hb_string_T input, char character) {
38
+ hb_buffer_T buffer;
50
39
 
51
- string++;
52
- }
53
-
54
- return original_string;
55
- }
56
-
57
- char* escape_newlines(const char* input) {
58
- char* output = calloc(strlen(input) * 2 + 1, sizeof(char));
59
- char* orig_output = output;
60
-
61
- while (*input) {
62
- if (*input == '\n') {
63
- *output++ = '\\';
64
- *output++ = 'n';
65
- } else if (*input == '\r') {
66
- *output++ = '\\';
67
- *output++ = 'r';
68
- } else {
69
- *output++ = *input;
70
- }
71
-
72
- input++;
73
- }
40
+ hb_buffer_init(&buffer, input.length + 2);
74
41
 
75
- *output = '\0';
42
+ hb_buffer_append_char(&buffer, character);
43
+ hb_buffer_append_string(&buffer, input);
44
+ hb_buffer_append_char(&buffer, character);
76
45
 
77
- return orig_output;
46
+ return hb_string(buffer.value);
78
47
  }
79
48
 
80
- char* wrap_string(const char* input, const char character) {
81
- if (input == NULL) { return NULL; }
82
-
83
- const size_t length = strlen(input);
84
- char* wrapped = malloc(length + 3);
85
-
86
- if (wrapped == NULL) { return NULL; }
87
-
88
- wrapped[0] = character;
89
- strcpy(wrapped + 1, input);
90
- wrapped[length + 1] = character;
91
- wrapped[length + 2] = '\0';
92
-
93
- return wrapped;
94
- }
95
-
96
- char* quoted_string(const char* input) {
49
+ hb_string_T quoted_string(hb_string_T input) {
97
50
  return wrap_string(input, '"');
98
51
  }
99
52
 
100
- // Check if a string is blank (NULL, empty, or only contains whitespace)
101
- bool string_blank(const char* input) {
102
- if (input == NULL || input[0] == '\0') { return true; }
103
-
104
- for (const char* p = input; *p != '\0'; p++) {
105
- if (!isspace(*p)) { return false; }
106
- }
107
-
108
- return true;
109
- }
110
-
111
- // Check if a string is present (not blank)
112
- bool string_present(const char* input) {
113
- return !string_blank(input);
114
- }
115
-
116
53
  char* herb_strdup(const char* s) {
117
54
  size_t len = strlen(s) + 1;
118
55
  char* copy = malloc(len);
@@ -121,10 +58,3 @@ char* herb_strdup(const char* s) {
121
58
 
122
59
  return copy;
123
60
  }
124
-
125
- char* size_t_to_string(const size_t value) {
126
- char* buffer = malloc(21);
127
- snprintf(buffer, 21, "%zu", value);
128
-
129
- return buffer;
130
- }
@@ -1,25 +1,14 @@
1
1
  #ifndef HERB_UTIL_H
2
2
  #define HERB_UTIL_H
3
3
 
4
+ #include "util/hb_string.h"
4
5
  #include <stdbool.h>
5
6
  #include <stdlib.h>
6
7
 
7
- int is_whitespace(int character);
8
8
  int is_newline(int character);
9
9
 
10
- int count_in_string(const char* string, char character);
11
- int count_newlines(const char* string);
12
-
13
- char* replace_char(char* string, char find, char replace);
14
- char* escape_newlines(const char* input);
15
- char* quoted_string(const char* input);
16
- char* wrap_string(const char* input, char character);
17
-
18
- bool string_blank(const char* input);
19
- bool string_present(const char* input);
20
-
10
+ hb_string_T escape_newlines(hb_string_T input);
11
+ hb_string_T quoted_string(hb_string_T input);
21
12
  char* herb_strdup(const char* s);
22
13
 
23
- char* size_t_to_string(size_t value);
24
-
25
14
  #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.4"
4
+ #define HERB_VERSION "0.8.0"
5
5
 
6
6
  #endif
@@ -1,12 +1,12 @@
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.4/templates/src/visitor.c.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.0/templates/src/visitor.c.erb
3
3
 
4
4
  #include <stdio.h>
5
5
 
6
- #include "include/array.h"
7
- #include "include/visitor.h"
8
6
  #include "include/ast_node.h"
9
7
  #include "include/ast_nodes.h"
8
+ #include "include/util/hb_array.h"
9
+ #include "include/visitor.h"
10
10
 
11
11
  void herb_visit_node(const AST_NODE_T* node, bool (*visitor)(const AST_NODE_T*, void*), void* data) {
12
12
  if (visitor(node, data) && node != NULL) {
@@ -24,8 +24,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
24
24
  const AST_DOCUMENT_NODE_T* document_node = ((const AST_DOCUMENT_NODE_T *) node);
25
25
 
26
26
  if (document_node->children != NULL) {
27
- for (size_t index = 0; index < array_size(document_node->children); index++) {
28
- herb_visit_node(array_get(document_node->children, index), visitor, data);
27
+ for (size_t index = 0; index < hb_array_size(document_node->children); index++) {
28
+ herb_visit_node(hb_array_get(document_node->children, index), visitor, data);
29
29
  }
30
30
  }
31
31
 
@@ -35,8 +35,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
35
35
  const AST_HTML_OPEN_TAG_NODE_T* html_open_tag_node = ((const AST_HTML_OPEN_TAG_NODE_T *) node);
36
36
 
37
37
  if (html_open_tag_node->children != NULL) {
38
- for (size_t index = 0; index < array_size(html_open_tag_node->children); index++) {
39
- herb_visit_node(array_get(html_open_tag_node->children, index), visitor, data);
38
+ for (size_t index = 0; index < hb_array_size(html_open_tag_node->children); index++) {
39
+ herb_visit_node(hb_array_get(html_open_tag_node->children, index), visitor, data);
40
40
  }
41
41
  }
42
42
 
@@ -46,8 +46,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
46
46
  const AST_HTML_CLOSE_TAG_NODE_T* html_close_tag_node = ((const AST_HTML_CLOSE_TAG_NODE_T *) node);
47
47
 
48
48
  if (html_close_tag_node->children != NULL) {
49
- for (size_t index = 0; index < array_size(html_close_tag_node->children); index++) {
50
- herb_visit_node(array_get(html_close_tag_node->children, index), visitor, data);
49
+ for (size_t index = 0; index < hb_array_size(html_close_tag_node->children); index++) {
50
+ herb_visit_node(hb_array_get(html_close_tag_node->children, index), visitor, data);
51
51
  }
52
52
  }
53
53
 
@@ -61,8 +61,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
61
61
  }
62
62
 
63
63
  if (html_element_node->body != NULL) {
64
- for (size_t index = 0; index < array_size(html_element_node->body); index++) {
65
- herb_visit_node(array_get(html_element_node->body, index), visitor, data);
64
+ for (size_t index = 0; index < hb_array_size(html_element_node->body); index++) {
65
+ herb_visit_node(hb_array_get(html_element_node->body, index), visitor, data);
66
66
  }
67
67
  }
68
68
 
@@ -76,8 +76,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
76
76
  const AST_HTML_ATTRIBUTE_VALUE_NODE_T* html_attribute_value_node = ((const AST_HTML_ATTRIBUTE_VALUE_NODE_T *) node);
77
77
 
78
78
  if (html_attribute_value_node->children != NULL) {
79
- for (size_t index = 0; index < array_size(html_attribute_value_node->children); index++) {
80
- herb_visit_node(array_get(html_attribute_value_node->children, index), visitor, data);
79
+ for (size_t index = 0; index < hb_array_size(html_attribute_value_node->children); index++) {
80
+ herb_visit_node(hb_array_get(html_attribute_value_node->children, index), visitor, data);
81
81
  }
82
82
  }
83
83
 
@@ -87,8 +87,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
87
87
  const AST_HTML_ATTRIBUTE_NAME_NODE_T* html_attribute_name_node = ((const AST_HTML_ATTRIBUTE_NAME_NODE_T *) node);
88
88
 
89
89
  if (html_attribute_name_node->children != NULL) {
90
- for (size_t index = 0; index < array_size(html_attribute_name_node->children); index++) {
91
- herb_visit_node(array_get(html_attribute_name_node->children, index), visitor, data);
90
+ for (size_t index = 0; index < hb_array_size(html_attribute_name_node->children); index++) {
91
+ herb_visit_node(hb_array_get(html_attribute_name_node->children, index), visitor, data);
92
92
  }
93
93
  }
94
94
 
@@ -111,8 +111,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
111
111
  const AST_HTML_COMMENT_NODE_T* html_comment_node = ((const AST_HTML_COMMENT_NODE_T *) node);
112
112
 
113
113
  if (html_comment_node->children != NULL) {
114
- for (size_t index = 0; index < array_size(html_comment_node->children); index++) {
115
- herb_visit_node(array_get(html_comment_node->children, index), visitor, data);
114
+ for (size_t index = 0; index < hb_array_size(html_comment_node->children); index++) {
115
+ herb_visit_node(hb_array_get(html_comment_node->children, index), visitor, data);
116
116
  }
117
117
  }
118
118
 
@@ -122,8 +122,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
122
122
  const AST_HTML_DOCTYPE_NODE_T* html_doctype_node = ((const AST_HTML_DOCTYPE_NODE_T *) node);
123
123
 
124
124
  if (html_doctype_node->children != NULL) {
125
- for (size_t index = 0; index < array_size(html_doctype_node->children); index++) {
126
- herb_visit_node(array_get(html_doctype_node->children, index), visitor, data);
125
+ for (size_t index = 0; index < hb_array_size(html_doctype_node->children); index++) {
126
+ herb_visit_node(hb_array_get(html_doctype_node->children, index), visitor, data);
127
127
  }
128
128
  }
129
129
 
@@ -133,8 +133,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
133
133
  const AST_XML_DECLARATION_NODE_T* xml_declaration_node = ((const AST_XML_DECLARATION_NODE_T *) node);
134
134
 
135
135
  if (xml_declaration_node->children != NULL) {
136
- for (size_t index = 0; index < array_size(xml_declaration_node->children); index++) {
137
- herb_visit_node(array_get(xml_declaration_node->children, index), visitor, data);
136
+ for (size_t index = 0; index < hb_array_size(xml_declaration_node->children); index++) {
137
+ herb_visit_node(hb_array_get(xml_declaration_node->children, index), visitor, data);
138
138
  }
139
139
  }
140
140
 
@@ -144,8 +144,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
144
144
  const AST_CDATA_NODE_T* cdata_node = ((const AST_CDATA_NODE_T *) node);
145
145
 
146
146
  if (cdata_node->children != NULL) {
147
- for (size_t index = 0; index < array_size(cdata_node->children); index++) {
148
- herb_visit_node(array_get(cdata_node->children, index), visitor, data);
147
+ for (size_t index = 0; index < hb_array_size(cdata_node->children); index++) {
148
+ herb_visit_node(hb_array_get(cdata_node->children, index), visitor, data);
149
149
  }
150
150
  }
151
151
 
@@ -155,8 +155,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
155
155
  const AST_ERB_ELSE_NODE_T* erb_else_node = ((const AST_ERB_ELSE_NODE_T *) node);
156
156
 
157
157
  if (erb_else_node->statements != NULL) {
158
- for (size_t index = 0; index < array_size(erb_else_node->statements); index++) {
159
- herb_visit_node(array_get(erb_else_node->statements, index), visitor, data);
158
+ for (size_t index = 0; index < hb_array_size(erb_else_node->statements); index++) {
159
+ herb_visit_node(hb_array_get(erb_else_node->statements, index), visitor, data);
160
160
  }
161
161
  }
162
162
 
@@ -166,8 +166,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
166
166
  const AST_ERB_IF_NODE_T* erb_if_node = ((const AST_ERB_IF_NODE_T *) node);
167
167
 
168
168
  if (erb_if_node->statements != NULL) {
169
- for (size_t index = 0; index < array_size(erb_if_node->statements); index++) {
170
- herb_visit_node(array_get(erb_if_node->statements, index), visitor, data);
169
+ for (size_t index = 0; index < hb_array_size(erb_if_node->statements); index++) {
170
+ herb_visit_node(hb_array_get(erb_if_node->statements, index), visitor, data);
171
171
  }
172
172
  }
173
173
 
@@ -185,8 +185,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
185
185
  const AST_ERB_BLOCK_NODE_T* erb_block_node = ((const AST_ERB_BLOCK_NODE_T *) node);
186
186
 
187
187
  if (erb_block_node->body != NULL) {
188
- for (size_t index = 0; index < array_size(erb_block_node->body); index++) {
189
- herb_visit_node(array_get(erb_block_node->body, index), visitor, data);
188
+ for (size_t index = 0; index < hb_array_size(erb_block_node->body); index++) {
189
+ herb_visit_node(hb_array_get(erb_block_node->body, index), visitor, data);
190
190
  }
191
191
  }
192
192
 
@@ -200,8 +200,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
200
200
  const AST_ERB_WHEN_NODE_T* erb_when_node = ((const AST_ERB_WHEN_NODE_T *) node);
201
201
 
202
202
  if (erb_when_node->statements != NULL) {
203
- for (size_t index = 0; index < array_size(erb_when_node->statements); index++) {
204
- herb_visit_node(array_get(erb_when_node->statements, index), visitor, data);
203
+ for (size_t index = 0; index < hb_array_size(erb_when_node->statements); index++) {
204
+ herb_visit_node(hb_array_get(erb_when_node->statements, index), visitor, data);
205
205
  }
206
206
  }
207
207
 
@@ -211,14 +211,14 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
211
211
  const AST_ERB_CASE_NODE_T* erb_case_node = ((const AST_ERB_CASE_NODE_T *) node);
212
212
 
213
213
  if (erb_case_node->children != NULL) {
214
- for (size_t index = 0; index < array_size(erb_case_node->children); index++) {
215
- herb_visit_node(array_get(erb_case_node->children, index), visitor, data);
214
+ for (size_t index = 0; index < hb_array_size(erb_case_node->children); index++) {
215
+ herb_visit_node(hb_array_get(erb_case_node->children, index), visitor, data);
216
216
  }
217
217
  }
218
218
 
219
219
  if (erb_case_node->conditions != NULL) {
220
- for (size_t index = 0; index < array_size(erb_case_node->conditions); index++) {
221
- herb_visit_node(array_get(erb_case_node->conditions, index), visitor, data);
220
+ for (size_t index = 0; index < hb_array_size(erb_case_node->conditions); index++) {
221
+ herb_visit_node(hb_array_get(erb_case_node->conditions, index), visitor, data);
222
222
  }
223
223
  }
224
224
 
@@ -236,14 +236,14 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
236
236
  const AST_ERB_CASE_MATCH_NODE_T* erb_case_match_node = ((const AST_ERB_CASE_MATCH_NODE_T *) node);
237
237
 
238
238
  if (erb_case_match_node->children != NULL) {
239
- for (size_t index = 0; index < array_size(erb_case_match_node->children); index++) {
240
- herb_visit_node(array_get(erb_case_match_node->children, index), visitor, data);
239
+ for (size_t index = 0; index < hb_array_size(erb_case_match_node->children); index++) {
240
+ herb_visit_node(hb_array_get(erb_case_match_node->children, index), visitor, data);
241
241
  }
242
242
  }
243
243
 
244
244
  if (erb_case_match_node->conditions != NULL) {
245
- for (size_t index = 0; index < array_size(erb_case_match_node->conditions); index++) {
246
- herb_visit_node(array_get(erb_case_match_node->conditions, index), visitor, data);
245
+ for (size_t index = 0; index < hb_array_size(erb_case_match_node->conditions); index++) {
246
+ herb_visit_node(hb_array_get(erb_case_match_node->conditions, index), visitor, data);
247
247
  }
248
248
  }
249
249
 
@@ -261,8 +261,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
261
261
  const AST_ERB_WHILE_NODE_T* erb_while_node = ((const AST_ERB_WHILE_NODE_T *) node);
262
262
 
263
263
  if (erb_while_node->statements != NULL) {
264
- for (size_t index = 0; index < array_size(erb_while_node->statements); index++) {
265
- herb_visit_node(array_get(erb_while_node->statements, index), visitor, data);
264
+ for (size_t index = 0; index < hb_array_size(erb_while_node->statements); index++) {
265
+ herb_visit_node(hb_array_get(erb_while_node->statements, index), visitor, data);
266
266
  }
267
267
  }
268
268
 
@@ -276,8 +276,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
276
276
  const AST_ERB_UNTIL_NODE_T* erb_until_node = ((const AST_ERB_UNTIL_NODE_T *) node);
277
277
 
278
278
  if (erb_until_node->statements != NULL) {
279
- for (size_t index = 0; index < array_size(erb_until_node->statements); index++) {
280
- herb_visit_node(array_get(erb_until_node->statements, index), visitor, data);
279
+ for (size_t index = 0; index < hb_array_size(erb_until_node->statements); index++) {
280
+ herb_visit_node(hb_array_get(erb_until_node->statements, index), visitor, data);
281
281
  }
282
282
  }
283
283
 
@@ -291,8 +291,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
291
291
  const AST_ERB_FOR_NODE_T* erb_for_node = ((const AST_ERB_FOR_NODE_T *) node);
292
292
 
293
293
  if (erb_for_node->statements != NULL) {
294
- for (size_t index = 0; index < array_size(erb_for_node->statements); index++) {
295
- herb_visit_node(array_get(erb_for_node->statements, index), visitor, data);
294
+ for (size_t index = 0; index < hb_array_size(erb_for_node->statements); index++) {
295
+ herb_visit_node(hb_array_get(erb_for_node->statements, index), visitor, data);
296
296
  }
297
297
  }
298
298
 
@@ -306,8 +306,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
306
306
  const AST_ERB_RESCUE_NODE_T* erb_rescue_node = ((const AST_ERB_RESCUE_NODE_T *) node);
307
307
 
308
308
  if (erb_rescue_node->statements != NULL) {
309
- for (size_t index = 0; index < array_size(erb_rescue_node->statements); index++) {
310
- herb_visit_node(array_get(erb_rescue_node->statements, index), visitor, data);
309
+ for (size_t index = 0; index < hb_array_size(erb_rescue_node->statements); index++) {
310
+ herb_visit_node(hb_array_get(erb_rescue_node->statements, index), visitor, data);
311
311
  }
312
312
  }
313
313
 
@@ -321,8 +321,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
321
321
  const AST_ERB_ENSURE_NODE_T* erb_ensure_node = ((const AST_ERB_ENSURE_NODE_T *) node);
322
322
 
323
323
  if (erb_ensure_node->statements != NULL) {
324
- for (size_t index = 0; index < array_size(erb_ensure_node->statements); index++) {
325
- herb_visit_node(array_get(erb_ensure_node->statements, index), visitor, data);
324
+ for (size_t index = 0; index < hb_array_size(erb_ensure_node->statements); index++) {
325
+ herb_visit_node(hb_array_get(erb_ensure_node->statements, index), visitor, data);
326
326
  }
327
327
  }
328
328
 
@@ -332,8 +332,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
332
332
  const AST_ERB_BEGIN_NODE_T* erb_begin_node = ((const AST_ERB_BEGIN_NODE_T *) node);
333
333
 
334
334
  if (erb_begin_node->statements != NULL) {
335
- for (size_t index = 0; index < array_size(erb_begin_node->statements); index++) {
336
- herb_visit_node(array_get(erb_begin_node->statements, index), visitor, data);
335
+ for (size_t index = 0; index < hb_array_size(erb_begin_node->statements); index++) {
336
+ herb_visit_node(hb_array_get(erb_begin_node->statements, index), visitor, data);
337
337
  }
338
338
  }
339
339
 
@@ -359,8 +359,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
359
359
  const AST_ERB_UNLESS_NODE_T* erb_unless_node = ((const AST_ERB_UNLESS_NODE_T *) node);
360
360
 
361
361
  if (erb_unless_node->statements != NULL) {
362
- for (size_t index = 0; index < array_size(erb_unless_node->statements); index++) {
363
- herb_visit_node(array_get(erb_unless_node->statements, index), visitor, data);
362
+ for (size_t index = 0; index < hb_array_size(erb_unless_node->statements); index++) {
363
+ herb_visit_node(hb_array_get(erb_unless_node->statements, index), visitor, data);
364
364
  }
365
365
  }
366
366
 
@@ -378,8 +378,8 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
378
378
  const AST_ERB_IN_NODE_T* erb_in_node = ((const AST_ERB_IN_NODE_T *) node);
379
379
 
380
380
  if (erb_in_node->statements != NULL) {
381
- for (size_t index = 0; index < array_size(erb_in_node->statements); index++) {
382
- herb_visit_node(array_get(erb_in_node->statements, index), visitor, data);
381
+ for (size_t index = 0; index < hb_array_size(erb_in_node->statements); index++) {
382
+ herb_visit_node(hb_array_get(erb_in_node->statements, index), visitor, data);
383
383
  }
384
384
  }
385
385
 
@@ -1,9 +1,9 @@
1
1
  #ifndef HERB_VISITOR_H
2
2
  #define HERB_VISITOR_H
3
3
 
4
- #include "array.h"
5
4
  #include "ast_node.h"
6
5
  #include "ast_nodes.h"
6
+ #include "util/hb_array.h"
7
7
 
8
8
  void herb_visit_node(const AST_NODE_T* node, bool (*visitor)(const AST_NODE_T*, void*), void* data);
9
9
  void herb_visit_child_nodes(const AST_NODE_T* node, bool (*visitor)(const AST_NODE_T* node, void* data), void* data);