herb 0.8.5 → 0.8.6
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/ext/herb/nodes.c +1 -1
- data/lib/herb/version.rb +1 -1
- data/src/analyze.c +13 -3
- data/src/include/util/hb_narray.h +29 -0
- data/src/include/version.h +1 -1
- data/src/util/hb_narray.c +75 -0
- 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 +3 -1
|
@@ -395,6 +395,12 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
|
|
|
395
395
|
pm_buffer_append_byte(buffer, 1);
|
|
396
396
|
pm_serialize_location(parser, &((pm_call_node_t *)node)->closing_loc, buffer);
|
|
397
397
|
}
|
|
398
|
+
if (((pm_call_node_t *)node)->equal_loc.start == NULL) {
|
|
399
|
+
pm_buffer_append_byte(buffer, 0);
|
|
400
|
+
} else {
|
|
401
|
+
pm_buffer_append_byte(buffer, 1);
|
|
402
|
+
pm_serialize_location(parser, &((pm_call_node_t *)node)->equal_loc, buffer);
|
|
403
|
+
}
|
|
398
404
|
if (((pm_call_node_t *)node)->block == NULL) {
|
|
399
405
|
pm_buffer_append_byte(buffer, 0);
|
|
400
406
|
} else {
|
|
@@ -2177,7 +2183,7 @@ pm_serialize_content(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer)
|
|
|
2177
2183
|
// buffer offset. We will add a leading 1 to indicate that this
|
|
2178
2184
|
// is a buffer offset.
|
|
2179
2185
|
uint32_t content_offset = pm_sizet_to_u32(buffer->length);
|
|
2180
|
-
uint32_t owned_mask =
|
|
2186
|
+
uint32_t owned_mask = 1U << 31;
|
|
2181
2187
|
|
|
2182
2188
|
assert(content_offset < owned_mask);
|
|
2183
2189
|
content_offset |= owned_mask;
|
|
@@ -48,6 +48,8 @@ pm_token_type_name(pm_token_type_t token_type) {
|
|
|
48
48
|
return "NEWLINE";
|
|
49
49
|
case PM_TOKEN_PARENTHESIS_RIGHT:
|
|
50
50
|
return "PARENTHESIS_RIGHT";
|
|
51
|
+
case PM_TOKEN_PIPE:
|
|
52
|
+
return "PIPE";
|
|
51
53
|
case PM_TOKEN_SEMICOLON:
|
|
52
54
|
return "SEMICOLON";
|
|
53
55
|
case PM_TOKEN_AMPERSAND:
|
|
@@ -280,8 +282,6 @@ pm_token_type_name(pm_token_type_t token_type) {
|
|
|
280
282
|
return "PERCENT_UPPER_I";
|
|
281
283
|
case PM_TOKEN_PERCENT_UPPER_W:
|
|
282
284
|
return "PERCENT_UPPER_W";
|
|
283
|
-
case PM_TOKEN_PIPE:
|
|
284
|
-
return "PIPE";
|
|
285
285
|
case PM_TOKEN_PIPE_EQUAL:
|
|
286
286
|
return "PIPE_EQUAL";
|
|
287
287
|
case PM_TOKEN_PIPE_PIPE:
|
|
@@ -264,7 +264,7 @@ pm_constant_pool_insert(pm_constant_pool_t *pool, const uint8_t *start, size_t l
|
|
|
264
264
|
// constant and replace it with the shared constant.
|
|
265
265
|
xfree((void *) constant->start);
|
|
266
266
|
constant->start = start;
|
|
267
|
-
bucket->type = (unsigned int) (
|
|
267
|
+
bucket->type = (unsigned int) (type & 0x3);
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
return bucket->id;
|
|
@@ -105,22 +105,6 @@ typedef uint16_t pm_node_flags_t;
|
|
|
105
105
|
static const pm_node_flags_t PM_NODE_FLAG_NEWLINE = 0x1;
|
|
106
106
|
static const pm_node_flags_t PM_NODE_FLAG_STATIC_LITERAL = 0x2;
|
|
107
107
|
|
|
108
|
-
/**
|
|
109
|
-
* Cast the type to an enum to allow the compiler to provide exhaustiveness
|
|
110
|
-
* checking.
|
|
111
|
-
*/
|
|
112
|
-
#define PM_NODE_TYPE(node) ((enum pm_node_type) (node)->type)
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Return true if the type of the given node matches the given type.
|
|
116
|
-
*/
|
|
117
|
-
#define PM_NODE_TYPE_P(node, type) (PM_NODE_TYPE(node) == (type))
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Return true if the given flag is set on the given node.
|
|
121
|
-
*/
|
|
122
|
-
#define PM_NODE_FLAG_P(node, flag) ((((pm_node_t *)(node))->flags & (flag)) != 0)
|
|
123
|
-
|
|
124
108
|
/**
|
|
125
109
|
* This is the base structure that represents a node in the syntax tree. It is
|
|
126
110
|
* embedded into every node type.
|
|
@@ -150,6 +134,32 @@ typedef struct pm_node {
|
|
|
150
134
|
*/
|
|
151
135
|
pm_location_t location;
|
|
152
136
|
} pm_node_t;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Cast the given node to the base pm_node_t type.
|
|
140
|
+
*/
|
|
141
|
+
#define PM_NODE_UPCAST(node_) ((pm_node_t *) (node_))
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Cast the type to an enum to allow the compiler to provide exhaustiveness
|
|
145
|
+
* checking.
|
|
146
|
+
*/
|
|
147
|
+
#define PM_NODE_TYPE(node_) ((enum pm_node_type) (node_)->type)
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Return true if the type of the given node matches the given type.
|
|
151
|
+
*/
|
|
152
|
+
#define PM_NODE_TYPE_P(node_, type_) (PM_NODE_TYPE(node_) == (type_))
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Return the flags associated with the given node.
|
|
156
|
+
*/
|
|
157
|
+
#define PM_NODE_FLAGS(node_) (PM_NODE_UPCAST(node_)->flags)
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Return true if the given flag is set on the given node.
|
|
161
|
+
*/
|
|
162
|
+
#define PM_NODE_FLAG_P(node_, flag_) ((PM_NODE_FLAGS(node_) & (flag_)) != 0)
|
|
153
163
|
<%- nodes.each do |node| -%>
|
|
154
164
|
|
|
155
165
|
/**
|
|
@@ -101,7 +101,7 @@ public class Loader {
|
|
|
101
101
|
expect((byte) 'M', "incorrect prism header");
|
|
102
102
|
|
|
103
103
|
expect((byte) 1, "prism major version does not match");
|
|
104
|
-
expect((byte)
|
|
104
|
+
expect((byte) 7, "prism minor version does not match");
|
|
105
105
|
expect((byte) 0, "prism patch version does not match");
|
|
106
106
|
|
|
107
107
|
expect((byte) 1, "Loader.java requires no location fields in the serialized output");
|
|
@@ -301,6 +301,7 @@ static const pm_diagnostic_data_t diagnostic_messages[PM_DIAGNOSTIC_ID_MAX] = {
|
|
|
301
301
|
[PM_ERR_PARAMETER_UNEXPECTED_NO_KW] = { "unexpected **nil; no keywords marker disallowed after keywords", PM_ERROR_LEVEL_SYNTAX },
|
|
302
302
|
[PM_ERR_PATTERN_ARRAY_MULTIPLE_RESTS] = { "unexpected multiple '*' rest patterns in an array pattern", PM_ERROR_LEVEL_SYNTAX },
|
|
303
303
|
[PM_ERR_PATTERN_CAPTURE_DUPLICATE] = { "duplicated variable name", PM_ERROR_LEVEL_SYNTAX },
|
|
304
|
+
[PM_ERR_PATTERN_CAPTURE_IN_ALTERNATIVE] = { "variable capture in alternative pattern", PM_ERROR_LEVEL_SYNTAX },
|
|
304
305
|
[PM_ERR_PATTERN_EXPRESSION_AFTER_BRACKET] = { "expected a pattern expression after the `[` operator", PM_ERROR_LEVEL_SYNTAX },
|
|
305
306
|
[PM_ERR_PATTERN_EXPRESSION_AFTER_COMMA] = { "expected a pattern expression after `,`", PM_ERROR_LEVEL_SYNTAX },
|
|
306
307
|
[PM_ERR_PATTERN_EXPRESSION_AFTER_HROCKET] = { "expected a pattern expression after `=>`", PM_ERROR_LEVEL_SYNTAX },
|
|
@@ -361,6 +362,7 @@ static const pm_diagnostic_data_t diagnostic_messages[PM_DIAGNOSTIC_ID_MAX] = {
|
|
|
361
362
|
[PM_ERR_UNEXPECTED_INDEX_KEYWORDS] = { "unexpected keyword arg given in index assignment; keywords are not allowed in index assignment expressions", PM_ERROR_LEVEL_SYNTAX },
|
|
362
363
|
[PM_ERR_UNEXPECTED_LABEL] = { "unexpected label", PM_ERROR_LEVEL_SYNTAX },
|
|
363
364
|
[PM_ERR_UNEXPECTED_MULTI_WRITE] = { "unexpected multiple assignment; multiple assignment is not allowed in this context", PM_ERROR_LEVEL_SYNTAX },
|
|
365
|
+
[PM_ERR_UNEXPECTED_PARAMETER_DEFAULT_VALUE] = { "unexpected %s; expected a default value for a parameter", PM_ERROR_LEVEL_SYNTAX },
|
|
364
366
|
[PM_ERR_UNEXPECTED_RANGE_OPERATOR] = { "unexpected range operator; .. and ... are non-associative and cannot be chained", PM_ERROR_LEVEL_SYNTAX },
|
|
365
367
|
[PM_ERR_UNEXPECTED_SAFE_NAVIGATION] = { "&. inside multiple assignment destination", PM_ERROR_LEVEL_SYNTAX },
|
|
366
368
|
[PM_ERR_UNEXPECTED_TOKEN_CLOSE_CONTEXT] = { "unexpected %s, assuming it is closing the parent %s", PM_ERROR_LEVEL_SYNTAX },
|
|
@@ -315,7 +315,7 @@ pm_serialize_content(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer)
|
|
|
315
315
|
// buffer offset. We will add a leading 1 to indicate that this
|
|
316
316
|
// is a buffer offset.
|
|
317
317
|
uint32_t content_offset = pm_sizet_to_u32(buffer->length);
|
|
318
|
-
uint32_t owned_mask =
|
|
318
|
+
uint32_t owned_mask = 1U << 31;
|
|
319
319
|
|
|
320
320
|
assert(content_offset < owned_mask);
|
|
321
321
|
content_offset |= owned_mask;
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: herb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marco Roth
|
|
@@ -145,6 +145,7 @@ files:
|
|
|
145
145
|
- src/include/util/hb_arena_debug.h
|
|
146
146
|
- src/include/util/hb_array.h
|
|
147
147
|
- src/include/util/hb_buffer.h
|
|
148
|
+
- src/include/util/hb_narray.h
|
|
148
149
|
- src/include/util/hb_string.h
|
|
149
150
|
- src/include/util/hb_system.h
|
|
150
151
|
- src/include/version.h
|
|
@@ -170,6 +171,7 @@ files:
|
|
|
170
171
|
- src/util/hb_arena_debug.c
|
|
171
172
|
- src/util/hb_array.c
|
|
172
173
|
- src/util/hb_buffer.c
|
|
174
|
+
- src/util/hb_narray.c
|
|
173
175
|
- src/util/hb_string.c
|
|
174
176
|
- src/util/hb_system.c
|
|
175
177
|
- src/visitor.c
|