prism 1.8.0 → 1.9.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.
data/sig/prism.rbs CHANGED
@@ -14,119 +14,128 @@ module Prism
14
14
 
15
15
  def self.parse: (
16
16
  String source,
17
+ ?command_line: String,
17
18
  ?encoding: Encoding | false,
18
19
  ?filepath: String,
19
20
  ?freeze: bool,
20
21
  ?frozen_string_literal: bool,
21
22
  ?line: Integer,
22
23
  ?main_script: bool,
23
- ?offset: Integer,
24
+ ?partial_script: bool,
24
25
  ?scopes: Array[Array[Symbol]],
25
- ?verbose: bool
26
+ ?version: String
26
27
  ) -> ParseResult
27
28
 
28
29
  def self.profile: (
29
30
  String source,
31
+ ?command_line: String,
30
32
  ?encoding: Encoding | false,
31
33
  ?filepath: String,
32
34
  ?freeze: bool,
33
35
  ?frozen_string_literal: bool,
34
36
  ?line: Integer,
35
37
  ?main_script: bool,
36
- ?offset: Integer,
38
+ ?partial_script: bool,
37
39
  ?scopes: Array[Array[Symbol]],
38
- ?verbose: bool
40
+ ?version: String
39
41
  ) -> nil
40
42
 
41
43
  def self.lex: (
42
44
  String source,
45
+ ?command_line: String,
43
46
  ?encoding: Encoding | false,
44
47
  ?filepath: String,
45
48
  ?freeze: bool,
46
49
  ?frozen_string_literal: bool,
47
50
  ?line: Integer,
48
51
  ?main_script: bool,
49
- ?offset: Integer,
52
+ ?partial_script: bool,
50
53
  ?scopes: Array[Array[Symbol]],
51
- ?verbose: bool
54
+ ?version: String
52
55
  ) -> LexResult
53
56
 
54
57
  def self.lex_compat: (
55
58
  String source,
59
+ ?command_line: String,
56
60
  ?encoding: Encoding | false,
57
61
  ?filepath: String,
58
62
  ?freeze: bool,
59
63
  ?frozen_string_literal: bool,
60
64
  ?line: Integer,
61
65
  ?main_script: bool,
62
- ?offset: Integer,
66
+ ?partial_script: bool,
63
67
  ?scopes: Array[Array[Symbol]],
64
- ?verbose: bool
68
+ ?version: String
65
69
  ) -> LexCompat::Result
66
70
 
67
71
  def self.parse_lex: (
68
72
  String source,
73
+ ?command_line: String,
69
74
  ?encoding: Encoding | false,
70
75
  ?filepath: String,
71
76
  ?freeze: bool,
72
77
  ?frozen_string_literal: bool,
73
78
  ?line: Integer,
74
79
  ?main_script: bool,
75
- ?offset: Integer,
80
+ ?partial_script: bool,
76
81
  ?scopes: Array[Array[Symbol]],
77
- ?verbose: bool
82
+ ?version: String
78
83
  ) -> ParseLexResult
79
84
 
80
85
  def self.dump: (
81
86
  String source,
87
+ ?command_line: String,
82
88
  ?encoding: Encoding | false,
83
89
  ?filepath: String,
84
90
  ?freeze: bool,
85
91
  ?frozen_string_literal: bool,
86
92
  ?line: Integer,
87
93
  ?main_script: bool,
88
- ?offset: Integer,
94
+ ?partial_script: bool,
89
95
  ?scopes: Array[Array[Symbol]],
90
- ?verbose: bool
96
+ ?version: String
91
97
  ) -> String
92
98
 
93
99
  def self.parse_comments: (
94
100
  String source,
101
+ ?command_line: String,
95
102
  ?encoding: Encoding | false,
96
103
  ?filepath: String,
97
104
  ?freeze: bool,
98
105
  ?frozen_string_literal: bool,
99
106
  ?line: Integer,
100
107
  ?main_script: bool,
101
- ?offset: Integer,
108
+ ?partial_script: bool,
102
109
  ?scopes: Array[Array[Symbol]],
103
- ?verbose: bool
110
+ ?version: String
104
111
  ) -> Array[comment]
105
112
 
106
113
  def self.parse_success?: (
107
114
  String source,
115
+ ?command_line: String,
108
116
  ?encoding: Encoding | false,
109
117
  ?filepath: String,
110
118
  ?freeze: bool,
111
119
  ?frozen_string_literal: bool,
112
120
  ?line: Integer,
113
121
  ?main_script: bool,
114
- ?offset: Integer,
122
+ ?partial_script: bool,
115
123
  ?scopes: Array[Array[Symbol]],
116
- ?verbose: bool
124
+ ?version: String
117
125
  ) -> bool
118
126
 
119
127
  def self.parse_failure?: (
120
128
  String source,
129
+ ?command_line: String,
121
130
  ?encoding: Encoding | false,
122
131
  ?filepath: String,
123
132
  ?freeze: bool,
124
133
  ?frozen_string_literal: bool,
125
134
  ?line: Integer,
126
135
  ?main_script: bool,
127
- ?offset: Integer,
136
+ ?partial_script: bool,
128
137
  ?scopes: Array[Array[Symbol]],
129
- ?verbose: bool
138
+ ?version: String
130
139
  ) -> bool
131
140
 
132
141
  def self.load: (
@@ -135,106 +144,110 @@ module Prism
135
144
  ?bool freeze
136
145
  ) -> ParseResult
137
146
 
138
- def self.lex_ripper: (
139
- String source
140
- ) -> Array[[[Integer, Integer], Symbol, String, untyped]]
141
-
142
147
  # Methods taking a path to a Ruby file:
143
148
 
144
149
  def self.parse_file: (
145
150
  String filepath,
151
+ ?command_line: String,
146
152
  ?encoding: Encoding | false,
147
153
  ?freeze: bool,
148
154
  ?frozen_string_literal: bool,
149
155
  ?line: Integer,
150
156
  ?main_script: bool,
151
- ?offset: Integer,
157
+ ?partial_script: bool,
152
158
  ?scopes: Array[Array[Symbol]],
153
- ?verbose: bool
159
+ ?version: String
154
160
  ) -> ParseResult
155
161
 
156
162
  def self.profile_file: (
157
163
  String filepath,
164
+ ?command_line: String,
158
165
  ?encoding: Encoding | false,
159
166
  ?freeze: bool,
160
167
  ?frozen_string_literal: bool,
161
168
  ?line: Integer,
162
169
  ?main_script: bool,
163
- ?offset: Integer,
170
+ ?partial_script: bool,
164
171
  ?scopes: Array[Array[Symbol]],
165
- ?verbose: bool
172
+ ?version: String
166
173
  ) -> nil
167
174
 
168
175
  def self.lex_file: (
169
176
  String filepath,
177
+ ?command_line: String,
170
178
  ?encoding: Encoding | false,
171
179
  ?freeze: bool,
172
180
  ?frozen_string_literal: bool,
173
181
  ?line: Integer,
174
182
  ?main_script: bool,
175
- ?offset: Integer,
183
+ ?partial_script: bool,
176
184
  ?scopes: Array[Array[Symbol]],
177
- ?verbose: bool
185
+ ?version: String
178
186
  ) -> LexResult
179
187
 
180
188
  def self.parse_lex_file: (
181
189
  String filepath,
190
+ ?command_line: String,
182
191
  ?encoding: Encoding | false,
183
192
  ?freeze: bool,
184
193
  ?frozen_string_literal: bool,
185
194
  ?line: Integer,
186
195
  ?main_script: bool,
187
- ?offset: Integer,
196
+ ?partial_script: bool,
188
197
  ?scopes: Array[Array[Symbol]],
189
- ?verbose: bool
198
+ ?version: String
190
199
  ) -> ParseLexResult
191
200
 
192
201
  def self.dump_file: (
193
202
  String filepath,
203
+ ?command_line: String,
194
204
  ?encoding: Encoding | false,
195
205
  ?freeze: bool,
196
206
  ?frozen_string_literal: bool,
197
207
  ?line: Integer,
198
208
  ?main_script: bool,
199
- ?offset: Integer,
209
+ ?partial_script: bool,
200
210
  ?scopes: Array[Array[Symbol]],
201
- ?verbose: bool
211
+ ?version: String
202
212
  ) -> String
203
213
 
204
214
  def self.parse_file_comments: (
205
215
  String filepath,
216
+ ?command_line: String,
206
217
  ?encoding: Encoding | false,
207
218
  ?freeze: bool,
208
219
  ?frozen_string_literal: bool,
209
220
  ?line: Integer,
210
221
  ?main_script: bool,
211
- ?offset: Integer,
222
+ ?partial_script: bool,
212
223
  ?scopes: Array[Array[Symbol]],
213
- ?verbose: bool
224
+ ?version: String
214
225
  ) -> Array[comment]
215
226
 
216
227
  def self.parse_file_success?: (
217
228
  String filepath,
229
+ ?command_line: String,
218
230
  ?encoding: Encoding | false,
219
231
  ?freeze: bool,
220
232
  ?frozen_string_literal: bool,
221
233
  ?line: Integer,
222
234
  ?main_script: bool,
223
- ?offset: Integer,
235
+ ?partial_script: bool,
224
236
  ?scopes: Array[Array[Symbol]],
225
- ?verbose: bool
237
+ ?version: String
226
238
  ) -> bool
227
239
 
228
240
  def self.parse_file_failure?: (
229
241
  String filepath,
242
+ ?command_line: String,
230
243
  ?encoding: Encoding | false,
231
244
  ?freeze: bool,
232
245
  ?frozen_string_literal: bool,
233
246
  ?line: Integer,
234
247
  ?main_script: bool,
235
- ?offset: Integer,
248
+ ?partial_script: bool,
236
249
  ?scopes: Array[Array[Symbol]],
237
- ?verbose: bool
250
+ ?version: String
238
251
  ) -> bool
239
252
 
240
253
  interface _Stream
@@ -243,15 +256,16 @@ module Prism
243
256
 
244
257
  def self.parse_stream: (
245
258
  _Stream stream,
259
+ ?command_line: String,
246
260
  ?encoding: Encoding | false,
247
261
  ?filepath: String,
248
262
  ?freeze: bool,
249
263
  ?frozen_string_literal: bool,
250
264
  ?line: Integer,
251
265
  ?main_script: bool,
252
- ?offset: Integer,
266
+ ?partial_script: bool,
253
267
  ?scopes: Array[Array[Symbol]],
254
- ?verbose: bool
268
+ ?version: String
255
269
  ) -> ParseResult
256
270
 
257
271
  def self.scope: (?locals: Array[Symbol], ?forwarding: Array[Symbol]) -> Scope
data/src/prism.c CHANGED
@@ -12438,7 +12438,7 @@ expect1_opening(pm_parser_t *parser, pm_token_type_t type, pm_diagnostic_id_t di
12438
12438
 
12439
12439
  pm_parser_err(parser, opening->start, opening->end, diag_id);
12440
12440
 
12441
- parser->previous.start = opening->end;
12441
+ parser->previous.start = parser->previous.end;
12442
12442
  parser->previous.type = PM_TOKEN_MISSING;
12443
12443
  }
12444
12444
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prism
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
@@ -80,7 +80,6 @@ files:
80
80
  - lib/prism/ffi.rb
81
81
  - lib/prism/inspect_visitor.rb
82
82
  - lib/prism/lex_compat.rb
83
- - lib/prism/lex_ripper.rb
84
83
  - lib/prism/mutation_compiler.rb
85
84
  - lib/prism/node.rb
86
85
  - lib/prism/node_ext.rb
@@ -107,6 +106,7 @@ files:
107
106
  - lib/prism/translation/parser_current.rb
108
107
  - lib/prism/translation/parser_versions.rb
109
108
  - lib/prism/translation/ripper.rb
109
+ - lib/prism/translation/ripper/filter.rb
110
110
  - lib/prism/translation/ripper/lexer.rb
111
111
  - lib/prism/translation/ripper/sexp.rb
112
112
  - lib/prism/translation/ripper/shim.rb
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
- # :markup: markdown
3
-
4
- require "ripper"
5
-
6
- module Prism
7
- # This is a class that wraps the Ripper lexer to produce almost exactly the
8
- # same tokens.
9
- class LexRipper # :nodoc:
10
- attr_reader :source
11
-
12
- def initialize(source)
13
- @source = source
14
- end
15
-
16
- def result
17
- previous = [] #: [[Integer, Integer], Symbol, String, untyped] | []
18
- results = [] #: Array[[[Integer, Integer], Symbol, String, untyped]]
19
-
20
- lex(source).each do |token|
21
- case token[1]
22
- when :on_sp
23
- # skip
24
- when :on_tstring_content
25
- if previous[1] == :on_tstring_content && (token[2].start_with?("\#$") || token[2].start_with?("\#@"))
26
- previous[2] << token[2]
27
- else
28
- results << token
29
- previous = token
30
- end
31
- when :on_words_sep
32
- if previous[1] == :on_words_sep
33
- previous[2] << token[2]
34
- else
35
- results << token
36
- previous = token
37
- end
38
- else
39
- results << token
40
- previous = token
41
- end
42
- end
43
-
44
- results
45
- end
46
-
47
- private
48
-
49
- if Ripper.method(:lex).parameters.assoc(:keyrest)
50
- def lex(source)
51
- Ripper.lex(source, raise_errors: true)
52
- end
53
- else
54
- def lex(source)
55
- ripper = Ripper::Lexer.new(source)
56
- ripper.lex.tap do |result|
57
- raise SyntaxError, ripper.errors.map(&:message).join(' ;') if ripper.errors.any?
58
- end
59
- end
60
- end
61
- end
62
-
63
- private_constant :LexRipper
64
- end