prism 0.24.0 → 0.26.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/BSDmakefile +58 -0
  3. data/CHANGELOG.md +69 -1
  4. data/Makefile +22 -16
  5. data/README.md +45 -6
  6. data/config.yml +510 -4
  7. data/docs/build_system.md +31 -0
  8. data/docs/configuration.md +3 -0
  9. data/docs/cruby_compilation.md +1 -1
  10. data/docs/parser_translation.md +14 -9
  11. data/docs/releasing.md +7 -9
  12. data/docs/ripper_translation.md +50 -0
  13. data/docs/ruby_api.md +1 -0
  14. data/docs/serialization.md +26 -5
  15. data/ext/prism/api_node.c +911 -815
  16. data/ext/prism/api_pack.c +9 -0
  17. data/ext/prism/extconf.rb +34 -13
  18. data/ext/prism/extension.c +341 -68
  19. data/ext/prism/extension.h +5 -4
  20. data/include/prism/ast.h +213 -64
  21. data/include/prism/defines.h +106 -2
  22. data/include/prism/diagnostic.h +146 -72
  23. data/include/prism/encoding.h +22 -4
  24. data/include/prism/node.h +93 -0
  25. data/include/prism/options.h +82 -7
  26. data/include/prism/pack.h +11 -0
  27. data/include/prism/parser.h +203 -54
  28. data/include/prism/prettyprint.h +8 -0
  29. data/include/prism/static_literals.h +118 -0
  30. data/include/prism/util/pm_buffer.h +65 -2
  31. data/include/prism/util/pm_constant_pool.h +18 -1
  32. data/include/prism/util/pm_integer.h +119 -0
  33. data/include/prism/util/pm_list.h +1 -1
  34. data/include/prism/util/pm_newline_list.h +8 -0
  35. data/include/prism/util/pm_string.h +26 -2
  36. data/include/prism/version.h +2 -2
  37. data/include/prism.h +59 -1
  38. data/lib/prism/compiler.rb +8 -1
  39. data/lib/prism/debug.rb +46 -3
  40. data/lib/prism/desugar_compiler.rb +4 -2
  41. data/lib/prism/dispatcher.rb +29 -0
  42. data/lib/prism/dot_visitor.rb +87 -16
  43. data/lib/prism/dsl.rb +24 -12
  44. data/lib/prism/ffi.rb +77 -12
  45. data/lib/prism/lex_compat.rb +17 -15
  46. data/lib/prism/mutation_compiler.rb +11 -0
  47. data/lib/prism/node.rb +2112 -2499
  48. data/lib/prism/node_ext.rb +77 -29
  49. data/lib/prism/pack.rb +4 -0
  50. data/lib/prism/parse_result/comments.rb +34 -17
  51. data/lib/prism/parse_result/newlines.rb +3 -1
  52. data/lib/prism/parse_result.rb +83 -32
  53. data/lib/prism/pattern.rb +16 -4
  54. data/lib/prism/polyfill/string.rb +12 -0
  55. data/lib/prism/reflection.rb +421 -0
  56. data/lib/prism/serialize.rb +450 -102
  57. data/lib/prism/translation/parser/compiler.rb +189 -50
  58. data/lib/prism/translation/parser/lexer.rb +103 -22
  59. data/lib/prism/translation/parser/rubocop.rb +41 -13
  60. data/lib/prism/translation/parser.rb +119 -7
  61. data/lib/prism/translation/parser33.rb +1 -1
  62. data/lib/prism/translation/parser34.rb +1 -1
  63. data/lib/prism/translation/ripper/sexp.rb +125 -0
  64. data/lib/prism/translation/ripper/shim.rb +5 -0
  65. data/lib/prism/translation/ripper.rb +3212 -462
  66. data/lib/prism/translation/ruby_parser.rb +35 -18
  67. data/lib/prism/translation.rb +3 -1
  68. data/lib/prism/visitor.rb +10 -0
  69. data/lib/prism.rb +9 -18
  70. data/prism.gemspec +39 -6
  71. data/rbi/prism/compiler.rbi +14 -0
  72. data/rbi/prism/desugar_compiler.rbi +5 -0
  73. data/rbi/prism/mutation_compiler.rbi +5 -0
  74. data/rbi/prism/node.rbi +8674 -0
  75. data/rbi/prism/node_ext.rbi +102 -0
  76. data/rbi/prism/parse_result.rbi +307 -0
  77. data/rbi/prism/reflection.rbi +64 -0
  78. data/rbi/prism/translation/parser/compiler.rbi +13 -0
  79. data/rbi/prism/translation/parser.rbi +11 -0
  80. data/rbi/prism/translation/parser33.rbi +6 -0
  81. data/rbi/prism/translation/parser34.rbi +6 -0
  82. data/rbi/prism/translation/ripper/ripper_compiler.rbi +5 -0
  83. data/rbi/prism/translation/ripper.rbi +25 -0
  84. data/rbi/prism/translation/ruby_parser.rbi +11 -0
  85. data/rbi/prism/visitor.rbi +470 -0
  86. data/rbi/prism.rbi +38 -7748
  87. data/sig/prism/compiler.rbs +9 -0
  88. data/sig/prism/dispatcher.rbs +16 -0
  89. data/sig/prism/dot_visitor.rbs +6 -0
  90. data/sig/prism/dsl.rbs +462 -0
  91. data/sig/prism/mutation_compiler.rbs +158 -0
  92. data/sig/prism/node.rbs +3538 -0
  93. data/sig/prism/node_ext.rbs +78 -0
  94. data/sig/prism/pack.rbs +43 -0
  95. data/sig/prism/parse_result.rbs +128 -0
  96. data/sig/prism/pattern.rbs +13 -0
  97. data/sig/prism/reflection.rbs +56 -0
  98. data/sig/prism/serialize.rbs +7 -0
  99. data/sig/prism/visitor.rbs +168 -0
  100. data/sig/prism.rbs +188 -4767
  101. data/src/diagnostic.c +597 -230
  102. data/src/encoding.c +211 -108
  103. data/src/node.c +7526 -447
  104. data/src/options.c +66 -31
  105. data/src/pack.c +33 -17
  106. data/src/prettyprint.c +1294 -1385
  107. data/src/prism.c +4015 -1149
  108. data/src/regexp.c +17 -2
  109. data/src/serialize.c +47 -28
  110. data/src/static_literals.c +552 -0
  111. data/src/token_type.c +4 -3
  112. data/src/util/pm_buffer.c +147 -20
  113. data/src/util/pm_char.c +4 -4
  114. data/src/util/pm_constant_pool.c +35 -11
  115. data/src/util/pm_integer.c +635 -0
  116. data/src/util/pm_list.c +1 -1
  117. data/src/util/pm_newline_list.c +14 -5
  118. data/src/util/pm_string.c +134 -5
  119. data/src/util/pm_string_list.c +2 -2
  120. metadata +41 -8
  121. data/docs/ripper.md +0 -36
  122. data/include/prism/util/pm_state_stack.h +0 -42
  123. data/rbi/prism_static.rbi +0 -207
  124. data/sig/prism_static.rbs +0 -201
  125. data/src/util/pm_state_stack.c +0 -25
data/src/util/pm_string.c CHANGED
@@ -58,7 +58,7 @@ pm_string_constant_init(pm_string_t *string, const char *source, size_t length)
58
58
  * `MapViewOfFile`, on POSIX systems that have access to `mmap` we'll use
59
59
  * `mmap`, and on other POSIX systems we'll use `read`.
60
60
  */
61
- bool
61
+ PRISM_EXPORTED_FUNCTION bool
62
62
  pm_string_mapped_init(pm_string_t *string, const char *filepath) {
63
63
  #ifdef _WIN32
64
64
  // Open the file for reading.
@@ -102,7 +102,7 @@ pm_string_mapped_init(pm_string_t *string, const char *filepath) {
102
102
 
103
103
  *string = (pm_string_t) { .type = PM_STRING_MAPPED, .source = source, .length = (size_t) file_size };
104
104
  return true;
105
- #else
105
+ #elif defined(_POSIX_MAPPED_FILES)
106
106
  // Open the file for reading
107
107
  int fd = open(filepath, O_RDONLY);
108
108
  if (fd == -1) {
@@ -135,6 +135,113 @@ pm_string_mapped_init(pm_string_t *string, const char *filepath) {
135
135
  close(fd);
136
136
  *string = (pm_string_t) { .type = PM_STRING_MAPPED, .source = source, .length = size };
137
137
  return true;
138
+ #else
139
+ (void) string;
140
+ (void) filepath;
141
+ perror("pm_string_mapped_init is not implemented for this platform");
142
+ return false;
143
+ #endif
144
+ }
145
+
146
+ /**
147
+ * Read the file indicated by the filepath parameter into source and load its
148
+ * contents and size into the given `pm_string_t`. The given `pm_string_t`
149
+ * should be freed using `pm_string_free` when it is no longer used.
150
+ */
151
+ PRISM_EXPORTED_FUNCTION bool
152
+ pm_string_file_init(pm_string_t *string, const char *filepath) {
153
+ #ifdef _WIN32
154
+ // Open the file for reading.
155
+ HANDLE file = CreateFile(filepath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
156
+
157
+ if (file == INVALID_HANDLE_VALUE) {
158
+ return false;
159
+ }
160
+
161
+ // Get the file size.
162
+ DWORD file_size = GetFileSize(file, NULL);
163
+ if (file_size == INVALID_FILE_SIZE) {
164
+ CloseHandle(file);
165
+ return false;
166
+ }
167
+
168
+ // If the file is empty, then we don't need to do anything else, we'll set
169
+ // the source to a constant empty string and return.
170
+ if (file_size == 0) {
171
+ CloseHandle(file);
172
+ const uint8_t source[] = "";
173
+ *string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = source, .length = 0 };
174
+ return true;
175
+ }
176
+
177
+ // Create a buffer to read the file into.
178
+ uint8_t *source = xmalloc(file_size);
179
+ if (source == NULL) {
180
+ CloseHandle(file);
181
+ return false;
182
+ }
183
+
184
+ // Read the contents of the file
185
+ DWORD bytes_read;
186
+ if (!ReadFile(file, source, file_size, &bytes_read, NULL)) {
187
+ CloseHandle(file);
188
+ return false;
189
+ }
190
+
191
+ // Check the number of bytes read
192
+ if (bytes_read != file_size) {
193
+ xfree(source);
194
+ CloseHandle(file);
195
+ return false;
196
+ }
197
+
198
+ CloseHandle(file);
199
+ *string = (pm_string_t) { .type = PM_STRING_OWNED, .source = source, .length = (size_t) file_size };
200
+ return true;
201
+ #elif defined(_POSIX_MAPPED_FILES)
202
+ FILE *file = fopen(filepath, "rb");
203
+ if (file == NULL) {
204
+ return false;
205
+ }
206
+
207
+ fseek(file, 0, SEEK_END);
208
+ long file_size = ftell(file);
209
+
210
+ if (file_size == -1) {
211
+ fclose(file);
212
+ return false;
213
+ }
214
+
215
+ if (file_size == 0) {
216
+ fclose(file);
217
+ const uint8_t source[] = "";
218
+ *string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = source, .length = 0 };
219
+ return true;
220
+ }
221
+
222
+ size_t length = (size_t) file_size;
223
+ uint8_t *source = xmalloc(length);
224
+ if (source == NULL) {
225
+ fclose(file);
226
+ return false;
227
+ }
228
+
229
+ fseek(file, 0, SEEK_SET);
230
+ size_t bytes_read = fread(source, length, 1, file);
231
+ fclose(file);
232
+
233
+ if (bytes_read != 1) {
234
+ xfree(source);
235
+ return false;
236
+ }
237
+
238
+ *string = (pm_string_t) { .type = PM_STRING_OWNED, .source = source, .length = length };
239
+ return true;
240
+ #else
241
+ (void) string;
242
+ (void) filepath;
243
+ perror("pm_string_file_init is not implemented for this platform");
244
+ return false;
138
245
  #endif
139
246
  }
140
247
 
@@ -161,13 +268,33 @@ pm_string_ensure_owned(pm_string_t *string) {
161
268
  size_t length = pm_string_length(string);
162
269
  const uint8_t *source = pm_string_source(string);
163
270
 
164
- uint8_t *memory = malloc(length);
271
+ uint8_t *memory = xmalloc(length);
165
272
  if (!memory) return;
166
273
 
167
274
  pm_string_owned_init(string, memory, length);
168
275
  memcpy((void *) string->source, source, length);
169
276
  }
170
277
 
278
+ /**
279
+ * Compare the underlying lengths and bytes of two strings. Returns 0 if the
280
+ * strings are equal, a negative number if the left string is less than the
281
+ * right string, and a positive number if the left string is greater than the
282
+ * right string.
283
+ */
284
+ int
285
+ pm_string_compare(const pm_string_t *left, const pm_string_t *right) {
286
+ size_t left_length = pm_string_length(left);
287
+ size_t right_length = pm_string_length(right);
288
+
289
+ if (left_length < right_length) {
290
+ return -1;
291
+ } else if (left_length > right_length) {
292
+ return 1;
293
+ }
294
+
295
+ return memcmp(pm_string_source(left), pm_string_source(right), left_length);
296
+ }
297
+
171
298
  /**
172
299
  * Returns the length associated with the string.
173
300
  */
@@ -192,12 +319,14 @@ pm_string_free(pm_string_t *string) {
192
319
  void *memory = (void *) string->source;
193
320
 
194
321
  if (string->type == PM_STRING_OWNED) {
195
- free(memory);
322
+ xfree(memory);
323
+ #ifdef PRISM_HAS_MMAP
196
324
  } else if (string->type == PM_STRING_MAPPED && string->length) {
197
325
  #if defined(_WIN32)
198
326
  UnmapViewOfFile(memory);
199
- #else
327
+ #elif defined(_POSIX_MAPPED_FILES)
200
328
  munmap(memory, string->length);
201
329
  #endif
330
+ #endif /* PRISM_HAS_MMAP */
202
331
  }
203
332
  }
@@ -12,7 +12,7 @@ pm_string_list_append(pm_string_list_t *string_list, pm_string_t *string) {
12
12
  string_list->capacity *= 2;
13
13
  }
14
14
 
15
- string_list->strings = realloc(string_list->strings, string_list->capacity * sizeof(pm_string_t));
15
+ string_list->strings = xrealloc(string_list->strings, string_list->capacity * sizeof(pm_string_t));
16
16
  if (string_list->strings == NULL) abort();
17
17
  }
18
18
 
@@ -24,5 +24,5 @@ pm_string_list_append(pm_string_list_t *string_list, pm_string_t *string) {
24
24
  */
25
25
  void
26
26
  pm_string_list_free(pm_string_list_t *string_list) {
27
- free(string_list->strings);
27
+ xfree(string_list->strings);
28
28
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prism
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0
4
+ version: 0.26.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-15 00:00:00.000000000 Z
11
+ date: 2024-04-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -18,6 +18,7 @@ extensions:
18
18
  - ext/prism/extconf.rb
19
19
  extra_rdoc_files: []
20
20
  files:
21
+ - BSDmakefile
21
22
  - CHANGELOG.md
22
23
  - CODE_OF_CONDUCT.md
23
24
  - CONTRIBUTING.md
@@ -38,7 +39,7 @@ files:
38
39
  - docs/parser_translation.md
39
40
  - docs/parsing_rules.md
40
41
  - docs/releasing.md
41
- - docs/ripper.md
42
+ - docs/ripper_translation.md
42
43
  - docs/ruby_api.md
43
44
  - docs/ruby_parser_translation.md
44
45
  - docs/serialization.md
@@ -59,13 +60,14 @@ files:
59
60
  - include/prism/parser.h
60
61
  - include/prism/prettyprint.h
61
62
  - include/prism/regexp.h
63
+ - include/prism/static_literals.h
62
64
  - include/prism/util/pm_buffer.h
63
65
  - include/prism/util/pm_char.h
64
66
  - include/prism/util/pm_constant_pool.h
67
+ - include/prism/util/pm_integer.h
65
68
  - include/prism/util/pm_list.h
66
69
  - include/prism/util/pm_memchr.h
67
70
  - include/prism/util/pm_newline_list.h
68
- - include/prism/util/pm_state_stack.h
69
71
  - include/prism/util/pm_string.h
70
72
  - include/prism/util/pm_string_list.h
71
73
  - include/prism/util/pm_strncasecmp.h
@@ -89,6 +91,8 @@ files:
89
91
  - lib/prism/parse_result/comments.rb
90
92
  - lib/prism/parse_result/newlines.rb
91
93
  - lib/prism/pattern.rb
94
+ - lib/prism/polyfill/string.rb
95
+ - lib/prism/reflection.rb
92
96
  - lib/prism/serialize.rb
93
97
  - lib/prism/translation.rb
94
98
  - lib/prism/translation/parser.rb
@@ -98,13 +102,41 @@ files:
98
102
  - lib/prism/translation/parser33.rb
99
103
  - lib/prism/translation/parser34.rb
100
104
  - lib/prism/translation/ripper.rb
105
+ - lib/prism/translation/ripper/sexp.rb
106
+ - lib/prism/translation/ripper/shim.rb
101
107
  - lib/prism/translation/ruby_parser.rb
102
108
  - lib/prism/visitor.rb
103
109
  - prism.gemspec
104
110
  - rbi/prism.rbi
105
- - rbi/prism_static.rbi
111
+ - rbi/prism/compiler.rbi
112
+ - rbi/prism/desugar_compiler.rbi
113
+ - rbi/prism/mutation_compiler.rbi
114
+ - rbi/prism/node.rbi
115
+ - rbi/prism/node_ext.rbi
116
+ - rbi/prism/parse_result.rbi
117
+ - rbi/prism/reflection.rbi
118
+ - rbi/prism/translation/parser.rbi
119
+ - rbi/prism/translation/parser/compiler.rbi
120
+ - rbi/prism/translation/parser33.rbi
121
+ - rbi/prism/translation/parser34.rbi
122
+ - rbi/prism/translation/ripper.rbi
123
+ - rbi/prism/translation/ripper/ripper_compiler.rbi
124
+ - rbi/prism/translation/ruby_parser.rbi
125
+ - rbi/prism/visitor.rbi
106
126
  - sig/prism.rbs
107
- - sig/prism_static.rbs
127
+ - sig/prism/compiler.rbs
128
+ - sig/prism/dispatcher.rbs
129
+ - sig/prism/dot_visitor.rbs
130
+ - sig/prism/dsl.rbs
131
+ - sig/prism/mutation_compiler.rbs
132
+ - sig/prism/node.rbs
133
+ - sig/prism/node_ext.rbs
134
+ - sig/prism/pack.rbs
135
+ - sig/prism/parse_result.rbs
136
+ - sig/prism/pattern.rbs
137
+ - sig/prism/reflection.rbs
138
+ - sig/prism/serialize.rbs
139
+ - sig/prism/visitor.rbs
108
140
  - src/diagnostic.c
109
141
  - src/encoding.c
110
142
  - src/node.c
@@ -114,14 +146,15 @@ files:
114
146
  - src/prism.c
115
147
  - src/regexp.c
116
148
  - src/serialize.c
149
+ - src/static_literals.c
117
150
  - src/token_type.c
118
151
  - src/util/pm_buffer.c
119
152
  - src/util/pm_char.c
120
153
  - src/util/pm_constant_pool.c
154
+ - src/util/pm_integer.c
121
155
  - src/util/pm_list.c
122
156
  - src/util/pm_memchr.c
123
157
  - src/util/pm_newline_list.c
124
- - src/util/pm_state_stack.c
125
158
  - src/util/pm_string.c
126
159
  - src/util/pm_string_list.c
127
160
  - src/util/pm_strncasecmp.c
@@ -148,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
181
  - !ruby/object:Gem::Version
149
182
  version: '0'
150
183
  requirements: []
151
- rubygems_version: 3.4.1
184
+ rubygems_version: 3.6.0.dev
152
185
  signing_key:
153
186
  specification_version: 4
154
187
  summary: Prism Ruby parser
data/docs/ripper.md DELETED
@@ -1,36 +0,0 @@
1
- # Ripper
2
-
3
- To test the parser, we compare against the output from `Ripper`, both for testing the lexer and testing the parser. The lexer test suite is much more feature complete at the moment.
4
-
5
- To lex source code using `prism`, you typically would run `Prism.lex(source)`. If you want to instead get output that `Ripper` would normally produce, you can run `Prism.lex_compat(source)`. This will produce tokens that should be equivalent to `Ripper`.
6
-
7
- To parse source code using `prism`, you typically would run `Prism.parse(source)`. If you want to instead using the `Ripper` streaming interface, you can inherit from `Prism::RipperCompat` and override the `on_*` methods. This will produce a syntax tree that should be equivalent to `Ripper`. That would look like:
8
-
9
- ```ruby
10
- class ArithmeticRipper < Prism::RipperCompat
11
- def on_binary(left, operator, right)
12
- left.public_send(operator, right)
13
- end
14
-
15
- def on_int(value)
16
- value.to_i
17
- end
18
-
19
- def on_program(stmts)
20
- stmts
21
- end
22
-
23
- def on_stmts_new
24
- []
25
- end
26
-
27
- def on_stmts_add(stmts, stmt)
28
- stmts << stmt
29
- stmts
30
- end
31
- end
32
-
33
- ArithmeticRipper.new("1 + 2 - 3").parse # => [0]
34
- ```
35
-
36
- There are also APIs for building trees similar to the s-expression builders in `Ripper`. The method names are the same. These include `Prism::RipperCompat.sexp_raw(source)` and `Prism::RipperCompat.sexp(source)`.
@@ -1,42 +0,0 @@
1
- /**
2
- * @file pm_state_stack.h
3
- *
4
- * A stack of boolean values.
5
- */
6
- #ifndef PRISM_STATE_STACK_H
7
- #define PRISM_STATE_STACK_H
8
-
9
- #include "prism/defines.h"
10
-
11
- #include <stdbool.h>
12
- #include <stdint.h>
13
-
14
- /**
15
- * A struct that represents a stack of boolean values.
16
- */
17
- typedef uint32_t pm_state_stack_t;
18
-
19
- /**
20
- * Pushes a value onto the stack.
21
- *
22
- * @param stack The stack to push the value onto.
23
- * @param value The value to push onto the stack.
24
- */
25
- void pm_state_stack_push(pm_state_stack_t *stack, bool value);
26
-
27
- /**
28
- * Pops a value off the stack.
29
- *
30
- * @param stack The stack to pop the value off of.
31
- */
32
- void pm_state_stack_pop(pm_state_stack_t *stack);
33
-
34
- /**
35
- * Returns the value at the top of the stack.
36
- *
37
- * @param stack The stack to get the value from.
38
- * @return The value at the top of the stack.
39
- */
40
- bool pm_state_stack_p(pm_state_stack_t *stack);
41
-
42
- #endif
data/rbi/prism_static.rbi DELETED
@@ -1,207 +0,0 @@
1
- class Prism::ParseResult
2
- sig { returns(Prism::ProgramNode) }
3
- def value; end
4
-
5
- sig { returns(T::Array[Prism::Comment]) }
6
- def comments; end
7
-
8
- sig { returns(T::Array[Prism::ParseError]) }
9
- def errors; end
10
-
11
- sig { returns(T::Array[Prism::ParseWarning]) }
12
- def warnings; end
13
-
14
- sig { returns(Prism::Source) }
15
- def source; end
16
- end
17
-
18
- class Prism::ParseError
19
- sig { returns(String) }
20
- def message; end
21
-
22
- sig { returns(Prism::Location) }
23
- def location; end
24
- end
25
-
26
- class Prism::ParseWarning
27
- sig { returns(String) }
28
- def message; end
29
-
30
- sig { returns(Prism::Location) }
31
- def location; end
32
- end
33
-
34
- class Prism::Node
35
- sig { returns(Prism::Location) }
36
- def location; end
37
-
38
- sig { returns(String) }
39
- def slice; end
40
-
41
- sig { returns(String) }
42
- def to_dot; end
43
-
44
- sig { params(visitor: Prism::Visitor).void }
45
- def accept(visitor); end
46
-
47
- sig { returns(T::Array[T.nilable(Prism::Node)]) }
48
- def child_nodes; end
49
-
50
- sig { returns(T::Array[Prism::Node]) }
51
- def compact_child_nodes; end
52
-
53
- sig { returns(T::Array[T.nilable(Prism::Node)]) }
54
- def deconstruct; end
55
-
56
- sig { returns(Symbol) }
57
- def type; end
58
- end
59
-
60
- class Prism::Comment
61
- sig { returns(Prism::Location) }
62
- def location; end
63
-
64
- sig { returns(T::Boolean) }
65
- def trailing?; end
66
- end
67
-
68
- class Prism::InlineComment < Prism::Comment
69
- sig { override.returns(T::Boolean) }
70
- def trailing?; end
71
- end
72
-
73
- class Prism::EmbDocComment < Prism::Comment
74
- end
75
-
76
- class Prism::DATAComment < Prism::Comment
77
- end
78
-
79
- class Prism::Location
80
- sig { params(source: Prism::Source, start_offset: Integer, length: Integer).void }
81
- def initialize(source, start_offset, length); end
82
-
83
- sig { returns(String) }
84
- def slice; end
85
-
86
- sig { returns(T::Array[Prism::Comment]) }
87
- def comments; end
88
-
89
- sig { params(options: T.untyped).returns(Prism::Location) }
90
- def copy(**options); end
91
-
92
- sig { returns(Integer) }
93
- def start_offset; end
94
-
95
- sig { returns(Integer) }
96
- def end_offset; end
97
-
98
- sig { returns(Integer) }
99
- def start_line; end
100
-
101
- sig { returns(Integer) }
102
- def end_line; end
103
-
104
- sig { returns(Integer) }
105
- def start_column; end
106
-
107
- sig { returns(Integer) }
108
- def end_column; end
109
- end
110
-
111
- class Prism::Source
112
- sig { params(source: String, start_line: Integer, offsets: T::Array[Integer]).void }
113
- def initialize(source, start_line, offsets); end
114
-
115
- sig { params(offset: Integer, length: Integer).returns(String) }
116
- def slice(offset, length); end
117
-
118
- sig { params(value: Integer).returns(Integer) }
119
- def line(value); end
120
-
121
- sig { params(value: Integer).returns(Integer) }
122
- def line_offset(value); end
123
-
124
- sig { params(value: Integer).returns(Integer) }
125
- def column(value); end
126
-
127
- sig { returns(String) }
128
- def source; end
129
-
130
- sig { returns(T::Array[Integer]) }
131
- def offsets; end
132
- end
133
-
134
- class Prism::Token
135
- sig { params(type: T.untyped, value: String, location: Prism::Location).void }
136
- def initialize(type, value, location); end
137
-
138
- sig { params(keys: T.untyped).returns(T.untyped) }
139
- def deconstruct_keys(keys); end
140
-
141
- sig { params(q: T.untyped).returns(T.untyped) }
142
- def pretty_print(q); end
143
-
144
- sig { params(other: T.untyped).returns(T::Boolean) }
145
- def ==(other); end
146
-
147
- sig { returns(T.untyped) }
148
- def type; end
149
-
150
- sig { returns(String) }
151
- def value; end
152
-
153
- sig { returns(Prism::Location) }
154
- def location; end
155
- end
156
-
157
- class Prism::NodeInspector
158
- sig { params(prefix: String).void }
159
- def initialize(prefix); end
160
-
161
- sig { returns(String) }
162
- def prefix; end
163
-
164
- sig { returns(String) }
165
- def output; end
166
-
167
- # Appends a line to the output with the current prefix.
168
- sig { params(line: String).void }
169
- def <<(line); end
170
-
171
- # This generates a string that is used as the header of the inspect output
172
- # for any given node.
173
- sig { params(node: Prism::Node).returns(String) }
174
- def header(node); end
175
-
176
- # Generates a string that represents a list of nodes. It handles properly
177
- # using the box drawing characters to make the output look nice.
178
- sig { params(prefix: String, nodes: T::Array[Prism::Node]).returns(String) }
179
- def list(prefix, nodes); end
180
-
181
- # Generates a string that represents a location field on a node.
182
- sig { params(value: Prism::Location).returns(String) }
183
- def location(value); end
184
-
185
- # Generates a string that represents a child node.
186
- sig { params(node: Prism::Node, append: String).returns(String) }
187
- def child_node(node, append); end
188
-
189
- # Returns a new inspector that can be used to inspect a child node.
190
- sig { params(append: String).returns(Prism::NodeInspector) }
191
- def child_inspector(append); end
192
-
193
- # Returns the output as a string.
194
- sig { returns(String) }
195
- def to_str; end
196
- end
197
-
198
- class Prism::BasicVisitor
199
- sig { params(node: T.nilable(Prism::Node)).void }
200
- def visit(node); end
201
-
202
- sig { params(nodes: T::Array[T.nilable(Prism::Node)]).void }
203
- def visit_all(nodes); end
204
-
205
- sig { params(node: Prism::Node).void }
206
- def visit_child_nodes(node); end
207
- end