prism 0.24.0 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/BSDmakefile +58 -0
- data/CHANGELOG.md +50 -1
- data/Makefile +5 -2
- data/README.md +45 -6
- data/config.yml +499 -4
- data/docs/build_system.md +31 -0
- data/docs/configuration.md +2 -0
- data/docs/cruby_compilation.md +1 -1
- data/docs/parser_translation.md +14 -9
- data/docs/releasing.md +2 -2
- data/docs/ripper_translation.md +50 -0
- data/docs/ruby_api.md +1 -0
- data/docs/serialization.md +26 -5
- data/ext/prism/api_node.c +911 -815
- data/ext/prism/api_pack.c +9 -0
- data/ext/prism/extconf.rb +27 -11
- data/ext/prism/extension.c +313 -66
- data/ext/prism/extension.h +5 -4
- data/include/prism/ast.h +213 -64
- data/include/prism/defines.h +106 -2
- data/include/prism/diagnostic.h +134 -71
- data/include/prism/encoding.h +22 -4
- data/include/prism/node.h +93 -0
- data/include/prism/options.h +82 -7
- data/include/prism/pack.h +11 -0
- data/include/prism/parser.h +198 -53
- data/include/prism/prettyprint.h +8 -0
- data/include/prism/static_literals.h +118 -0
- data/include/prism/util/pm_buffer.h +65 -2
- data/include/prism/util/pm_constant_pool.h +18 -1
- data/include/prism/util/pm_integer.h +119 -0
- data/include/prism/util/pm_list.h +1 -1
- data/include/prism/util/pm_newline_list.h +8 -0
- data/include/prism/util/pm_string.h +26 -2
- data/include/prism/version.h +2 -2
- data/include/prism.h +59 -1
- data/lib/prism/compiler.rb +8 -1
- data/lib/prism/debug.rb +46 -3
- data/lib/prism/desugar_compiler.rb +1 -1
- data/lib/prism/dispatcher.rb +29 -0
- data/lib/prism/dot_visitor.rb +87 -16
- data/lib/prism/dsl.rb +24 -12
- data/lib/prism/ffi.rb +67 -12
- data/lib/prism/lex_compat.rb +17 -15
- data/lib/prism/mutation_compiler.rb +11 -0
- data/lib/prism/node.rb +2096 -2499
- data/lib/prism/node_ext.rb +77 -29
- data/lib/prism/pack.rb +4 -0
- data/lib/prism/parse_result/comments.rb +34 -17
- data/lib/prism/parse_result/newlines.rb +3 -1
- data/lib/prism/parse_result.rb +78 -32
- data/lib/prism/pattern.rb +16 -4
- data/lib/prism/polyfill/string.rb +12 -0
- data/lib/prism/serialize.rb +439 -102
- data/lib/prism/translation/parser/compiler.rb +152 -50
- data/lib/prism/translation/parser/lexer.rb +103 -22
- data/lib/prism/translation/parser/rubocop.rb +41 -13
- data/lib/prism/translation/parser.rb +119 -7
- data/lib/prism/translation/parser33.rb +1 -1
- data/lib/prism/translation/parser34.rb +1 -1
- data/lib/prism/translation/ripper/sexp.rb +125 -0
- data/lib/prism/translation/ripper/shim.rb +5 -0
- data/lib/prism/translation/ripper.rb +3212 -462
- data/lib/prism/translation/ruby_parser.rb +35 -18
- data/lib/prism/translation.rb +3 -1
- data/lib/prism/visitor.rb +10 -0
- data/lib/prism.rb +8 -2
- data/prism.gemspec +33 -4
- data/rbi/prism/compiler.rbi +14 -0
- data/rbi/prism/desugar_compiler.rbi +5 -0
- data/rbi/prism/mutation_compiler.rbi +5 -0
- data/rbi/prism/node.rbi +8221 -0
- data/rbi/prism/node_ext.rbi +102 -0
- data/rbi/prism/parse_result.rbi +304 -0
- data/rbi/prism/translation/parser/compiler.rbi +13 -0
- data/rbi/prism/translation/ripper/ripper_compiler.rbi +5 -0
- data/rbi/prism/translation/ripper.rbi +25 -0
- data/rbi/prism/translation/ruby_parser.rbi +11 -0
- data/rbi/prism/visitor.rbi +470 -0
- data/rbi/prism.rbi +39 -7749
- data/sig/prism/compiler.rbs +9 -0
- data/sig/prism/dispatcher.rbs +16 -0
- data/sig/prism/dot_visitor.rbs +6 -0
- data/sig/prism/dsl.rbs +462 -0
- data/sig/prism/mutation_compiler.rbs +158 -0
- data/sig/prism/node.rbs +3529 -0
- data/sig/prism/node_ext.rbs +78 -0
- data/sig/prism/pack.rbs +43 -0
- data/sig/prism/parse_result.rbs +127 -0
- data/sig/prism/pattern.rbs +13 -0
- data/sig/prism/serialize.rbs +7 -0
- data/sig/prism/visitor.rbs +168 -0
- data/sig/prism.rbs +188 -4767
- data/src/diagnostic.c +575 -230
- data/src/encoding.c +211 -108
- data/src/node.c +7526 -447
- data/src/options.c +36 -12
- data/src/pack.c +33 -17
- data/src/prettyprint.c +1294 -1385
- data/src/prism.c +3628 -1099
- data/src/regexp.c +17 -2
- data/src/serialize.c +47 -28
- data/src/static_literals.c +552 -0
- data/src/token_type.c +1 -0
- data/src/util/pm_buffer.c +147 -20
- data/src/util/pm_char.c +4 -4
- data/src/util/pm_constant_pool.c +35 -11
- data/src/util/pm_integer.c +629 -0
- data/src/util/pm_list.c +1 -1
- data/src/util/pm_newline_list.c +14 -5
- data/src/util/pm_string.c +134 -5
- data/src/util/pm_string_list.c +2 -2
- metadata +35 -6
- data/docs/ripper.md +0 -36
- data/rbi/prism_static.rbi +0 -207
- data/sig/prism_static.rbs +0 -201
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
|
-
#
|
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 =
|
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
|
-
|
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
|
-
#
|
327
|
+
#elif defined(_POSIX_MAPPED_FILES)
|
200
328
|
munmap(memory, string->length);
|
201
329
|
#endif
|
330
|
+
#endif /* PRISM_HAS_MMAP */
|
202
331
|
}
|
203
332
|
}
|
data/src/util/pm_string_list.c
CHANGED
@@ -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 =
|
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
|
-
|
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.
|
4
|
+
version: 0.25.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-
|
11
|
+
date: 2024-04-05 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/
|
42
|
+
- docs/ripper_translation.md
|
42
43
|
- docs/ruby_api.md
|
43
44
|
- docs/ruby_parser_translation.md
|
44
45
|
- docs/serialization.md
|
@@ -59,9 +60,11 @@ 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
|
@@ -89,6 +92,7 @@ files:
|
|
89
92
|
- lib/prism/parse_result/comments.rb
|
90
93
|
- lib/prism/parse_result/newlines.rb
|
91
94
|
- lib/prism/pattern.rb
|
95
|
+
- lib/prism/polyfill/string.rb
|
92
96
|
- lib/prism/serialize.rb
|
93
97
|
- lib/prism/translation.rb
|
94
98
|
- lib/prism/translation/parser.rb
|
@@ -98,13 +102,36 @@ 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/
|
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/translation/parser/compiler.rbi
|
118
|
+
- rbi/prism/translation/ripper.rbi
|
119
|
+
- rbi/prism/translation/ripper/ripper_compiler.rbi
|
120
|
+
- rbi/prism/translation/ruby_parser.rbi
|
121
|
+
- rbi/prism/visitor.rbi
|
106
122
|
- sig/prism.rbs
|
107
|
-
- sig/
|
123
|
+
- sig/prism/compiler.rbs
|
124
|
+
- sig/prism/dispatcher.rbs
|
125
|
+
- sig/prism/dot_visitor.rbs
|
126
|
+
- sig/prism/dsl.rbs
|
127
|
+
- sig/prism/mutation_compiler.rbs
|
128
|
+
- sig/prism/node.rbs
|
129
|
+
- sig/prism/node_ext.rbs
|
130
|
+
- sig/prism/pack.rbs
|
131
|
+
- sig/prism/parse_result.rbs
|
132
|
+
- sig/prism/pattern.rbs
|
133
|
+
- sig/prism/serialize.rbs
|
134
|
+
- sig/prism/visitor.rbs
|
108
135
|
- src/diagnostic.c
|
109
136
|
- src/encoding.c
|
110
137
|
- src/node.c
|
@@ -114,10 +141,12 @@ files:
|
|
114
141
|
- src/prism.c
|
115
142
|
- src/regexp.c
|
116
143
|
- src/serialize.c
|
144
|
+
- src/static_literals.c
|
117
145
|
- src/token_type.c
|
118
146
|
- src/util/pm_buffer.c
|
119
147
|
- src/util/pm_char.c
|
120
148
|
- src/util/pm_constant_pool.c
|
149
|
+
- src/util/pm_integer.c
|
121
150
|
- src/util/pm_list.c
|
122
151
|
- src/util/pm_memchr.c
|
123
152
|
- src/util/pm_newline_list.c
|
@@ -148,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
177
|
- !ruby/object:Gem::Version
|
149
178
|
version: '0'
|
150
179
|
requirements: []
|
151
|
-
rubygems_version: 3.
|
180
|
+
rubygems_version: 3.6.0.dev
|
152
181
|
signing_key:
|
153
182
|
specification_version: 4
|
154
183
|
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)`.
|
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
|