ripper_ruby_parser 1.11.0 → 1.12.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +6 -4
- data/lib/ripper_ruby_parser/commenting_ripper_parser.rb +27 -7
- data/lib/ripper_ruby_parser/sexp_handlers/assignment.rb +3 -0
- data/lib/ripper_ruby_parser/sexp_handlers/blocks.rb +3 -2
- data/lib/ripper_ruby_parser/sexp_handlers/methods.rb +1 -0
- data/lib/ripper_ruby_parser/sexp_handlers/string_literals.rb +8 -2
- data/lib/ripper_ruby_parser/sexp_processor.rb +0 -6
- data/lib/ripper_ruby_parser/unescape.rb +1 -1
- data/lib/ripper_ruby_parser/version.rb +1 -1
- metadata +14 -31
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e017d6c1dff36a5f33a74676c9ff3d9d069ad2210bc8e8049b26ddff56d8961b
|
|
4
|
+
data.tar.gz: 76ba1cc8e225478f4679ed0b801c69387f5c350b57fda365a6316f42c0800bba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c22fb29374df4cde3de294f1fd7f7e7b529b7a67d69522f5779ff2cb1ec83f8ea8acfdc6eb0750bf9246094989df59b586a1bb96ff3c7c6227aa51be49d8e121
|
|
7
|
+
data.tar.gz: 2d3988eebde86cc80dbcd8079941e00cd3edc4263a105590d608cb37622284cb96bf9cff923b8514d31fd8b4cddaaafdbab270f077d49f0326960c6645577f3b
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,16 @@ This project adheres to [Semantic Versioning 2.0.0][1].
|
|
|
6
6
|
|
|
7
7
|
This document is formatted based on [Keep A CHANGELOG][2].
|
|
8
8
|
|
|
9
|
+
## 1.12.0 / 2025-10-25
|
|
10
|
+
|
|
11
|
+
* Target compatibility with `ruby_parser` 3.21 ([#256] by [mvz])
|
|
12
|
+
* Support Ruby 3.2 through 3.4, dropping support for Ruby 3.0 and 3.1
|
|
13
|
+
([#255] and [#260] by [mvz])
|
|
14
|
+
|
|
15
|
+
[#255]: https://github.com/mvz/ripper_ruby_parser/pull/255
|
|
16
|
+
[#256]: https://github.com/mvz/ripper_ruby_parser/pull/256
|
|
17
|
+
[#260]: https://github.com/mvz/ripper_ruby_parser/pull/260
|
|
18
|
+
|
|
9
19
|
## 1.11.0 / 2024-01-05
|
|
10
20
|
|
|
11
21
|
* Support Ruby 3.0 through 3.3, dropping support for Ruby 2.6 and 2.7
|
data/README.md
CHANGED
|
@@ -10,8 +10,8 @@ Parse with Ripper, produce sexps that are compatible with RubyParser.
|
|
|
10
10
|
|
|
11
11
|
* Drop-in replacement for RubyParser
|
|
12
12
|
* Should handle 1.9 and later syntax gracefully
|
|
13
|
-
* Requires Ruby 3.
|
|
14
|
-
* Compatible with RubyParser 3.
|
|
13
|
+
* Requires Ruby 3.2 or higher
|
|
14
|
+
* Compatible with RubyParser 3.21.0
|
|
15
15
|
|
|
16
16
|
## Known incompatibilities
|
|
17
17
|
|
|
@@ -22,6 +22,8 @@ RipperRubyParser has a few incompatibilities with RubyParser.
|
|
|
22
22
|
* RipperRubyParser does not always match RubyParser's line numbering
|
|
23
23
|
* RipperRubyParser dedents auto-dedenting heredocs
|
|
24
24
|
* RipperRubyParser does not include postfix comments
|
|
25
|
+
* With Ruby 3.4, RipperRubyParser parses variables assigned by regular
|
|
26
|
+
expressions as local variables
|
|
25
27
|
|
|
26
28
|
## Install
|
|
27
29
|
|
|
@@ -46,7 +48,7 @@ parser.parse "foo[bar] += baz qux"
|
|
|
46
48
|
|
|
47
49
|
## Requirements
|
|
48
50
|
|
|
49
|
-
* Ruby 2
|
|
51
|
+
* Ruby 3.2 or higher
|
|
50
52
|
* `sexp_processor`
|
|
51
53
|
|
|
52
54
|
## Hacking and contributing
|
|
@@ -66,7 +68,7 @@ If you want to send pull requests or patches, please:
|
|
|
66
68
|
|
|
67
69
|
(The MIT License)
|
|
68
70
|
|
|
69
|
-
Copyright (c) 2012, 2014-
|
|
71
|
+
Copyright (c) 2012, 2014-2025 Matijs van Zuijlen
|
|
70
72
|
|
|
71
73
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
72
74
|
a copy of this software and associated documentation files (the
|
|
@@ -70,15 +70,17 @@ module RipperRubyParser
|
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
def on_kw(tok)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
super.tap do |result|
|
|
74
|
+
next if @in_symbol
|
|
75
|
+
|
|
76
|
+
case tok
|
|
77
|
+
when "class", "def", "module", "BEGIN", "begin", "END"
|
|
77
78
|
@comment_stack.push [result, @comment]
|
|
78
79
|
@comment = ""
|
|
80
|
+
when "end"
|
|
81
|
+
@comment = "" if @comment_stack.any?
|
|
79
82
|
end
|
|
80
83
|
end
|
|
81
|
-
result
|
|
82
84
|
end
|
|
83
85
|
|
|
84
86
|
def on_module(*args)
|
|
@@ -221,7 +223,7 @@ module RipperRubyParser
|
|
|
221
223
|
end
|
|
222
224
|
|
|
223
225
|
def on_tstring_content(content)
|
|
224
|
-
super
|
|
226
|
+
super << @delimiter_stack.last
|
|
225
227
|
end
|
|
226
228
|
|
|
227
229
|
def on_tstring_end(delimiter)
|
|
@@ -287,6 +289,7 @@ module RipperRubyParser
|
|
|
287
289
|
end
|
|
288
290
|
|
|
289
291
|
NUMBER_LITERAL_TYPES = [:@imaginary, :@int, :@float, :@rational].freeze
|
|
292
|
+
private_constant :NUMBER_LITERAL_TYPES
|
|
290
293
|
|
|
291
294
|
def on_unary(operator, value)
|
|
292
295
|
if !@space_before && operator == :-@ && NUMBER_LITERAL_TYPES.include?(value.first)
|
|
@@ -321,6 +324,21 @@ module RipperRubyParser
|
|
|
321
324
|
super
|
|
322
325
|
end
|
|
323
326
|
|
|
327
|
+
def on_case(*args)
|
|
328
|
+
@comment = ""
|
|
329
|
+
super
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
def on_ident(*args)
|
|
333
|
+
@comment = ""
|
|
334
|
+
super
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
def on_string_content(*args)
|
|
338
|
+
@comment = ""
|
|
339
|
+
super
|
|
340
|
+
end
|
|
341
|
+
|
|
324
342
|
def on_BEGIN(*args)
|
|
325
343
|
commentize("BEGIN", super)
|
|
326
344
|
end
|
|
@@ -351,13 +369,15 @@ module RipperRubyParser
|
|
|
351
369
|
end
|
|
352
370
|
|
|
353
371
|
def commentize(name, exp, target_loc = nil)
|
|
372
|
+
raise "Non-empty comment in progress: #{@comment}" unless @comment.empty?
|
|
373
|
+
|
|
354
374
|
if target_loc
|
|
355
375
|
(_, kw, loc), comment = @comment_stack.pop until (loc <=> target_loc) == -1
|
|
356
376
|
else
|
|
357
377
|
(_, kw, loc), comment = @comment_stack.pop
|
|
358
378
|
end
|
|
359
379
|
|
|
360
|
-
|
|
380
|
+
raise "Comment stack mismatch: expected #{kw} to equal #{name}" unless kw == name
|
|
361
381
|
|
|
362
382
|
@comment = ""
|
|
363
383
|
exp.push loc
|
|
@@ -155,6 +155,7 @@ module RipperRubyParser
|
|
|
155
155
|
"||": :op_asgn_or,
|
|
156
156
|
"&&": :op_asgn_and
|
|
157
157
|
}.freeze
|
|
158
|
+
private_constant :OPERATOR_ASSIGNMENT_MAP
|
|
158
159
|
|
|
159
160
|
def create_regular_operator_assignment_sub_type(lvalue, value, operator)
|
|
160
161
|
value = unwrap_begin(value)
|
|
@@ -198,6 +199,8 @@ module RipperRubyParser
|
|
|
198
199
|
cvar: :cvasgn
|
|
199
200
|
}.freeze
|
|
200
201
|
|
|
202
|
+
private_constant :ASSIGNMENT_SUB_TYPE_MAP, :ASSIGNMENT_IN_METHOD_SUB_TYPE_MAP
|
|
203
|
+
|
|
201
204
|
def create_assignment_sub_type(lvalue, value)
|
|
202
205
|
lvalue_type, lvalue_value = lvalue
|
|
203
206
|
s(map_assignment_lvalue_type(lvalue_type), lvalue_value, value)
|
|
@@ -215,7 +215,8 @@ module RipperRubyParser
|
|
|
215
215
|
end
|
|
216
216
|
|
|
217
217
|
LVAR_MATCHER = Sexp::Matcher.new(:lvar, Sexp._)
|
|
218
|
-
NUMBERED_PARAMS = (1..9).map { |
|
|
218
|
+
NUMBERED_PARAMS = (1..9).map { |num| :"_#{num}" }.freeze
|
|
219
|
+
private_constant :LVAR_MATCHER, :NUMBERED_PARAMS
|
|
219
220
|
|
|
220
221
|
def make_iter(call, args, stmt)
|
|
221
222
|
args[-1] = nil if args && args.last == s(:excessed_comma)
|
|
@@ -230,7 +231,7 @@ module RipperRubyParser
|
|
|
230
231
|
end
|
|
231
232
|
|
|
232
233
|
def count_numbered_lvars(stmt)
|
|
233
|
-
lvar_names = (LVAR_MATCHER / stmt).map { |
|
|
234
|
+
lvar_names = (LVAR_MATCHER / stmt).map { |match| match[1] }
|
|
234
235
|
(NUMBERED_PARAMS & lvar_names).length
|
|
235
236
|
end
|
|
236
237
|
end
|
|
@@ -139,11 +139,11 @@ module RipperRubyParser
|
|
|
139
139
|
end
|
|
140
140
|
|
|
141
141
|
def merge_raw_string_literals(list)
|
|
142
|
-
chunks = list.chunk { |
|
|
142
|
+
chunks = list.chunk { |lit| lit.sexp_type == :@tstring_content }
|
|
143
143
|
chunks.flat_map do |is_simple, items|
|
|
144
144
|
if is_simple && items.count > 1
|
|
145
145
|
head = items.first
|
|
146
|
-
contents = items.map { |
|
|
146
|
+
contents = items.map { |lit| lit[1] }.join
|
|
147
147
|
[s(:@tstring_content, contents, head[2], head[3])]
|
|
148
148
|
else
|
|
149
149
|
items
|
|
@@ -236,6 +236,12 @@ module RipperRubyParser
|
|
|
236
236
|
NON_INTERPOLATING_WORD_LIST = /^%[wi].$/
|
|
237
237
|
REGEXP_LITERALS = ["/", /^%r.$/].freeze
|
|
238
238
|
|
|
239
|
+
private_constant :INTERPOLATING_HEREDOC, :NON_INTERPOLATING_HEREDOC,
|
|
240
|
+
:INTERPOLATING_STRINGS, :NON_INTERPOLATING_STRINGS,
|
|
241
|
+
:INTERPOLATING_DSYM,
|
|
242
|
+
:INTERPOLATING_WORD_LIST, :NON_INTERPOLATING_WORD_LIST,
|
|
243
|
+
:REGEXP_LITERALS
|
|
244
|
+
|
|
239
245
|
def handle_string_unescaping(content, delim)
|
|
240
246
|
case delim
|
|
241
247
|
when INTERPOLATING_HEREDOC, INTERPOLATING_DSYM, *INTERPOLATING_STRINGS
|
|
@@ -27,8 +27,6 @@ module RipperRubyParser
|
|
|
27
27
|
|
|
28
28
|
@in_method_body = false
|
|
29
29
|
@local_variables = []
|
|
30
|
-
|
|
31
|
-
@kept_comment = nil
|
|
32
30
|
end
|
|
33
31
|
|
|
34
32
|
include SexpHandlers
|
|
@@ -118,14 +116,10 @@ module RipperRubyParser
|
|
|
118
116
|
|
|
119
117
|
def process_comment(exp)
|
|
120
118
|
_, comment, inner = exp.shift 3
|
|
121
|
-
comment = @kept_comment + comment if @kept_comment
|
|
122
|
-
@kept_comment = nil
|
|
123
119
|
sexp = process(inner)
|
|
124
120
|
case sexp.sexp_type
|
|
125
121
|
when :defs, :defn, :module, :class, :sclass
|
|
126
122
|
sexp.comments = comment
|
|
127
|
-
else
|
|
128
|
-
@kept_comment = comment
|
|
129
123
|
end
|
|
130
124
|
sexp
|
|
131
125
|
end
|
|
@@ -183,7 +183,7 @@ module RipperRubyParser
|
|
|
183
183
|
def delimiter_regexp_pattern(delimiter)
|
|
184
184
|
delimiter = delimiter[-1]
|
|
185
185
|
delimiters = DELIMITER_PAIRS.fetch(delimiter, delimiter)
|
|
186
|
-
delimiters.each_char.map { |
|
|
186
|
+
delimiters.each_char.map { |char| Regexp.escape char }.join(" | ")
|
|
187
187
|
end
|
|
188
188
|
end
|
|
189
189
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ripper_ruby_parser
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.12.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matijs van Zuijlen
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: sexp_processor
|
|
@@ -58,20 +57,6 @@ dependencies:
|
|
|
58
57
|
- - ">="
|
|
59
58
|
- !ruby/object:Gem::Version
|
|
60
59
|
version: 1.3.1
|
|
61
|
-
- !ruby/object:Gem::Dependency
|
|
62
|
-
name: pry
|
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
|
64
|
-
requirements:
|
|
65
|
-
- - "~>"
|
|
66
|
-
- !ruby/object:Gem::Version
|
|
67
|
-
version: 0.14.0
|
|
68
|
-
type: :development
|
|
69
|
-
prerelease: false
|
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
71
|
-
requirements:
|
|
72
|
-
- - "~>"
|
|
73
|
-
- !ruby/object:Gem::Version
|
|
74
|
-
version: 0.14.0
|
|
75
60
|
- !ruby/object:Gem::Dependency
|
|
76
61
|
name: rake
|
|
77
62
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -106,70 +91,70 @@ dependencies:
|
|
|
106
91
|
requirements:
|
|
107
92
|
- - "~>"
|
|
108
93
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: '1.
|
|
94
|
+
version: '1.79'
|
|
110
95
|
type: :development
|
|
111
96
|
prerelease: false
|
|
112
97
|
version_requirements: !ruby/object:Gem::Requirement
|
|
113
98
|
requirements:
|
|
114
99
|
- - "~>"
|
|
115
100
|
- !ruby/object:Gem::Version
|
|
116
|
-
version: '1.
|
|
101
|
+
version: '1.79'
|
|
117
102
|
- !ruby/object:Gem::Dependency
|
|
118
103
|
name: rubocop-minitest
|
|
119
104
|
requirement: !ruby/object:Gem::Requirement
|
|
120
105
|
requirements:
|
|
121
106
|
- - "~>"
|
|
122
107
|
- !ruby/object:Gem::Version
|
|
123
|
-
version: 0.
|
|
108
|
+
version: 0.38.0
|
|
124
109
|
type: :development
|
|
125
110
|
prerelease: false
|
|
126
111
|
version_requirements: !ruby/object:Gem::Requirement
|
|
127
112
|
requirements:
|
|
128
113
|
- - "~>"
|
|
129
114
|
- !ruby/object:Gem::Version
|
|
130
|
-
version: 0.
|
|
115
|
+
version: 0.38.0
|
|
131
116
|
- !ruby/object:Gem::Dependency
|
|
132
117
|
name: rubocop-packaging
|
|
133
118
|
requirement: !ruby/object:Gem::Requirement
|
|
134
119
|
requirements:
|
|
135
120
|
- - "~>"
|
|
136
121
|
- !ruby/object:Gem::Version
|
|
137
|
-
version: 0.
|
|
122
|
+
version: 0.6.0
|
|
138
123
|
type: :development
|
|
139
124
|
prerelease: false
|
|
140
125
|
version_requirements: !ruby/object:Gem::Requirement
|
|
141
126
|
requirements:
|
|
142
127
|
- - "~>"
|
|
143
128
|
- !ruby/object:Gem::Version
|
|
144
|
-
version: 0.
|
|
129
|
+
version: 0.6.0
|
|
145
130
|
- !ruby/object:Gem::Dependency
|
|
146
131
|
name: rubocop-performance
|
|
147
132
|
requirement: !ruby/object:Gem::Requirement
|
|
148
133
|
requirements:
|
|
149
134
|
- - "~>"
|
|
150
135
|
- !ruby/object:Gem::Version
|
|
151
|
-
version: '1.
|
|
136
|
+
version: '1.25'
|
|
152
137
|
type: :development
|
|
153
138
|
prerelease: false
|
|
154
139
|
version_requirements: !ruby/object:Gem::Requirement
|
|
155
140
|
requirements:
|
|
156
141
|
- - "~>"
|
|
157
142
|
- !ruby/object:Gem::Version
|
|
158
|
-
version: '1.
|
|
143
|
+
version: '1.25'
|
|
159
144
|
- !ruby/object:Gem::Dependency
|
|
160
145
|
name: ruby_parser
|
|
161
146
|
requirement: !ruby/object:Gem::Requirement
|
|
162
147
|
requirements:
|
|
163
148
|
- - "~>"
|
|
164
149
|
- !ruby/object:Gem::Version
|
|
165
|
-
version: 3.
|
|
150
|
+
version: 3.21.0
|
|
166
151
|
type: :development
|
|
167
152
|
prerelease: false
|
|
168
153
|
version_requirements: !ruby/object:Gem::Requirement
|
|
169
154
|
requirements:
|
|
170
155
|
- - "~>"
|
|
171
156
|
- !ruby/object:Gem::Version
|
|
172
|
-
version: 3.
|
|
157
|
+
version: 3.21.0
|
|
173
158
|
- !ruby/object:Gem::Dependency
|
|
174
159
|
name: sexp_processor
|
|
175
160
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -236,7 +221,6 @@ metadata:
|
|
|
236
221
|
source_code_uri: https://github.com/mvz/ripper_ruby_parser
|
|
237
222
|
changelog_uri: https://github.com/mvz/ripper_ruby_parser/blob/master/CHANGELOG.md
|
|
238
223
|
rubygems_mfa_required: 'true'
|
|
239
|
-
post_install_message:
|
|
240
224
|
rdoc_options:
|
|
241
225
|
- "--main"
|
|
242
226
|
- README.md
|
|
@@ -246,15 +230,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
246
230
|
requirements:
|
|
247
231
|
- - ">="
|
|
248
232
|
- !ruby/object:Gem::Version
|
|
249
|
-
version: 3.
|
|
233
|
+
version: 3.2.0
|
|
250
234
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
251
235
|
requirements:
|
|
252
236
|
- - ">="
|
|
253
237
|
- !ruby/object:Gem::Version
|
|
254
238
|
version: '0'
|
|
255
239
|
requirements: []
|
|
256
|
-
rubygems_version: 3.
|
|
257
|
-
signing_key:
|
|
240
|
+
rubygems_version: 3.7.2
|
|
258
241
|
specification_version: 4
|
|
259
242
|
summary: Parse with Ripper, produce sexps that are compatible with RubyParser.
|
|
260
243
|
test_files: []
|