prism 0.28.0 → 0.30.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 (73) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -1
  3. data/CONTRIBUTING.md +0 -4
  4. data/README.md +1 -0
  5. data/config.yml +95 -26
  6. data/docs/fuzzing.md +1 -1
  7. data/docs/ripper_translation.md +22 -0
  8. data/ext/prism/api_node.c +70 -52
  9. data/ext/prism/extconf.rb +27 -23
  10. data/ext/prism/extension.c +107 -372
  11. data/ext/prism/extension.h +1 -1
  12. data/include/prism/ast.h +170 -102
  13. data/include/prism/diagnostic.h +18 -3
  14. data/include/prism/node.h +0 -21
  15. data/include/prism/parser.h +23 -25
  16. data/include/prism/regexp.h +17 -8
  17. data/include/prism/static_literals.h +3 -2
  18. data/include/prism/util/pm_char.h +1 -2
  19. data/include/prism/util/pm_constant_pool.h +0 -8
  20. data/include/prism/util/pm_integer.h +16 -9
  21. data/include/prism/util/pm_string.h +0 -8
  22. data/include/prism/version.h +2 -2
  23. data/include/prism.h +0 -11
  24. data/lib/prism/compiler.rb +3 -0
  25. data/lib/prism/desugar_compiler.rb +4 -4
  26. data/lib/prism/dispatcher.rb +14 -0
  27. data/lib/prism/dot_visitor.rb +54 -35
  28. data/lib/prism/dsl.rb +23 -18
  29. data/lib/prism/ffi.rb +25 -4
  30. data/lib/prism/inspect_visitor.rb +26 -24
  31. data/lib/prism/mutation_compiler.rb +6 -1
  32. data/lib/prism/node.rb +314 -389
  33. data/lib/prism/node_ext.rb +175 -17
  34. data/lib/prism/parse_result/comments.rb +1 -8
  35. data/lib/prism/parse_result/newlines.rb +102 -12
  36. data/lib/prism/parse_result.rb +17 -0
  37. data/lib/prism/reflection.rb +11 -9
  38. data/lib/prism/serialize.rb +91 -68
  39. data/lib/prism/translation/parser/compiler.rb +288 -138
  40. data/lib/prism/translation/parser.rb +7 -2
  41. data/lib/prism/translation/ripper.rb +24 -22
  42. data/lib/prism/translation/ruby_parser.rb +32 -14
  43. data/lib/prism/visitor.rb +3 -0
  44. data/lib/prism.rb +0 -4
  45. data/prism.gemspec +2 -4
  46. data/rbi/prism/node.rbi +114 -57
  47. data/rbi/prism/node_ext.rbi +5 -0
  48. data/rbi/prism/parse_result.rbi +1 -1
  49. data/rbi/prism/visitor.rbi +3 -0
  50. data/rbi/prism.rbi +6 -0
  51. data/sig/prism/dsl.rbs +13 -10
  52. data/sig/prism/lex_compat.rbs +10 -0
  53. data/sig/prism/mutation_compiler.rbs +1 -0
  54. data/sig/prism/node.rbs +72 -48
  55. data/sig/prism/node_ext.rbs +4 -0
  56. data/sig/prism/visitor.rbs +1 -0
  57. data/sig/prism.rbs +21 -0
  58. data/src/diagnostic.c +56 -27
  59. data/src/node.c +432 -1690
  60. data/src/prettyprint.c +97 -54
  61. data/src/prism.c +1286 -1196
  62. data/src/regexp.c +133 -68
  63. data/src/serialize.c +22 -17
  64. data/src/static_literals.c +63 -84
  65. data/src/token_type.c +4 -4
  66. data/src/util/pm_constant_pool.c +0 -8
  67. data/src/util/pm_integer.c +39 -11
  68. data/src/util/pm_string.c +0 -12
  69. data/src/util/pm_strpbrk.c +32 -6
  70. metadata +3 -5
  71. data/include/prism/util/pm_string_list.h +0 -44
  72. data/lib/prism/debug.rb +0 -249
  73. data/src/util/pm_string_list.c +0 -28
data/include/prism/node.h CHANGED
@@ -56,27 +56,6 @@ void pm_node_list_free(pm_node_list_t *list);
56
56
  */
57
57
  PRISM_EXPORTED_FUNCTION void pm_node_destroy(pm_parser_t *parser, struct pm_node *node);
58
58
 
59
- /**
60
- * This struct stores the information gathered by the pm_node_memsize function.
61
- * It contains both the memory footprint and additionally metadata about the
62
- * shape of the tree.
63
- */
64
- typedef struct {
65
- /** The total memory footprint of the node and all of its children. */
66
- size_t memsize;
67
-
68
- /** The number of children the node has. */
69
- size_t node_count;
70
- } pm_memsize_t;
71
-
72
- /**
73
- * Calculates the memory footprint of a given node.
74
- *
75
- * @param node The node to calculate the memory footprint of.
76
- * @param memsize The memory footprint of the node and all of its children.
77
- */
78
- PRISM_EXPORTED_FUNCTION void pm_node_memsize(pm_node_t *node, pm_memsize_t *memsize);
79
-
80
59
  /**
81
60
  * Returns a string representation of the given node type.
82
61
  *
@@ -546,6 +546,17 @@ typedef struct pm_locals {
546
546
  pm_local_t *locals;
547
547
  } pm_locals_t;
548
548
 
549
+ /** The flags about scope parameters that can be set. */
550
+ typedef uint8_t pm_scope_parameters_t;
551
+ static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_NONE = 0x0;
552
+ static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_FORWARDING_POSITIONALS = 0x1;
553
+ static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_FORWARDING_KEYWORDS = 0x2;
554
+ static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_FORWARDING_BLOCK = 0x4;
555
+ static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_FORWARDING_ALL = 0x8;
556
+ static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_IMPLICIT_DISALLOWED = 0x10;
557
+ static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_NUMBERED_INNER = 0x20;
558
+ static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_NUMBERED_FOUND = 0x40;
559
+
549
560
  /**
550
561
  * This struct represents a node in a linked list of scopes. Some scopes can see
551
562
  * into their parent scopes, while others cannot.
@@ -557,10 +568,19 @@ typedef struct pm_scope {
557
568
  /** The IDs of the locals in the given scope. */
558
569
  pm_locals_t locals;
559
570
 
571
+ /**
572
+ * This is a list of the implicit parameters contained within the block.
573
+ * These will be processed after the block is parsed to determine the kind
574
+ * of parameters node that should be used and to check if any errors need to
575
+ * be added.
576
+ */
577
+ pm_node_list_t implicit_parameters;
578
+
560
579
  /**
561
580
  * This is a bitfield that indicates the parameters that are being used in
562
- * this scope. It is a combination of the PM_SCOPE_PARAMS_* constants. There
563
- * are three different kinds of parameters that can be used in a scope:
581
+ * this scope. It is a combination of the PM_SCOPE_PARAMETERS_* constants.
582
+ * There are three different kinds of parameters that can be used in a
583
+ * scope:
564
584
  *
565
585
  * - Ordinary parameters (e.g., def foo(bar); end)
566
586
  * - Numbered parameters (e.g., def foo; _1; end)
@@ -575,15 +595,7 @@ typedef struct pm_scope {
575
595
  * - def foo(&); end
576
596
  * - def foo(...); end
577
597
  */
578
- uint8_t parameters;
579
-
580
- /**
581
- * An integer indicating the number of numbered parameters on this scope.
582
- * This is necessary to determine if child blocks are allowed to use
583
- * numbered parameters, and to pass information to consumers of the AST
584
- * about how many numbered parameters exist.
585
- */
586
- int8_t numbered_parameters;
598
+ pm_scope_parameters_t parameters;
587
599
 
588
600
  /**
589
601
  * The current state of constant shareability for this scope. This is
@@ -598,20 +610,6 @@ typedef struct pm_scope {
598
610
  bool closed;
599
611
  } pm_scope_t;
600
612
 
601
- static const uint8_t PM_SCOPE_PARAMETERS_NONE = 0x0;
602
- static const uint8_t PM_SCOPE_PARAMETERS_ORDINARY = 0x1;
603
- static const uint8_t PM_SCOPE_PARAMETERS_NUMBERED = 0x2;
604
- static const uint8_t PM_SCOPE_PARAMETERS_IT = 0x4;
605
- static const uint8_t PM_SCOPE_PARAMETERS_TYPE_MASK = 0x7;
606
-
607
- static const uint8_t PM_SCOPE_PARAMETERS_FORWARDING_POSITIONALS = 0x8;
608
- static const uint8_t PM_SCOPE_PARAMETERS_FORWARDING_KEYWORDS = 0x10;
609
- static const uint8_t PM_SCOPE_PARAMETERS_FORWARDING_BLOCK = 0x20;
610
- static const uint8_t PM_SCOPE_PARAMETERS_FORWARDING_ALL = 0x40;
611
-
612
- static const int8_t PM_SCOPE_NUMBERED_PARAMETERS_DISALLOWED = -1;
613
- static const int8_t PM_SCOPE_NUMBERED_PARAMETERS_NONE = 0;
614
-
615
613
  /**
616
614
  * A struct that represents a stack of boolean values.
617
615
  */
@@ -10,7 +10,6 @@
10
10
  #include "prism/parser.h"
11
11
  #include "prism/encoding.h"
12
12
  #include "prism/util/pm_memchr.h"
13
- #include "prism/util/pm_string_list.h"
14
13
  #include "prism/util/pm_string.h"
15
14
 
16
15
  #include <stdbool.h>
@@ -18,16 +17,26 @@
18
17
  #include <string.h>
19
18
 
20
19
  /**
21
- * Parse a regular expression and extract the names of all of the named capture
22
- * groups.
20
+ * This callback is called when a named capture group is found.
21
+ */
22
+ typedef void (*pm_regexp_name_callback_t)(const pm_string_t *name, void *data);
23
+
24
+ /**
25
+ * This callback is called when a parse error is found.
26
+ */
27
+ typedef void (*pm_regexp_error_callback_t)(const uint8_t *start, const uint8_t *end, const char *message, void *data);
28
+
29
+ /**
30
+ * Parse a regular expression.
23
31
  *
32
+ * @param parser The parser that is currently being used.
24
33
  * @param source The source code to parse.
25
34
  * @param size The size of the source code.
26
- * @param named_captures The list to add the names of the named capture groups.
27
- * @param encoding_changed Whether or not the encoding changed from the default.
28
- * @param encoding The encoding of the source code.
29
- * @return Whether or not the parsing was successful.
35
+ * @param name_callback The optional callback to call when a named capture group is found.
36
+ * @param name_data The optional data to pass to the name callback.
37
+ * @param error_callback The callback to call when a parse error is found.
38
+ * @param error_data The data to pass to the error callback.
30
39
  */
31
- PRISM_EXPORTED_FUNCTION bool pm_regexp_named_capture_group_names(const uint8_t *source, size_t size, pm_string_list_t *named_captures, bool encoding_changed, const pm_encoding_t *encoding);
40
+ PRISM_EXPORTED_FUNCTION void pm_regexp_parse(pm_parser_t *parser, const uint8_t *source, size_t size, pm_regexp_name_callback_t name_callback, void *name_data, pm_regexp_error_callback_t error_callback, void *error_data);
32
41
 
33
42
  #endif
@@ -95,9 +95,10 @@ typedef struct {
95
95
  * @param start_line The line number that the parser starts on.
96
96
  * @param literals The set of static literals to add the node to.
97
97
  * @param node The node to add to the set.
98
+ * @param replace Whether to replace the previous node if one already exists.
98
99
  * @return A pointer to the node that is being overwritten, if there is one.
99
100
  */
100
- pm_node_t * pm_static_literals_add(const pm_newline_list_t *newline_list, int32_t start_line, pm_static_literals_t *literals, pm_node_t *node);
101
+ pm_node_t * pm_static_literals_add(const pm_newline_list_t *newline_list, int32_t start_line, pm_static_literals_t *literals, pm_node_t *node, bool replace);
101
102
 
102
103
  /**
103
104
  * Free the internal memory associated with the given static literals set.
@@ -115,6 +116,6 @@ void pm_static_literals_free(pm_static_literals_t *literals);
115
116
  * @param encoding_name The name of the encoding of the source being parsed.
116
117
  * @param node The node to create a string representation of.
117
118
  */
118
- PRISM_EXPORTED_FUNCTION void pm_static_literal_inspect(pm_buffer_t *buffer, const pm_newline_list_t *newline_list, int32_t start_line, const char *encoding_name, const pm_node_t *node);
119
+ void pm_static_literal_inspect(pm_buffer_t *buffer, const pm_newline_list_t *newline_list, int32_t start_line, const char *encoding_name, const pm_node_t *node);
119
120
 
120
121
  #endif
@@ -34,8 +34,7 @@ size_t pm_strspn_whitespace(const uint8_t *string, ptrdiff_t length);
34
34
  * @return The number of characters at the start of the string that are
35
35
  * whitespace.
36
36
  */
37
- size_t
38
- pm_strspn_whitespace_newlines(const uint8_t *string, ptrdiff_t length, pm_newline_list_t *newline_list);
37
+ size_t pm_strspn_whitespace_newlines(const uint8_t *string, ptrdiff_t length, pm_newline_list_t *newline_list);
39
38
 
40
39
  /**
41
40
  * Returns the number of characters at the start of the string that are inline
@@ -87,14 +87,6 @@ void pm_constant_id_list_insert(pm_constant_id_list_t *list, size_t index, pm_co
87
87
  */
88
88
  bool pm_constant_id_list_includes(pm_constant_id_list_t *list, pm_constant_id_t id);
89
89
 
90
- /**
91
- * Get the memory size of a list of constant ids.
92
- *
93
- * @param list The list to get the memory size of.
94
- * @return The memory size of the list.
95
- */
96
- size_t pm_constant_id_list_memsize(pm_constant_id_list_t *list);
97
-
98
90
  /**
99
91
  * Free the memory associated with a list of constant ids.
100
92
  *
@@ -48,6 +48,9 @@ typedef struct {
48
48
  * from the string itself.
49
49
  */
50
50
  typedef enum {
51
+ /** The default decimal base, with no prefix. Leading 0s will be ignored. */
52
+ PM_INTEGER_BASE_DEFAULT,
53
+
51
54
  /** The binary base, indicated by a 0b or 0B prefix. */
52
55
  PM_INTEGER_BASE_BINARY,
53
56
 
@@ -79,15 +82,7 @@ typedef enum {
79
82
  * @param start The start of the string.
80
83
  * @param end The end of the string.
81
84
  */
82
- PRISM_EXPORTED_FUNCTION void pm_integer_parse(pm_integer_t *integer, pm_integer_base_t base, const uint8_t *start, const uint8_t *end);
83
-
84
- /**
85
- * Return the memory size of the integer.
86
- *
87
- * @param integer The integer to get the memory size of.
88
- * @return The size of the memory associated with the integer.
89
- */
90
- size_t pm_integer_memsize(const pm_integer_t *integer);
85
+ void pm_integer_parse(pm_integer_t *integer, pm_integer_base_t base, const uint8_t *start, const uint8_t *end);
91
86
 
92
87
  /**
93
88
  * Compare two integers. This function returns -1 if the left integer is less
@@ -100,6 +95,18 @@ size_t pm_integer_memsize(const pm_integer_t *integer);
100
95
  */
101
96
  int pm_integer_compare(const pm_integer_t *left, const pm_integer_t *right);
102
97
 
98
+ /**
99
+ * Reduce a ratio of integers to its simplest form.
100
+ *
101
+ * If either the numerator or denominator do not fit into a 32-bit integer, then
102
+ * this function is a no-op. In the future, we may consider reducing even the
103
+ * larger numbers, but for now we're going to keep it simple.
104
+ *
105
+ * @param numerator The numerator of the ratio.
106
+ * @param denominator The denominator of the ratio.
107
+ */
108
+ void pm_integers_reduce(pm_integer_t *numerator, pm_integer_t *denominator);
109
+
103
110
  /**
104
111
  * Convert an integer to a decimal string.
105
112
  *
@@ -120,14 +120,6 @@ PRISM_EXPORTED_FUNCTION bool pm_string_mapped_init(pm_string_t *string, const ch
120
120
  */
121
121
  PRISM_EXPORTED_FUNCTION bool pm_string_file_init(pm_string_t *string, const char *filepath);
122
122
 
123
- /**
124
- * Returns the memory size associated with the string.
125
- *
126
- * @param string The string to get the memory size of.
127
- * @return The size of the memory associated with the string.
128
- */
129
- size_t pm_string_memsize(const pm_string_t *string);
130
-
131
123
  /**
132
124
  * Ensure the string is owned. If it is not, then reinitialize it as owned and
133
125
  * copy over the previous source.
@@ -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 28
17
+ #define PRISM_VERSION_MINOR 30
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 "0.28.0"
27
+ #define PRISM_VERSION "0.30.0"
28
28
 
29
29
  #endif
data/include/prism.h CHANGED
@@ -219,17 +219,6 @@ PRISM_EXPORTED_FUNCTION const char * pm_token_type_name(pm_token_type_t token_ty
219
219
  */
220
220
  const char * pm_token_type_human(pm_token_type_t token_type);
221
221
 
222
- /**
223
- * Format the errors on the parser into the given buffer.
224
- *
225
- * @param parser The parser to format the errors for.
226
- * @param error_list The list of errors to format.
227
- * @param buffer The buffer to format the errors into.
228
- * @param colorize Whether or not to colorize the errors with ANSI escape sequences.
229
- * @param inline_messages Whether or not to inline the messages with the source.
230
- */
231
- PRISM_EXPORTED_FUNCTION void pm_parser_errors_format(const pm_parser_t *parser, const pm_list_t *error_list, pm_buffer_t *buffer, bool colorize, bool inline_messages);
232
-
233
222
  // We optionally support dumping to JSON. For systems that don't want or need
234
223
  // this functionality, it can be turned off with the PRISM_EXCLUDE_JSON define.
235
224
  #ifndef PRISM_EXCLUDE_JSON
@@ -301,6 +301,9 @@ module Prism
301
301
  # Compile a InterpolatedXStringNode node
302
302
  alias visit_interpolated_x_string_node visit_child_nodes
303
303
 
304
+ # Compile a ItLocalVariableReadNode node
305
+ alias visit_it_local_variable_read_node visit_child_nodes
306
+
304
307
  # Compile a ItParametersNode node
305
308
  alias visit_it_parameters_node visit_child_nodes
306
309
 
@@ -73,7 +73,7 @@ module Prism
73
73
 
74
74
  # Desugar `x += y` to `x = x + y`
75
75
  def compile
76
- operator_loc = node.operator_loc.chop
76
+ binary_operator_loc = node.binary_operator_loc.chop
77
77
 
78
78
  write_class.new(
79
79
  source,
@@ -84,15 +84,15 @@ module Prism
84
84
  0,
85
85
  read_class.new(source, *arguments, node.name_loc),
86
86
  nil,
87
- operator_loc.slice.to_sym,
88
- operator_loc,
87
+ binary_operator_loc.slice.to_sym,
88
+ binary_operator_loc,
89
89
  nil,
90
90
  ArgumentsNode.new(source, 0, [node.value], node.value.location),
91
91
  nil,
92
92
  nil,
93
93
  node.location
94
94
  ),
95
- node.operator_loc.copy(start_offset: node.operator_loc.end_offset - 1, length: 1),
95
+ node.binary_operator_loc.copy(start_offset: node.binary_operator_loc.end_offset - 1, length: 1),
96
96
  node.location
97
97
  )
98
98
  end
@@ -762,6 +762,14 @@ module Prism
762
762
  listeners[:on_interpolated_x_string_node_leave]&.each { |listener| listener.on_interpolated_x_string_node_leave(node) }
763
763
  end
764
764
 
765
+ # Dispatch enter and leave events for ItLocalVariableReadNode nodes and continue
766
+ # walking the tree.
767
+ def visit_it_local_variable_read_node(node)
768
+ listeners[:on_it_local_variable_read_node_enter]&.each { |listener| listener.on_it_local_variable_read_node_enter(node) }
769
+ super
770
+ listeners[:on_it_local_variable_read_node_leave]&.each { |listener| listener.on_it_local_variable_read_node_leave(node) }
771
+ end
772
+
765
773
  # Dispatch enter and leave events for ItParametersNode nodes and continue
766
774
  # walking the tree.
767
775
  def visit_it_parameters_node(node)
@@ -1795,6 +1803,12 @@ module Prism
1795
1803
  listeners[:on_interpolated_x_string_node_leave]&.each { |listener| listener.on_interpolated_x_string_node_leave(node) }
1796
1804
  end
1797
1805
 
1806
+ # Dispatch enter and leave events for ItLocalVariableReadNode nodes.
1807
+ def visit_it_local_variable_read_node(node)
1808
+ listeners[:on_it_local_variable_read_node_enter]&.each { |listener| listener.on_it_local_variable_read_node_enter(node) }
1809
+ listeners[:on_it_local_variable_read_node_leave]&.each { |listener| listener.on_it_local_variable_read_node_leave(node) }
1810
+ end
1811
+
1798
1812
  # Dispatch enter and leave events for ItParametersNode nodes.
1799
1813
  def visit_it_parameters_node(node)
1800
1814
  listeners[:on_it_parameters_node_enter]&.each { |listener| listener.on_it_parameters_node_enter(node) }
@@ -765,11 +765,11 @@ module Prism
765
765
  # write_name
766
766
  table.field("write_name", node.write_name.inspect)
767
767
 
768
- # operator
769
- table.field("operator", node.operator.inspect)
768
+ # binary_operator
769
+ table.field("binary_operator", node.binary_operator.inspect)
770
770
 
771
- # operator_loc
772
- table.field("operator_loc", location_inspect(node.operator_loc))
771
+ # binary_operator_loc
772
+ table.field("binary_operator_loc", location_inspect(node.binary_operator_loc))
773
773
 
774
774
  # value
775
775
  table.field("value", port: true)
@@ -1060,15 +1060,15 @@ module Prism
1060
1060
  # name_loc
1061
1061
  table.field("name_loc", location_inspect(node.name_loc))
1062
1062
 
1063
- # operator_loc
1064
- table.field("operator_loc", location_inspect(node.operator_loc))
1063
+ # binary_operator_loc
1064
+ table.field("binary_operator_loc", location_inspect(node.binary_operator_loc))
1065
1065
 
1066
1066
  # value
1067
1067
  table.field("value", port: true)
1068
1068
  digraph.edge("#{id}:value -> #{node_id(node.value)};")
1069
1069
 
1070
- # operator
1071
- table.field("operator", node.operator.inspect)
1070
+ # binary_operator
1071
+ table.field("binary_operator", node.binary_operator.inspect)
1072
1072
 
1073
1073
  digraph.nodes << <<~DOT
1074
1074
  #{id} [
@@ -1205,15 +1205,15 @@ module Prism
1205
1205
  # name_loc
1206
1206
  table.field("name_loc", location_inspect(node.name_loc))
1207
1207
 
1208
- # operator_loc
1209
- table.field("operator_loc", location_inspect(node.operator_loc))
1208
+ # binary_operator_loc
1209
+ table.field("binary_operator_loc", location_inspect(node.binary_operator_loc))
1210
1210
 
1211
1211
  # value
1212
1212
  table.field("value", port: true)
1213
1213
  digraph.edge("#{id}:value -> #{node_id(node.value)};")
1214
1214
 
1215
- # operator
1216
- table.field("operator", node.operator.inspect)
1215
+ # binary_operator
1216
+ table.field("binary_operator", node.binary_operator.inspect)
1217
1217
 
1218
1218
  digraph.nodes << <<~DOT
1219
1219
  #{id} [
@@ -1314,15 +1314,15 @@ module Prism
1314
1314
  table.field("target", port: true)
1315
1315
  digraph.edge("#{id}:target -> #{node_id(node.target)};")
1316
1316
 
1317
- # operator_loc
1318
- table.field("operator_loc", location_inspect(node.operator_loc))
1317
+ # binary_operator_loc
1318
+ table.field("binary_operator_loc", location_inspect(node.binary_operator_loc))
1319
1319
 
1320
1320
  # value
1321
1321
  table.field("value", port: true)
1322
1322
  digraph.edge("#{id}:value -> #{node_id(node.value)};")
1323
1323
 
1324
- # operator
1325
- table.field("operator", node.operator.inspect)
1324
+ # binary_operator
1325
+ table.field("binary_operator", node.binary_operator.inspect)
1326
1326
 
1327
1327
  digraph.nodes << <<~DOT
1328
1328
  #{id} [
@@ -1916,15 +1916,15 @@ module Prism
1916
1916
  # name_loc
1917
1917
  table.field("name_loc", location_inspect(node.name_loc))
1918
1918
 
1919
- # operator_loc
1920
- table.field("operator_loc", location_inspect(node.operator_loc))
1919
+ # binary_operator_loc
1920
+ table.field("binary_operator_loc", location_inspect(node.binary_operator_loc))
1921
1921
 
1922
1922
  # value
1923
1923
  table.field("value", port: true)
1924
1924
  digraph.edge("#{id}:value -> #{node_id(node.value)};")
1925
1925
 
1926
- # operator
1927
- table.field("operator", node.operator.inspect)
1926
+ # binary_operator
1927
+ table.field("binary_operator", node.binary_operator.inspect)
1928
1928
 
1929
1929
  digraph.nodes << <<~DOT
1930
1930
  #{id} [
@@ -2322,11 +2322,11 @@ module Prism
2322
2322
  digraph.edge("#{id}:block -> #{node_id(block)};")
2323
2323
  end
2324
2324
 
2325
- # operator
2326
- table.field("operator", node.operator.inspect)
2325
+ # binary_operator
2326
+ table.field("binary_operator", node.binary_operator.inspect)
2327
2327
 
2328
- # operator_loc
2329
- table.field("operator_loc", location_inspect(node.operator_loc))
2328
+ # binary_operator_loc
2329
+ table.field("binary_operator_loc", location_inspect(node.binary_operator_loc))
2330
2330
 
2331
2331
  # value
2332
2332
  table.field("value", port: true)
@@ -2471,15 +2471,15 @@ module Prism
2471
2471
  # name_loc
2472
2472
  table.field("name_loc", location_inspect(node.name_loc))
2473
2473
 
2474
- # operator_loc
2475
- table.field("operator_loc", location_inspect(node.operator_loc))
2474
+ # binary_operator_loc
2475
+ table.field("binary_operator_loc", location_inspect(node.binary_operator_loc))
2476
2476
 
2477
2477
  # value
2478
2478
  table.field("value", port: true)
2479
2479
  digraph.edge("#{id}:value -> #{node_id(node.value)};")
2480
2480
 
2481
- # operator
2482
- table.field("operator", node.operator.inspect)
2481
+ # binary_operator
2482
+ table.field("binary_operator", node.binary_operator.inspect)
2483
2483
 
2484
2484
  digraph.nodes << <<~DOT
2485
2485
  #{id} [
@@ -2780,6 +2780,20 @@ module Prism
2780
2780
  super
2781
2781
  end
2782
2782
 
2783
+ # Visit a ItLocalVariableReadNode node.
2784
+ def visit_it_local_variable_read_node(node)
2785
+ table = Table.new("ItLocalVariableReadNode")
2786
+ id = node_id(node)
2787
+
2788
+ digraph.nodes << <<~DOT
2789
+ #{id} [
2790
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2791
+ ];
2792
+ DOT
2793
+
2794
+ super
2795
+ end
2796
+
2783
2797
  # Visit a ItParametersNode node.
2784
2798
  def visit_it_parameters_node(node)
2785
2799
  table = Table.new("ItParametersNode")
@@ -2928,8 +2942,8 @@ module Prism
2928
2942
  # name_loc
2929
2943
  table.field("name_loc", location_inspect(node.name_loc))
2930
2944
 
2931
- # operator_loc
2932
- table.field("operator_loc", location_inspect(node.operator_loc))
2945
+ # binary_operator_loc
2946
+ table.field("binary_operator_loc", location_inspect(node.binary_operator_loc))
2933
2947
 
2934
2948
  # value
2935
2949
  table.field("value", port: true)
@@ -2938,8 +2952,8 @@ module Prism
2938
2952
  # name
2939
2953
  table.field("name", node.name.inspect)
2940
2954
 
2941
- # operator
2942
- table.field("operator", node.operator.inspect)
2955
+ # binary_operator
2956
+ table.field("binary_operator", node.binary_operator.inspect)
2943
2957
 
2944
2958
  # depth
2945
2959
  table.field("depth", node.depth.inspect)
@@ -3779,9 +3793,14 @@ module Prism
3779
3793
  table = Table.new("RationalNode")
3780
3794
  id = node_id(node)
3781
3795
 
3782
- # numeric
3783
- table.field("numeric", port: true)
3784
- digraph.edge("#{id}:numeric -> #{node_id(node.numeric)};")
3796
+ # flags
3797
+ table.field("flags", integer_base_flags_inspect(node))
3798
+
3799
+ # numerator
3800
+ table.field("numerator", node.numerator.inspect)
3801
+
3802
+ # denominator
3803
+ table.field("denominator", node.denominator.inspect)
3785
3804
 
3786
3805
  digraph.nodes << <<~DOT
3787
3806
  #{id} [
data/lib/prism/dsl.rb CHANGED
@@ -143,8 +143,8 @@ module Prism
143
143
  end
144
144
 
145
145
  # Create a new CallOperatorWriteNode node
146
- def CallOperatorWriteNode(flags, receiver, call_operator_loc, message_loc, read_name, write_name, operator, operator_loc, value, source = nil, location = Location())
147
- CallOperatorWriteNode.new(source, flags, receiver, call_operator_loc, message_loc, read_name, write_name, operator, operator_loc, value, location)
146
+ def CallOperatorWriteNode(flags, receiver, call_operator_loc, message_loc, read_name, write_name, binary_operator, binary_operator_loc, value, source = nil, location = Location())
147
+ CallOperatorWriteNode.new(source, flags, receiver, call_operator_loc, message_loc, read_name, write_name, binary_operator, binary_operator_loc, value, location)
148
148
  end
149
149
 
150
150
  # Create a new CallOrWriteNode node
@@ -183,8 +183,8 @@ module Prism
183
183
  end
184
184
 
185
185
  # Create a new ClassVariableOperatorWriteNode node
186
- def ClassVariableOperatorWriteNode(name, name_loc, operator_loc, value, operator, source = nil, location = Location())
187
- ClassVariableOperatorWriteNode.new(source, name, name_loc, operator_loc, value, operator, location)
186
+ def ClassVariableOperatorWriteNode(name, name_loc, binary_operator_loc, value, binary_operator, source = nil, location = Location())
187
+ ClassVariableOperatorWriteNode.new(source, name, name_loc, binary_operator_loc, value, binary_operator, location)
188
188
  end
189
189
 
190
190
  # Create a new ClassVariableOrWriteNode node
@@ -213,8 +213,8 @@ module Prism
213
213
  end
214
214
 
215
215
  # Create a new ConstantOperatorWriteNode node
216
- def ConstantOperatorWriteNode(name, name_loc, operator_loc, value, operator, source = nil, location = Location())
217
- ConstantOperatorWriteNode.new(source, name, name_loc, operator_loc, value, operator, location)
216
+ def ConstantOperatorWriteNode(name, name_loc, binary_operator_loc, value, binary_operator, source = nil, location = Location())
217
+ ConstantOperatorWriteNode.new(source, name, name_loc, binary_operator_loc, value, binary_operator, location)
218
218
  end
219
219
 
220
220
  # Create a new ConstantOrWriteNode node
@@ -233,8 +233,8 @@ module Prism
233
233
  end
234
234
 
235
235
  # Create a new ConstantPathOperatorWriteNode node
236
- def ConstantPathOperatorWriteNode(target, operator_loc, value, operator, source = nil, location = Location())
237
- ConstantPathOperatorWriteNode.new(source, target, operator_loc, value, operator, location)
236
+ def ConstantPathOperatorWriteNode(target, binary_operator_loc, value, binary_operator, source = nil, location = Location())
237
+ ConstantPathOperatorWriteNode.new(source, target, binary_operator_loc, value, binary_operator, location)
238
238
  end
239
239
 
240
240
  # Create a new ConstantPathOrWriteNode node
@@ -343,8 +343,8 @@ module Prism
343
343
  end
344
344
 
345
345
  # Create a new GlobalVariableOperatorWriteNode node
346
- def GlobalVariableOperatorWriteNode(name, name_loc, operator_loc, value, operator, source = nil, location = Location())
347
- GlobalVariableOperatorWriteNode.new(source, name, name_loc, operator_loc, value, operator, location)
346
+ def GlobalVariableOperatorWriteNode(name, name_loc, binary_operator_loc, value, binary_operator, source = nil, location = Location())
347
+ GlobalVariableOperatorWriteNode.new(source, name, name_loc, binary_operator_loc, value, binary_operator, location)
348
348
  end
349
349
 
350
350
  # Create a new GlobalVariableOrWriteNode node
@@ -408,8 +408,8 @@ module Prism
408
408
  end
409
409
 
410
410
  # Create a new IndexOperatorWriteNode node
411
- def IndexOperatorWriteNode(flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, operator, operator_loc, value, source = nil, location = Location())
412
- IndexOperatorWriteNode.new(source, flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, operator, operator_loc, value, location)
411
+ def IndexOperatorWriteNode(flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, binary_operator, binary_operator_loc, value, source = nil, location = Location())
412
+ IndexOperatorWriteNode.new(source, flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, binary_operator, binary_operator_loc, value, location)
413
413
  end
414
414
 
415
415
  # Create a new IndexOrWriteNode node
@@ -428,8 +428,8 @@ module Prism
428
428
  end
429
429
 
430
430
  # Create a new InstanceVariableOperatorWriteNode node
431
- def InstanceVariableOperatorWriteNode(name, name_loc, operator_loc, value, operator, source = nil, location = Location())
432
- InstanceVariableOperatorWriteNode.new(source, name, name_loc, operator_loc, value, operator, location)
431
+ def InstanceVariableOperatorWriteNode(name, name_loc, binary_operator_loc, value, binary_operator, source = nil, location = Location())
432
+ InstanceVariableOperatorWriteNode.new(source, name, name_loc, binary_operator_loc, value, binary_operator, location)
433
433
  end
434
434
 
435
435
  # Create a new InstanceVariableOrWriteNode node
@@ -482,6 +482,11 @@ module Prism
482
482
  InterpolatedXStringNode.new(source, opening_loc, parts, closing_loc, location)
483
483
  end
484
484
 
485
+ # Create a new ItLocalVariableReadNode node
486
+ def ItLocalVariableReadNode(source = nil, location = Location())
487
+ ItLocalVariableReadNode.new(source, location)
488
+ end
489
+
485
490
  # Create a new ItParametersNode node
486
491
  def ItParametersNode(source = nil, location = Location())
487
492
  ItParametersNode.new(source, location)
@@ -508,8 +513,8 @@ module Prism
508
513
  end
509
514
 
510
515
  # Create a new LocalVariableOperatorWriteNode node
511
- def LocalVariableOperatorWriteNode(name_loc, operator_loc, value, name, operator, depth, source = nil, location = Location())
512
- LocalVariableOperatorWriteNode.new(source, name_loc, operator_loc, value, name, operator, depth, location)
516
+ def LocalVariableOperatorWriteNode(name_loc, binary_operator_loc, value, name, binary_operator, depth, source = nil, location = Location())
517
+ LocalVariableOperatorWriteNode.new(source, name_loc, binary_operator_loc, value, name, binary_operator, depth, location)
513
518
  end
514
519
 
515
520
  # Create a new LocalVariableOrWriteNode node
@@ -653,8 +658,8 @@ module Prism
653
658
  end
654
659
 
655
660
  # Create a new RationalNode node
656
- def RationalNode(numeric, source = nil, location = Location())
657
- RationalNode.new(source, numeric, location)
661
+ def RationalNode(flags, numerator, denominator, source = nil, location = Location())
662
+ RationalNode.new(source, flags, numerator, denominator, location)
658
663
  end
659
664
 
660
665
  # Create a new RedoNode node