@herb-tools/node 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.
Files changed (41) 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/analyze.c +13 -3
  6. package/extension/libherb/analyze_missing_end.c +1 -1
  7. package/extension/libherb/analyze_transform.c +1 -1
  8. package/extension/libherb/ast_nodes.c +1 -1
  9. package/extension/libherb/ast_nodes.h +1 -1
  10. package/extension/libherb/ast_pretty_print.c +1 -1
  11. package/extension/libherb/ast_pretty_print.h +1 -1
  12. package/extension/libherb/errors.c +1 -1
  13. package/extension/libherb/errors.h +1 -1
  14. package/extension/libherb/include/ast_nodes.h +1 -1
  15. package/extension/libherb/include/ast_pretty_print.h +1 -1
  16. package/extension/libherb/include/errors.h +1 -1
  17. package/extension/libherb/include/util/hb_narray.h +29 -0
  18. package/extension/libherb/include/version.h +1 -1
  19. package/extension/libherb/parser_match_tags.c +1 -1
  20. package/extension/libherb/util/hb_narray.c +75 -0
  21. package/extension/libherb/util/hb_narray.h +29 -0
  22. package/extension/libherb/version.h +1 -1
  23. package/extension/libherb/visitor.c +1 -1
  24. package/extension/nodes.cpp +1 -1
  25. package/extension/nodes.h +1 -1
  26. package/extension/prism/include/prism/ast.h +54 -20
  27. package/extension/prism/include/prism/diagnostic.h +2 -0
  28. package/extension/prism/include/prism/options.h +8 -2
  29. package/extension/prism/include/prism/parser.h +3 -0
  30. package/extension/prism/include/prism/version.h +2 -2
  31. package/extension/prism/include/prism.h +1 -1
  32. package/extension/prism/src/diagnostic.c +5 -1
  33. package/extension/prism/src/encoding.c +172 -67
  34. package/extension/prism/src/node.c +9 -0
  35. package/extension/prism/src/options.c +17 -7
  36. package/extension/prism/src/prettyprint.c +16 -0
  37. package/extension/prism/src/prism.c +1192 -1895
  38. package/extension/prism/src/serialize.c +7 -1
  39. package/extension/prism/src/token_type.c +2 -2
  40. package/extension/prism/src/util/pm_constant_pool.c +1 -1
  41. package/package.json +4 -4
package/binding.gyp CHANGED
@@ -40,6 +40,7 @@
40
40
  "./extension/libherb/util.c",
41
41
  "./extension/libherb/util/hb_arena.c",
42
42
  "./extension/libherb/util/hb_array.c",
43
+ "./extension/libherb/util/hb_narray.c",
43
44
  "./extension/libherb/util/hb_buffer.c",
44
45
  "./extension/libherb/util/hb_string.c",
45
46
  "./extension/libherb/util/hb_system.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.8.5";
9
+ var version = "0.8.6";
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.8.5/templates/javascript/packages/node/extension/error_helpers.cpp.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/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.8.5/templates/javascript/packages/node/extension/error_helpers.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/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
@@ -192,9 +192,19 @@ static bool find_earliest_control_keyword_walker(const pm_node_t* node, void* da
192
192
  case PM_CALL_NODE: {
193
193
  pm_call_node_t* call = (pm_call_node_t*) node;
194
194
 
195
- if (call->block != NULL) {
196
- current_type = CONTROL_TYPE_BLOCK;
197
- keyword_offset = (uint32_t) (node->location.start - context->source_start);
195
+ if (call->block != NULL && call->block->type == PM_BLOCK_NODE) {
196
+ pm_block_node_t* block_node = (pm_block_node_t*) call->block;
197
+ size_t opening_length = block_node->opening_loc.end - block_node->opening_loc.start;
198
+ bool has_do_opening =
199
+ opening_length == 2 && block_node->opening_loc.start[0] == 'd' && block_node->opening_loc.start[1] == 'o';
200
+ bool has_brace_opening = opening_length == 1 && block_node->opening_loc.start[0] == '{';
201
+ bool has_closing_location = block_node->closing_loc.start != NULL && block_node->closing_loc.end != NULL
202
+ && (block_node->closing_loc.end - block_node->closing_loc.start) > 0;
203
+
204
+ if (has_do_opening || (has_brace_opening && !has_closing_location)) {
205
+ current_type = CONTROL_TYPE_BLOCK;
206
+ keyword_offset = (uint32_t) (node->location.start - context->source_start);
207
+ }
198
208
  }
199
209
  break;
200
210
  }
@@ -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.8.5/templates/src/analyze_missing_end.c.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/templates/src/analyze_missing_end.c.erb
3
3
 
4
4
  #include "include/analyze_helpers.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.8.5/templates/src/analyze_transform.c.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/templates/src/analyze_transform.c.erb
3
3
 
4
4
  #include "include/analyze.h"
5
5
  #include "include/visitor.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.8.5/templates/src/ast_nodes.c.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/templates/src/ast_nodes.c.erb
3
3
 
4
4
  #include <stdio.h>
5
5
  #include <stdbool.h>
@@ -1,5 +1,5 @@
1
1
  // NOTE: This file is generated by the templates/template.rb script and should not
2
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.5/templates/src/include/ast_nodes.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/templates/src/include/ast_nodes.h.erb
3
3
 
4
4
  #ifndef HERB_AST_NODES_H
5
5
  #define HERB_AST_NODES_H
@@ -1,5 +1,5 @@
1
1
  // NOTE: This file is generated by the templates/template.rb script and should not
2
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.5/templates/src/ast_pretty_print.c.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/templates/src/ast_pretty_print.c.erb
3
3
 
4
4
  #include "include/analyze_helpers.h"
5
5
  #include "include/ast_node.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.8.5/templates/src/include/ast_pretty_print.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/templates/src/include/ast_pretty_print.h.erb
3
3
 
4
4
  #ifndef HERB_AST_PRETTY_PRINT_H
5
5
  #define HERB_AST_PRETTY_PRINT_H
@@ -1,5 +1,5 @@
1
1
  // NOTE: This file is generated by the templates/template.rb script and should not
2
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.5/templates/src/errors.c.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/templates/src/errors.c.erb
3
3
 
4
4
  #include "include/errors.h"
5
5
  #include "include/location.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.8.5/templates/src/include/errors.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/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.8.5/templates/src/include/ast_nodes.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/templates/src/include/ast_nodes.h.erb
3
3
 
4
4
  #ifndef HERB_AST_NODES_H
5
5
  #define HERB_AST_NODES_H
@@ -1,5 +1,5 @@
1
1
  // NOTE: This file is generated by the templates/template.rb script and should not
2
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.5/templates/src/include/ast_pretty_print.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/templates/src/include/ast_pretty_print.h.erb
3
3
 
4
4
  #ifndef HERB_AST_PRETTY_PRINT_H
5
5
  #define HERB_AST_PRETTY_PRINT_H
@@ -1,5 +1,5 @@
1
1
  // NOTE: This file is generated by the templates/template.rb script and should not
2
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.5/templates/src/include/errors.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/templates/src/include/errors.h.erb
3
3
 
4
4
  #ifndef HERB_ERRORS_H
5
5
  #define HERB_ERRORS_H
@@ -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
@@ -1,6 +1,6 @@
1
1
  #ifndef HERB_VERSION_H
2
2
  #define HERB_VERSION_H
3
3
 
4
- #define HERB_VERSION "0.8.5"
4
+ #define HERB_VERSION "0.8.6"
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.8.5/templates/src/parser_match_tags.c.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/templates/src/parser_match_tags.c.erb
3
3
 
4
4
  #include "include/parser.h"
5
5
  #include "include/ast_nodes.h"
@@ -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
+ }
@@ -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
@@ -1,6 +1,6 @@
1
1
  #ifndef HERB_VERSION_H
2
2
  #define HERB_VERSION_H
3
3
 
4
- #define HERB_VERSION "0.8.5"
4
+ #define HERB_VERSION "0.8.6"
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.8.5/templates/src/visitor.c.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/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.8.5/templates/javascript/packages/node/extension/nodes.cpp.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/templates/javascript/packages/node/extension/nodes.cpp.erb
3
3
 
4
4
  #include <node_api.h>
5
5
  #include "error_helpers.h"
package/extension/nodes.h CHANGED
@@ -1,5 +1,5 @@
1
1
  // NOTE: This file is generated by the templates/template.rb script and should not
2
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.5/templates/javascript/packages/node/extension/nodes.h.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.6/templates/javascript/packages/node/extension/nodes.h.erb
3
3
 
4
4
  #ifndef HERB_EXTENSION_NODES_H
5
5
  #define HERB_EXTENSION_NODES_H
@@ -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 3.5.x. */
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 = PM_OPTIONS_VERSION_CRUBY_3_5
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 6
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.6.0"
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/oracle/truffleruby),
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
  *
@@ -10,7 +10,7 @@
10
10
 
11
11
  #include "prism/diagnostic.h"
12
12
 
13
- #define PM_DIAGNOSTIC_ID_MAX 322
13
+ #define PM_DIAGNOSTIC_ID_MAX 324
14
14
 
15
15
  /** This struct holds the data for each diagnostic. */
16
16
  typedef struct {
@@ -311,6 +311,7 @@ static const pm_diagnostic_data_t diagnostic_messages[PM_DIAGNOSTIC_ID_MAX] = {
311
311
  [PM_ERR_PARAMETER_UNEXPECTED_NO_KW] = { "unexpected **nil; no keywords marker disallowed after keywords", PM_ERROR_LEVEL_SYNTAX },
312
312
  [PM_ERR_PATTERN_ARRAY_MULTIPLE_RESTS] = { "unexpected multiple '*' rest patterns in an array pattern", PM_ERROR_LEVEL_SYNTAX },
313
313
  [PM_ERR_PATTERN_CAPTURE_DUPLICATE] = { "duplicated variable name", PM_ERROR_LEVEL_SYNTAX },
314
+ [PM_ERR_PATTERN_CAPTURE_IN_ALTERNATIVE] = { "variable capture in alternative pattern", PM_ERROR_LEVEL_SYNTAX },
314
315
  [PM_ERR_PATTERN_EXPRESSION_AFTER_BRACKET] = { "expected a pattern expression after the `[` operator", PM_ERROR_LEVEL_SYNTAX },
315
316
  [PM_ERR_PATTERN_EXPRESSION_AFTER_COMMA] = { "expected a pattern expression after `,`", PM_ERROR_LEVEL_SYNTAX },
316
317
  [PM_ERR_PATTERN_EXPRESSION_AFTER_HROCKET] = { "expected a pattern expression after `=>`", PM_ERROR_LEVEL_SYNTAX },
@@ -371,6 +372,7 @@ static const pm_diagnostic_data_t diagnostic_messages[PM_DIAGNOSTIC_ID_MAX] = {
371
372
  [PM_ERR_UNEXPECTED_INDEX_KEYWORDS] = { "unexpected keyword arg given in index assignment; keywords are not allowed in index assignment expressions", PM_ERROR_LEVEL_SYNTAX },
372
373
  [PM_ERR_UNEXPECTED_LABEL] = { "unexpected label", PM_ERROR_LEVEL_SYNTAX },
373
374
  [PM_ERR_UNEXPECTED_MULTI_WRITE] = { "unexpected multiple assignment; multiple assignment is not allowed in this context", PM_ERROR_LEVEL_SYNTAX },
375
+ [PM_ERR_UNEXPECTED_PARAMETER_DEFAULT_VALUE] = { "unexpected %s; expected a default value for a parameter", PM_ERROR_LEVEL_SYNTAX },
374
376
  [PM_ERR_UNEXPECTED_RANGE_OPERATOR] = { "unexpected range operator; .. and ... are non-associative and cannot be chained", PM_ERROR_LEVEL_SYNTAX },
375
377
  [PM_ERR_UNEXPECTED_SAFE_NAVIGATION] = { "&. inside multiple assignment destination", PM_ERROR_LEVEL_SYNTAX },
376
378
  [PM_ERR_UNEXPECTED_TOKEN_CLOSE_CONTEXT] = { "unexpected %s, assuming it is closing the parent %s", PM_ERROR_LEVEL_SYNTAX },
@@ -642,6 +644,7 @@ pm_diagnostic_id_human(pm_diagnostic_id_t diag_id) {
642
644
  case PM_ERR_PARAMETER_WILD_LOOSE_COMMA: return "parameter_wild_loose_comma";
643
645
  case PM_ERR_PATTERN_ARRAY_MULTIPLE_RESTS: return "pattern_array_multiple_rests";
644
646
  case PM_ERR_PATTERN_CAPTURE_DUPLICATE: return "pattern_capture_duplicate";
647
+ case PM_ERR_PATTERN_CAPTURE_IN_ALTERNATIVE: return "pattern_capture_in_alternative";
645
648
  case PM_ERR_PATTERN_EXPRESSION_AFTER_BRACKET: return "pattern_expression_after_bracket";
646
649
  case PM_ERR_PATTERN_EXPRESSION_AFTER_COMMA: return "pattern_expression_after_comma";
647
650
  case PM_ERR_PATTERN_EXPRESSION_AFTER_HROCKET: return "pattern_expression_after_hrocket";
@@ -703,6 +706,7 @@ pm_diagnostic_id_human(pm_diagnostic_id_t diag_id) {
703
706
  case PM_ERR_UNEXPECTED_INDEX_KEYWORDS: return "unexpected_index_keywords";
704
707
  case PM_ERR_UNEXPECTED_LABEL: return "unexpected_label";
705
708
  case PM_ERR_UNEXPECTED_MULTI_WRITE: return "unexpected_multi_write";
709
+ case PM_ERR_UNEXPECTED_PARAMETER_DEFAULT_VALUE: return "unexpected_parameter_default_value";
706
710
  case PM_ERR_UNEXPECTED_RANGE_OPERATOR: return "unexpected_range_operator";
707
711
  case PM_ERR_UNEXPECTED_SAFE_NAVIGATION: return "unexpected_safe_navigation";
708
712
  case PM_ERR_UNEXPECTED_TOKEN_CLOSE_CONTEXT: return "unexpected_token_close_context";