herb 0.8.4-x86-linux-gnu → 0.8.6-x86-linux-gnu
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.
- checksums.yaml +4 -4
- data/config.yml +7 -0
- data/ext/herb/error_helpers.c +25 -0
- data/ext/herb/nodes.c +1 -1
- data/lib/herb/3.0/herb.so +0 -0
- data/lib/herb/3.1/herb.so +0 -0
- data/lib/herb/3.2/herb.so +0 -0
- data/lib/herb/3.3/herb.so +0 -0
- data/lib/herb/3.4/herb.so +0 -0
- data/lib/herb/4.0/herb.so +0 -0
- data/lib/herb/ast/helpers.rb +5 -0
- data/lib/herb/engine/compiler.rb +1 -0
- data/lib/herb/errors.rb +53 -44
- data/lib/herb/version.rb +1 -1
- data/sig/herb/ast/helpers.rbs +3 -0
- data/sig/herb/errors.rbs +10 -0
- data/sig/serialized_ast_errors.rbs +3 -0
- data/src/analyze.c +25 -4
- data/src/analyze_helpers.c +179 -84
- data/src/analyzed_ruby.c +26 -25
- data/src/ast_pretty_print.c +16 -15
- data/src/errors.c +37 -0
- data/src/extract.c +2 -1
- data/src/include/analyze_helpers.h +1 -0
- data/src/include/analyzed_ruby.h +19 -18
- data/src/include/errors.h +8 -0
- data/src/include/util/hb_narray.h +29 -0
- data/src/include/version.h +1 -1
- data/src/lexer.c +3 -3
- data/src/parser.c +4 -2
- data/src/parser_helpers.c +5 -5
- data/src/util/hb_narray.c +75 -0
- data/templates/lib/herb/errors.rb.erb +8 -5
- data/templates/src/ast_pretty_print.c.erb +16 -15
- data/vendor/prism/config.yml +28 -3
- data/vendor/prism/include/prism/ast.h +54 -20
- data/vendor/prism/include/prism/diagnostic.h +2 -0
- data/vendor/prism/include/prism/options.h +8 -2
- data/vendor/prism/include/prism/parser.h +3 -0
- data/vendor/prism/include/prism/version.h +2 -2
- data/vendor/prism/include/prism.h +1 -1
- data/vendor/prism/src/diagnostic.c +5 -1
- data/vendor/prism/src/encoding.c +172 -67
- data/vendor/prism/src/node.c +9 -0
- data/vendor/prism/src/options.c +17 -7
- data/vendor/prism/src/prettyprint.c +16 -0
- data/vendor/prism/src/prism.c +1192 -1895
- data/vendor/prism/src/serialize.c +7 -1
- data/vendor/prism/src/token_type.c +2 -2
- data/vendor/prism/src/util/pm_constant_pool.c +1 -1
- data/vendor/prism/templates/include/prism/ast.h.erb +26 -16
- data/vendor/prism/templates/java/org/prism/Loader.java.erb +1 -1
- data/vendor/prism/templates/javascript/src/deserialize.js.erb +1 -1
- data/vendor/prism/templates/lib/prism/serialize.rb.erb +1 -1
- data/vendor/prism/templates/src/diagnostic.c.erb +2 -0
- data/vendor/prism/templates/src/serialize.c.erb +1 -1
- metadata +5 -2
data/src/include/analyzed_ruby.h
CHANGED
|
@@ -11,24 +11,25 @@ typedef struct ANALYZED_RUBY_STRUCT {
|
|
|
11
11
|
pm_node_t* root;
|
|
12
12
|
bool valid;
|
|
13
13
|
bool parsed;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
14
|
+
int if_node_count;
|
|
15
|
+
int elsif_node_count;
|
|
16
|
+
int else_node_count;
|
|
17
|
+
int end_count;
|
|
18
|
+
int block_closing_count;
|
|
19
|
+
int block_node_count;
|
|
20
|
+
int case_node_count;
|
|
21
|
+
int case_match_node_count;
|
|
22
|
+
int when_node_count;
|
|
23
|
+
int in_node_count;
|
|
24
|
+
int for_node_count;
|
|
25
|
+
int while_node_count;
|
|
26
|
+
int until_node_count;
|
|
27
|
+
int begin_node_count;
|
|
28
|
+
int rescue_node_count;
|
|
29
|
+
int ensure_node_count;
|
|
30
|
+
int unless_node_count;
|
|
31
|
+
int yield_node_count;
|
|
32
|
+
int unclosed_control_flow_count;
|
|
32
33
|
} analyzed_ruby_T;
|
|
33
34
|
|
|
34
35
|
analyzed_ruby_T* init_analyzed_ruby(hb_string_T source);
|
data/src/include/errors.h
CHANGED
|
@@ -23,6 +23,7 @@ typedef enum {
|
|
|
23
23
|
RUBY_PARSE_ERROR,
|
|
24
24
|
ERB_CONTROL_FLOW_SCOPE_ERROR,
|
|
25
25
|
MISSINGERB_END_TAG_ERROR,
|
|
26
|
+
ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR,
|
|
26
27
|
} error_type_T;
|
|
27
28
|
|
|
28
29
|
typedef struct ERROR_STRUCT {
|
|
@@ -96,6 +97,11 @@ typedef struct {
|
|
|
96
97
|
const char* keyword;
|
|
97
98
|
} MISSINGERB_END_TAG_ERROR_T;
|
|
98
99
|
|
|
100
|
+
typedef struct {
|
|
101
|
+
ERROR_T base;
|
|
102
|
+
/* no additional fields */
|
|
103
|
+
} ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR_T;
|
|
104
|
+
|
|
99
105
|
UNEXPECTED_ERROR_T* unexpected_error_init(const char* description, const char* expected, const char* found, position_T start, position_T end);
|
|
100
106
|
void append_unexpected_error(const char* description, const char* expected, const char* found, position_T start, position_T end, hb_array_T* errors);
|
|
101
107
|
UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error_init(token_type_T expected_type, token_T* found, position_T start, position_T end);
|
|
@@ -118,6 +124,8 @@ ERB_CONTROL_FLOW_SCOPE_ERROR_T* erb_control_flow_scope_error_init(const char* ke
|
|
|
118
124
|
void append_erb_control_flow_scope_error(const char* keyword, position_T start, position_T end, hb_array_T* errors);
|
|
119
125
|
MISSINGERB_END_TAG_ERROR_T* missingerb_end_tag_error_init(const char* keyword, position_T start, position_T end);
|
|
120
126
|
void append_missingerb_end_tag_error(const char* keyword, position_T start, position_T end, hb_array_T* errors);
|
|
127
|
+
ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR_T* erb_multiple_blocks_in_tag_error_init(position_T start, position_T end);
|
|
128
|
+
void append_erb_multiple_blocks_in_tag_error(position_T start, position_T end, hb_array_T* errors);
|
|
121
129
|
|
|
122
130
|
void error_init(ERROR_T* error, error_type_T type, position_T start, position_T end);
|
|
123
131
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#ifndef HERB_NARRAY_H
|
|
2
|
+
#define HERB_NARRAY_H
|
|
3
|
+
|
|
4
|
+
#include <stdint.h>
|
|
5
|
+
#include <stdlib.h>
|
|
6
|
+
#include <stdbool.h>
|
|
7
|
+
|
|
8
|
+
typedef struct HB_NARRAY_STRUCT {
|
|
9
|
+
uint8_t* items;
|
|
10
|
+
size_t item_size;
|
|
11
|
+
size_t size;
|
|
12
|
+
size_t capacity;
|
|
13
|
+
} hb_narray_T;
|
|
14
|
+
|
|
15
|
+
void hb_narray_init(hb_narray_T* array, size_t item_size, size_t initial_capacity);
|
|
16
|
+
#define hb_narray_pointer_init(array, initial_capacity) (hb_narray_init(array, sizeof(void*), initial_capacity))
|
|
17
|
+
|
|
18
|
+
void* hb_narray_get(const hb_narray_T* array, size_t index);
|
|
19
|
+
void* hb_narray_first(hb_narray_T* array);
|
|
20
|
+
void* hb_narray_last(hb_narray_T* array);
|
|
21
|
+
|
|
22
|
+
void hb_narray_append(hb_narray_T* array, void* item);
|
|
23
|
+
void hb_narray_remove(hb_narray_T* array, size_t index);
|
|
24
|
+
void hb_narray_deinit(hb_narray_T* array);
|
|
25
|
+
|
|
26
|
+
#define hb_narray_push(array, item) (hb_narray_append(array, item))
|
|
27
|
+
bool hb_narray_pop(hb_narray_T* array, void* item);
|
|
28
|
+
|
|
29
|
+
#endif
|
data/src/include/version.h
CHANGED
data/src/lexer.c
CHANGED
|
@@ -185,8 +185,8 @@ static token_T* lexer_parse_identifier(lexer_T* lexer) {
|
|
|
185
185
|
// ===== ERB Parsing
|
|
186
186
|
|
|
187
187
|
static token_T* lexer_parse_erb_open(lexer_T* lexer) {
|
|
188
|
-
hb_string_T erb_patterns[] = { hb_string("<%=="), hb_string("<%%="), hb_string("<%="),
|
|
189
|
-
hb_string("<%-"), hb_string("<%%"), hb_string("<%") };
|
|
188
|
+
hb_string_T erb_patterns[] = { hb_string("<%=="), hb_string("<%%="), hb_string("<%="), hb_string("<%#"),
|
|
189
|
+
hb_string("<%-"), hb_string("<%%"), hb_string("<%graphql"), hb_string("<%") };
|
|
190
190
|
|
|
191
191
|
lexer->state = STATE_ERB_CONTENT;
|
|
192
192
|
|
|
@@ -278,7 +278,7 @@ token_T* lexer_next_token(lexer_T* lexer) {
|
|
|
278
278
|
return lexer_advance_with_next(lexer, strlen("<![CDATA["), TOKEN_CDATA_START);
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
if (
|
|
281
|
+
if (isalpha(lexer_peek(lexer, 1))) { return lexer_advance_current(lexer, TOKEN_HTML_TAG_START); }
|
|
282
282
|
|
|
283
283
|
if (lexer_peek_for_html_comment_start(lexer, 0)) {
|
|
284
284
|
return lexer_advance_with(lexer, hb_string("<!--"), TOKEN_HTML_COMMENT_START);
|
data/src/parser.c
CHANGED
|
@@ -1115,7 +1115,9 @@ static void parser_parse_in_data_state(parser_T* parser, hb_array_T* children, h
|
|
|
1115
1115
|
TOKEN_DASH,
|
|
1116
1116
|
TOKEN_EQUALS,
|
|
1117
1117
|
TOKEN_EXCLAMATION,
|
|
1118
|
+
TOKEN_HTML_TAG_END,
|
|
1118
1119
|
TOKEN_IDENTIFIER,
|
|
1120
|
+
TOKEN_LT,
|
|
1119
1121
|
TOKEN_NBSP,
|
|
1120
1122
|
TOKEN_NEWLINE,
|
|
1121
1123
|
TOKEN_PERCENT,
|
|
@@ -1149,11 +1151,11 @@ static size_t find_matching_close_tag(hb_array_T* nodes, size_t start_idx, hb_st
|
|
|
1149
1151
|
if (node->type == AST_HTML_OPEN_TAG_NODE) {
|
|
1150
1152
|
AST_HTML_OPEN_TAG_NODE_T* open = (AST_HTML_OPEN_TAG_NODE_T*) node;
|
|
1151
1153
|
|
|
1152
|
-
if (
|
|
1154
|
+
if (hb_string_equals_case_insensitive(hb_string(open->tag_name->value), tag_name)) { depth++; }
|
|
1153
1155
|
} else if (node->type == AST_HTML_CLOSE_TAG_NODE) {
|
|
1154
1156
|
AST_HTML_CLOSE_TAG_NODE_T* close = (AST_HTML_CLOSE_TAG_NODE_T*) node;
|
|
1155
1157
|
|
|
1156
|
-
if (
|
|
1158
|
+
if (hb_string_equals_case_insensitive(hb_string(close->tag_name->value), tag_name)) {
|
|
1157
1159
|
if (depth == 0) { return i; }
|
|
1158
1160
|
depth--;
|
|
1159
1161
|
}
|
data/src/parser_helpers.c
CHANGED
|
@@ -24,7 +24,7 @@ bool parser_check_matching_tag(const parser_T* parser, hb_string_T tag_name) {
|
|
|
24
24
|
token_T* top_token = hb_array_last(parser->open_tags_stack);
|
|
25
25
|
if (top_token == NULL || top_token->value == NULL) { return false; };
|
|
26
26
|
|
|
27
|
-
return
|
|
27
|
+
return hb_string_equals_case_insensitive(hb_string(top_token->value), tag_name);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
token_T* parser_pop_open_tag(const parser_T* parser) {
|
|
@@ -49,7 +49,7 @@ bool parser_in_svg_context(const parser_T* parser) {
|
|
|
49
49
|
|
|
50
50
|
if (tag && tag->value) {
|
|
51
51
|
hb_string_T tag_value_string = hb_string(tag->value);
|
|
52
|
-
if (
|
|
52
|
+
if (hb_string_equals_case_insensitive(tag_value_string, hb_string("svg"))) { return true; }
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -61,8 +61,8 @@ bool parser_in_svg_context(const parser_T* parser) {
|
|
|
61
61
|
foreign_content_type_T parser_get_foreign_content_type(hb_string_T tag_name) {
|
|
62
62
|
if (hb_string_is_empty(tag_name)) { return FOREIGN_CONTENT_UNKNOWN; }
|
|
63
63
|
|
|
64
|
-
if (
|
|
65
|
-
if (
|
|
64
|
+
if (hb_string_equals_case_insensitive(tag_name, hb_string("script"))) { return FOREIGN_CONTENT_SCRIPT; }
|
|
65
|
+
if (hb_string_equals_case_insensitive(tag_name, hb_string("style"))) { return FOREIGN_CONTENT_STYLE; }
|
|
66
66
|
|
|
67
67
|
return FOREIGN_CONTENT_UNKNOWN;
|
|
68
68
|
}
|
|
@@ -217,5 +217,5 @@ bool parser_is_expected_closing_tag_name(hb_string_T tag_name, foreign_content_t
|
|
|
217
217
|
|
|
218
218
|
if (hb_string_is_empty(tag_name) || hb_string_is_empty(expected_tag_name)) { return false; }
|
|
219
219
|
|
|
220
|
-
return
|
|
220
|
+
return hb_string_equals_case_insensitive(expected_tag_name, tag_name);
|
|
221
221
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#include "../include/util/hb_narray.h"
|
|
2
|
+
|
|
3
|
+
#include <assert.h>
|
|
4
|
+
#include <stdbool.h>
|
|
5
|
+
#include <string.h>
|
|
6
|
+
|
|
7
|
+
void hb_narray_init(hb_narray_T* array, size_t item_size, size_t initial_capacity) {
|
|
8
|
+
assert(initial_capacity != 0);
|
|
9
|
+
|
|
10
|
+
array->item_size = item_size;
|
|
11
|
+
array->capacity = initial_capacity;
|
|
12
|
+
array->size = 0;
|
|
13
|
+
array->items = malloc(array->capacity * array->item_size);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
void hb_narray_append(hb_narray_T* array, void* item) {
|
|
17
|
+
if (array->size + 1 > array->capacity) {
|
|
18
|
+
array->capacity *= 2;
|
|
19
|
+
void* new_buffer = realloc(array->items, array->capacity * array->item_size);
|
|
20
|
+
assert(new_buffer != NULL);
|
|
21
|
+
array->items = new_buffer;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
memcpy(array->items + (array->size * array->item_size), item, array->item_size);
|
|
25
|
+
array->size += 1;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static inline uint8_t* hb_narray_memory_position(const hb_narray_T* array, size_t index) {
|
|
29
|
+
return array->items + (array->item_size * index);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
void hb_narray_remove(hb_narray_T* array, size_t index) {
|
|
33
|
+
assert(index < array->size);
|
|
34
|
+
|
|
35
|
+
if (array->size - 1 > index) {
|
|
36
|
+
size_t elements_to_shift = (array->size - 1) - index;
|
|
37
|
+
size_t bytes_to_shift = array->item_size * elements_to_shift;
|
|
38
|
+
|
|
39
|
+
memcpy(hb_narray_memory_position(array, index), hb_narray_memory_position(array, index + 1), bytes_to_shift);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
array->size -= 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void* hb_narray_get(const hb_narray_T* array, size_t index) {
|
|
46
|
+
assert(index < array->size);
|
|
47
|
+
|
|
48
|
+
return hb_narray_memory_position(array, index);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
void* hb_narray_first(hb_narray_T* array) {
|
|
52
|
+
if (array->size == 0) { return NULL; }
|
|
53
|
+
|
|
54
|
+
return hb_narray_get(array, 0);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
void* hb_narray_last(hb_narray_T* array) {
|
|
58
|
+
if (array->size == 0) { return NULL; }
|
|
59
|
+
return hb_narray_get(array, array->size - 1);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
bool hb_narray_pop(hb_narray_T* array, void* item) {
|
|
63
|
+
if (array->size == 0) { return false; }
|
|
64
|
+
memcpy(item, hb_narray_last(array), array->item_size);
|
|
65
|
+
array->size -= 1;
|
|
66
|
+
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
void hb_narray_deinit(hb_narray_T* array) {
|
|
71
|
+
array->item_size = 0;
|
|
72
|
+
array->capacity = 0;
|
|
73
|
+
array->size = 0;
|
|
74
|
+
free(array->items);
|
|
75
|
+
}
|
|
@@ -46,6 +46,7 @@ module Herb
|
|
|
46
46
|
<%- errors.each do |error| -%>
|
|
47
47
|
class <%= error.name -%> < Error
|
|
48
48
|
include Colors
|
|
49
|
+
<%- if error.fields.any? -%>
|
|
49
50
|
|
|
50
51
|
<%- error.fields.each do |field| -%>
|
|
51
52
|
attr_reader :<%= field.name %> #: <%= field.ruby_type %>
|
|
@@ -54,25 +55,27 @@ module Herb
|
|
|
54
55
|
#: (<%= [*base_arguments.map(&:last), *error.fields.map(&:ruby_type)].join(", ") %>) -> void
|
|
55
56
|
def initialize(<%= [*base_arguments.map(&:first), *error.fields.map(&:name)].join(", ") %>)
|
|
56
57
|
super(<%= base_arguments.map(&:first).join(", ") %>)
|
|
57
|
-
|
|
58
58
|
<%- error.fields.each do |field| -%>
|
|
59
59
|
@<%= field.name %> = <%= field.name %>
|
|
60
60
|
<%- end -%>
|
|
61
61
|
end
|
|
62
|
+
<%- end -%>
|
|
62
63
|
|
|
63
64
|
#: () -> String
|
|
64
65
|
def inspect
|
|
65
66
|
tree_inspect.rstrip.gsub(/\s+$/, "")
|
|
66
67
|
end
|
|
68
|
+
<%- if error.fields.any? -%>
|
|
67
69
|
|
|
68
70
|
#: () -> serialized_<%= error.human %>
|
|
69
71
|
def to_hash
|
|
70
|
-
super.merge(
|
|
71
|
-
<%- error.fields.
|
|
72
|
-
<%= field.name %>: <%= field.name
|
|
72
|
+
super.merge(
|
|
73
|
+
<%- error.fields.each_with_index do |field, index| -%>
|
|
74
|
+
<%= field.name %>: <%= field.name %><%= index < error.fields.size - 1 ? "," : "" %>
|
|
73
75
|
<%- end -%>
|
|
74
|
-
|
|
76
|
+
) #: Herb::serialized_<%= error.human %>
|
|
75
77
|
end
|
|
78
|
+
<%- end -%>
|
|
76
79
|
|
|
77
80
|
#: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
|
|
78
81
|
def tree_inspect(indent: 0, depth: 0, depth_limit: 25)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#include "include/analyze_helpers.h"
|
|
1
2
|
#include "include/ast_node.h"
|
|
2
3
|
#include "include/ast_nodes.h"
|
|
3
4
|
#include "include/errors.h"
|
|
@@ -62,21 +63,21 @@ void ast_pretty_print_node(AST_NODE_T* node, const size_t indent, const size_t r
|
|
|
62
63
|
|
|
63
64
|
<%- when Herb::Template::AnalyzedRubyField -%>
|
|
64
65
|
if (<%= node.human %>-><%= field.name %>) {
|
|
65
|
-
pretty_print_boolean_property(hb_string("if_node"), <%= node.human %>-><%= field.name
|
|
66
|
-
pretty_print_boolean_property(hb_string("elsif_node"), <%= node.human %>-><%= field.name
|
|
67
|
-
pretty_print_boolean_property(hb_string("else_node"), <%= node.human %>-><%= field.name
|
|
68
|
-
pretty_print_boolean_property(hb_string("end"), <%= node.human %>-><%= field.name
|
|
69
|
-
pretty_print_boolean_property(hb_string("block_node"), <%= node.human %>-><%= field.name
|
|
70
|
-
pretty_print_boolean_property(hb_string("block_closing"), <%= node.human %>-><%= field.name
|
|
71
|
-
pretty_print_boolean_property(hb_string("case_node"), <%= node.human %>-><%= field.name
|
|
72
|
-
pretty_print_boolean_property(hb_string("when_node"), <%= node.human %>-><%= field.name
|
|
73
|
-
pretty_print_boolean_property(hb_string("for_node"), <%= node.human %>-><%= field.name
|
|
74
|
-
pretty_print_boolean_property(hb_string("while_node"), <%= node.human %>-><%= field.name
|
|
75
|
-
pretty_print_boolean_property(hb_string("until_node"), <%= node.human %>-><%= field.name
|
|
76
|
-
pretty_print_boolean_property(hb_string("begin_node"), <%= node.human %>-><%= field.name
|
|
77
|
-
pretty_print_boolean_property(hb_string("rescue_node"), <%= node.human %>-><%= field.name
|
|
78
|
-
pretty_print_boolean_property(hb_string("ensure_node"), <%= node.human %>-><%= field.name
|
|
79
|
-
pretty_print_boolean_property(hb_string("unless_node"), <%= node.human %>-><%= field.name
|
|
66
|
+
pretty_print_boolean_property(hb_string("if_node"), has_if_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
|
|
67
|
+
pretty_print_boolean_property(hb_string("elsif_node"), has_elsif_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
|
|
68
|
+
pretty_print_boolean_property(hb_string("else_node"), has_else_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
|
|
69
|
+
pretty_print_boolean_property(hb_string("end"), has_end(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
|
|
70
|
+
pretty_print_boolean_property(hb_string("block_node"), has_block_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
|
|
71
|
+
pretty_print_boolean_property(hb_string("block_closing"), has_block_closing(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
|
|
72
|
+
pretty_print_boolean_property(hb_string("case_node"), has_case_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
|
|
73
|
+
pretty_print_boolean_property(hb_string("when_node"), has_when_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
|
|
74
|
+
pretty_print_boolean_property(hb_string("for_node"), has_for_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
|
|
75
|
+
pretty_print_boolean_property(hb_string("while_node"), has_while_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
|
|
76
|
+
pretty_print_boolean_property(hb_string("until_node"), has_until_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
|
|
77
|
+
pretty_print_boolean_property(hb_string("begin_node"), has_begin_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
|
|
78
|
+
pretty_print_boolean_property(hb_string("rescue_node"), has_rescue_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
|
|
79
|
+
pretty_print_boolean_property(hb_string("ensure_node"), has_ensure_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
|
|
80
|
+
pretty_print_boolean_property(hb_string("unless_node"), has_unless_node(<%= node.human %>-><%= field.name %>), indent, relative_indent, false, buffer);
|
|
80
81
|
} else {
|
|
81
82
|
pretty_print_label(hb_string("<%= field.name %>"), indent, relative_indent, <%= last %>, buffer);
|
|
82
83
|
hb_buffer_append(buffer, " ∅\n");
|
data/vendor/prism/config.yml
CHANGED
|
@@ -219,6 +219,7 @@ errors:
|
|
|
219
219
|
- PARAMETER_WILD_LOOSE_COMMA
|
|
220
220
|
- PATTERN_ARRAY_MULTIPLE_RESTS
|
|
221
221
|
- PATTERN_CAPTURE_DUPLICATE
|
|
222
|
+
- PATTERN_CAPTURE_IN_ALTERNATIVE
|
|
222
223
|
- PATTERN_EXPRESSION_AFTER_BRACKET
|
|
223
224
|
- PATTERN_EXPRESSION_AFTER_COMMA
|
|
224
225
|
- PATTERN_EXPRESSION_AFTER_HROCKET
|
|
@@ -280,6 +281,7 @@ errors:
|
|
|
280
281
|
- UNEXPECTED_INDEX_KEYWORDS
|
|
281
282
|
- UNEXPECTED_LABEL
|
|
282
283
|
- UNEXPECTED_MULTI_WRITE
|
|
284
|
+
- UNEXPECTED_PARAMETER_DEFAULT_VALUE
|
|
283
285
|
- UNEXPECTED_RANGE_OPERATOR
|
|
284
286
|
- UNEXPECTED_SAFE_NAVIGATION
|
|
285
287
|
- UNEXPECTED_TOKEN_CLOSE_CONTEXT
|
|
@@ -356,6 +358,8 @@ tokens:
|
|
|
356
358
|
comment: "a newline character outside of other tokens"
|
|
357
359
|
- name: PARENTHESIS_RIGHT
|
|
358
360
|
comment: ")"
|
|
361
|
+
- name: PIPE
|
|
362
|
+
comment: "|"
|
|
359
363
|
- name: SEMICOLON
|
|
360
364
|
comment: ";"
|
|
361
365
|
# Tokens from here on are not used for lookup, and can be in any order.
|
|
@@ -589,8 +593,6 @@ tokens:
|
|
|
589
593
|
comment: "%I"
|
|
590
594
|
- name: PERCENT_UPPER_W
|
|
591
595
|
comment: "%W"
|
|
592
|
-
- name: PIPE
|
|
593
|
-
comment: "|"
|
|
594
596
|
- name: PIPE_EQUAL
|
|
595
597
|
comment: "|="
|
|
596
598
|
- name: PIPE_PIPE
|
|
@@ -1515,6 +1517,16 @@ nodes:
|
|
|
1515
1517
|
|
|
1516
1518
|
foo(bar)
|
|
1517
1519
|
^
|
|
1520
|
+
- name: equal_loc
|
|
1521
|
+
type: location?
|
|
1522
|
+
comment: |
|
|
1523
|
+
Represents the location of the equal sign, in the case that this is an attribute write.
|
|
1524
|
+
|
|
1525
|
+
foo.bar = value
|
|
1526
|
+
^
|
|
1527
|
+
|
|
1528
|
+
foo[bar] = value
|
|
1529
|
+
^
|
|
1518
1530
|
- name: block
|
|
1519
1531
|
type: node?
|
|
1520
1532
|
kind:
|
|
@@ -2616,11 +2628,18 @@ nodes:
|
|
|
2616
2628
|
- name: block
|
|
2617
2629
|
type: node?
|
|
2618
2630
|
kind: BlockNode
|
|
2631
|
+
comment: |
|
|
2632
|
+
All other arguments are forwarded as normal, except the original block is replaced with the new block.
|
|
2619
2633
|
comment: |
|
|
2620
|
-
Represents the use of the `super` keyword without parentheses or arguments.
|
|
2634
|
+
Represents the use of the `super` keyword without parentheses or arguments, but which might have a block.
|
|
2621
2635
|
|
|
2622
2636
|
super
|
|
2623
2637
|
^^^^^
|
|
2638
|
+
|
|
2639
|
+
super { 123 }
|
|
2640
|
+
^^^^^^^^^^^^^
|
|
2641
|
+
|
|
2642
|
+
If it has any other arguments, it would be a `SuperNode` instead.
|
|
2624
2643
|
- name: GlobalVariableAndWriteNode
|
|
2625
2644
|
fields:
|
|
2626
2645
|
- name: name
|
|
@@ -3287,6 +3306,9 @@ nodes:
|
|
|
3287
3306
|
- EmbeddedVariableNode
|
|
3288
3307
|
- InterpolatedStringNode # `"a" "#{b}"`
|
|
3289
3308
|
- on error: XStringNode # `<<`FOO` "bar"
|
|
3309
|
+
- on error: InterpolatedXStringNode
|
|
3310
|
+
- on error: SymbolNode
|
|
3311
|
+
- on error: InterpolatedSymbolNode
|
|
3290
3312
|
- name: closing_loc
|
|
3291
3313
|
type: location?
|
|
3292
3314
|
newline: parts
|
|
@@ -4496,6 +4518,7 @@ nodes:
|
|
|
4496
4518
|
- name: arguments
|
|
4497
4519
|
type: node?
|
|
4498
4520
|
kind: ArgumentsNode
|
|
4521
|
+
comment: "Can be only `nil` when there are empty parentheses, like `super()`."
|
|
4499
4522
|
- name: rparen_loc
|
|
4500
4523
|
type: location?
|
|
4501
4524
|
- name: block
|
|
@@ -4511,6 +4534,8 @@ nodes:
|
|
|
4511
4534
|
|
|
4512
4535
|
super foo, bar
|
|
4513
4536
|
^^^^^^^^^^^^^^
|
|
4537
|
+
|
|
4538
|
+
If no arguments are provided (except for a block), it would be a `ForwardingSuperNode` instead.
|
|
4514
4539
|
- name: SymbolNode
|
|
4515
4540
|
flags: SymbolFlags
|
|
4516
4541
|
fields:
|
|
@@ -76,6 +76,9 @@ typedef enum pm_token_type {
|
|
|
76
76
|
/** ) */
|
|
77
77
|
PM_TOKEN_PARENTHESIS_RIGHT,
|
|
78
78
|
|
|
79
|
+
/** | */
|
|
80
|
+
PM_TOKEN_PIPE,
|
|
81
|
+
|
|
79
82
|
/** ; */
|
|
80
83
|
PM_TOKEN_SEMICOLON,
|
|
81
84
|
|
|
@@ -424,9 +427,6 @@ typedef enum pm_token_type {
|
|
|
424
427
|
/** %W */
|
|
425
428
|
PM_TOKEN_PERCENT_UPPER_W,
|
|
426
429
|
|
|
427
|
-
/** | */
|
|
428
|
-
PM_TOKEN_PIPE,
|
|
429
|
-
|
|
430
430
|
/** |= */
|
|
431
431
|
PM_TOKEN_PIPE_EQUAL,
|
|
432
432
|
|
|
@@ -1050,22 +1050,6 @@ typedef uint16_t pm_node_flags_t;
|
|
|
1050
1050
|
static const pm_node_flags_t PM_NODE_FLAG_NEWLINE = 0x1;
|
|
1051
1051
|
static const pm_node_flags_t PM_NODE_FLAG_STATIC_LITERAL = 0x2;
|
|
1052
1052
|
|
|
1053
|
-
/**
|
|
1054
|
-
* Cast the type to an enum to allow the compiler to provide exhaustiveness
|
|
1055
|
-
* checking.
|
|
1056
|
-
*/
|
|
1057
|
-
#define PM_NODE_TYPE(node) ((enum pm_node_type) (node)->type)
|
|
1058
|
-
|
|
1059
|
-
/**
|
|
1060
|
-
* Return true if the type of the given node matches the given type.
|
|
1061
|
-
*/
|
|
1062
|
-
#define PM_NODE_TYPE_P(node, type) (PM_NODE_TYPE(node) == (type))
|
|
1063
|
-
|
|
1064
|
-
/**
|
|
1065
|
-
* Return true if the given flag is set on the given node.
|
|
1066
|
-
*/
|
|
1067
|
-
#define PM_NODE_FLAG_P(node, flag) ((((pm_node_t *)(node))->flags & (flag)) != 0)
|
|
1068
|
-
|
|
1069
1053
|
/**
|
|
1070
1054
|
* This is the base structure that represents a node in the syntax tree. It is
|
|
1071
1055
|
* embedded into every node type.
|
|
@@ -1096,6 +1080,32 @@ typedef struct pm_node {
|
|
|
1096
1080
|
pm_location_t location;
|
|
1097
1081
|
} pm_node_t;
|
|
1098
1082
|
|
|
1083
|
+
/**
|
|
1084
|
+
* Cast the given node to the base pm_node_t type.
|
|
1085
|
+
*/
|
|
1086
|
+
#define PM_NODE_UPCAST(node_) ((pm_node_t *) (node_))
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* Cast the type to an enum to allow the compiler to provide exhaustiveness
|
|
1090
|
+
* checking.
|
|
1091
|
+
*/
|
|
1092
|
+
#define PM_NODE_TYPE(node_) ((enum pm_node_type) (node_)->type)
|
|
1093
|
+
|
|
1094
|
+
/**
|
|
1095
|
+
* Return true if the type of the given node matches the given type.
|
|
1096
|
+
*/
|
|
1097
|
+
#define PM_NODE_TYPE_P(node_, type_) (PM_NODE_TYPE(node_) == (type_))
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
* Return the flags associated with the given node.
|
|
1101
|
+
*/
|
|
1102
|
+
#define PM_NODE_FLAGS(node_) (PM_NODE_UPCAST(node_)->flags)
|
|
1103
|
+
|
|
1104
|
+
/**
|
|
1105
|
+
* Return true if the given flag is set on the given node.
|
|
1106
|
+
*/
|
|
1107
|
+
#define PM_NODE_FLAG_P(node_, flag_) ((PM_NODE_FLAGS(node_) & (flag_)) != 0)
|
|
1108
|
+
|
|
1099
1109
|
/**
|
|
1100
1110
|
* AliasGlobalVariableNode
|
|
1101
1111
|
*
|
|
@@ -2214,6 +2224,19 @@ typedef struct pm_call_node {
|
|
|
2214
2224
|
*/
|
|
2215
2225
|
pm_location_t closing_loc;
|
|
2216
2226
|
|
|
2227
|
+
/**
|
|
2228
|
+
* CallNode#equal_loc
|
|
2229
|
+
*
|
|
2230
|
+
* Represents the location of the equal sign, in the case that this is an attribute write.
|
|
2231
|
+
*
|
|
2232
|
+
* foo.bar = value
|
|
2233
|
+
* ^
|
|
2234
|
+
*
|
|
2235
|
+
* foo[bar] = value
|
|
2236
|
+
* ^
|
|
2237
|
+
*/
|
|
2238
|
+
pm_location_t equal_loc;
|
|
2239
|
+
|
|
2217
2240
|
/**
|
|
2218
2241
|
* CallNode#block
|
|
2219
2242
|
*
|
|
@@ -4084,11 +4107,16 @@ typedef struct pm_forwarding_parameter_node {
|
|
|
4084
4107
|
/**
|
|
4085
4108
|
* ForwardingSuperNode
|
|
4086
4109
|
*
|
|
4087
|
-
* Represents the use of the `super` keyword without parentheses or arguments.
|
|
4110
|
+
* Represents the use of the `super` keyword without parentheses or arguments, but which might have a block.
|
|
4088
4111
|
*
|
|
4089
4112
|
* super
|
|
4090
4113
|
* ^^^^^
|
|
4091
4114
|
*
|
|
4115
|
+
* super { 123 }
|
|
4116
|
+
* ^^^^^^^^^^^^^
|
|
4117
|
+
*
|
|
4118
|
+
* If it has any other arguments, it would be a `SuperNode` instead.
|
|
4119
|
+
*
|
|
4092
4120
|
* Type: ::PM_FORWARDING_SUPER_NODE
|
|
4093
4121
|
*
|
|
4094
4122
|
* @extends pm_node_t
|
|
@@ -4100,6 +4128,8 @@ typedef struct pm_forwarding_super_node {
|
|
|
4100
4128
|
|
|
4101
4129
|
/**
|
|
4102
4130
|
* ForwardingSuperNode#block
|
|
4131
|
+
*
|
|
4132
|
+
* All other arguments are forwarded as normal, except the original block is replaced with the new block.
|
|
4103
4133
|
*/
|
|
4104
4134
|
struct pm_block_node *block;
|
|
4105
4135
|
} pm_forwarding_super_node_t;
|
|
@@ -7539,6 +7569,8 @@ typedef struct pm_string_node {
|
|
|
7539
7569
|
* super foo, bar
|
|
7540
7570
|
* ^^^^^^^^^^^^^^
|
|
7541
7571
|
*
|
|
7572
|
+
* If no arguments are provided (except for a block), it would be a `ForwardingSuperNode` instead.
|
|
7573
|
+
*
|
|
7542
7574
|
* Type: ::PM_SUPER_NODE
|
|
7543
7575
|
*
|
|
7544
7576
|
* @extends pm_node_t
|
|
@@ -7560,6 +7592,8 @@ typedef struct pm_super_node {
|
|
|
7560
7592
|
|
|
7561
7593
|
/**
|
|
7562
7594
|
* SuperNode#arguments
|
|
7595
|
+
*
|
|
7596
|
+
* Can be only `nil` when there are empty parentheses, like `super()`.
|
|
7563
7597
|
*/
|
|
7564
7598
|
struct pm_arguments_node *arguments;
|
|
7565
7599
|
|
|
@@ -250,6 +250,7 @@ typedef enum {
|
|
|
250
250
|
PM_ERR_PARAMETER_WILD_LOOSE_COMMA,
|
|
251
251
|
PM_ERR_PATTERN_ARRAY_MULTIPLE_RESTS,
|
|
252
252
|
PM_ERR_PATTERN_CAPTURE_DUPLICATE,
|
|
253
|
+
PM_ERR_PATTERN_CAPTURE_IN_ALTERNATIVE,
|
|
253
254
|
PM_ERR_PATTERN_EXPRESSION_AFTER_BRACKET,
|
|
254
255
|
PM_ERR_PATTERN_EXPRESSION_AFTER_COMMA,
|
|
255
256
|
PM_ERR_PATTERN_EXPRESSION_AFTER_HROCKET,
|
|
@@ -311,6 +312,7 @@ typedef enum {
|
|
|
311
312
|
PM_ERR_UNEXPECTED_INDEX_KEYWORDS,
|
|
312
313
|
PM_ERR_UNEXPECTED_LABEL,
|
|
313
314
|
PM_ERR_UNEXPECTED_MULTI_WRITE,
|
|
315
|
+
PM_ERR_UNEXPECTED_PARAMETER_DEFAULT_VALUE,
|
|
314
316
|
PM_ERR_UNEXPECTED_RANGE_OPERATOR,
|
|
315
317
|
PM_ERR_UNEXPECTED_SAFE_NAVIGATION,
|
|
316
318
|
PM_ERR_UNEXPECTED_TOKEN_CLOSE_CONTEXT,
|
|
@@ -91,11 +91,17 @@ typedef enum {
|
|
|
91
91
|
/** The vendored version of prism in CRuby 3.4.x. */
|
|
92
92
|
PM_OPTIONS_VERSION_CRUBY_3_4 = 2,
|
|
93
93
|
|
|
94
|
-
/** The vendored version of prism in CRuby
|
|
94
|
+
/** The vendored version of prism in CRuby 4.0.x. */
|
|
95
95
|
PM_OPTIONS_VERSION_CRUBY_3_5 = 3,
|
|
96
96
|
|
|
97
|
+
/** The vendored version of prism in CRuby 4.0.x. */
|
|
98
|
+
PM_OPTIONS_VERSION_CRUBY_4_0 = 3,
|
|
99
|
+
|
|
100
|
+
/** The vendored version of prism in CRuby 4.1.x. */
|
|
101
|
+
PM_OPTIONS_VERSION_CRUBY_4_1 = 4,
|
|
102
|
+
|
|
97
103
|
/** The current version of prism. */
|
|
98
|
-
PM_OPTIONS_VERSION_LATEST =
|
|
104
|
+
PM_OPTIONS_VERSION_LATEST = PM_OPTIONS_VERSION_CRUBY_4_1
|
|
99
105
|
} pm_options_version_t;
|
|
100
106
|
|
|
101
107
|
/**
|
|
@@ -299,6 +299,9 @@ typedef enum {
|
|
|
299
299
|
/** a rescue else statement within a do..end block */
|
|
300
300
|
PM_CONTEXT_BLOCK_ELSE,
|
|
301
301
|
|
|
302
|
+
/** expressions in block parameters `foo do |...| end ` */
|
|
303
|
+
PM_CONTEXT_BLOCK_PARAMETERS,
|
|
304
|
+
|
|
302
305
|
/** a rescue statement within a do..end block */
|
|
303
306
|
PM_CONTEXT_BLOCK_RESCUE,
|
|
304
307
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
/**
|
|
15
15
|
* The minor version of the Prism library as an int.
|
|
16
16
|
*/
|
|
17
|
-
#define PRISM_VERSION_MINOR
|
|
17
|
+
#define PRISM_VERSION_MINOR 7
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* The patch version of the Prism library as an int.
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
/**
|
|
25
25
|
* The version of the Prism library as a constant string.
|
|
26
26
|
*/
|
|
27
|
-
#define PRISM_VERSION "1.
|
|
27
|
+
#define PRISM_VERSION "1.7.0"
|
|
28
28
|
|
|
29
29
|
#endif
|
|
@@ -314,7 +314,7 @@ PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_method_name(const uint
|
|
|
314
314
|
* dependencies. It is currently being integrated into
|
|
315
315
|
* [CRuby](https://github.com/ruby/ruby),
|
|
316
316
|
* [JRuby](https://github.com/jruby/jruby),
|
|
317
|
-
* [TruffleRuby](https://github.com/
|
|
317
|
+
* [TruffleRuby](https://github.com/truffleruby/truffleruby),
|
|
318
318
|
* [Sorbet](https://github.com/sorbet/sorbet), and
|
|
319
319
|
* [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree).
|
|
320
320
|
*
|