ruby_parser 3.13.1 → 3.15.1

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.
@@ -16,11 +16,11 @@ class TestStackState < Minitest::Test
16
16
  p = RubyParser.latest
17
17
  s = nil
18
18
 
19
- out, err = capture_io do
19
+ out, err = capture_io {
20
20
  s = p.handle_encoding str
21
- end
21
+ }
22
22
 
23
- assert_equal orig_str.sub(/\357\273\277/, ''), s
23
+ assert_equal orig_str.sub(/\357\273\277/, ""), s
24
24
 
25
25
  exp_err = ""
26
26
 
@@ -162,7 +162,7 @@ end
162
162
 
163
163
  class TestEnvironment < Minitest::Test
164
164
  def deny t
165
- assert ! t
165
+ assert !t
166
166
  end
167
167
 
168
168
  def setup
@@ -224,3 +224,38 @@ class TestEnvironment < Minitest::Test
224
224
  assert_equal expected0, @env.all
225
225
  end
226
226
  end
227
+
228
+ class Fake20
229
+ include RubyParserStuff
230
+
231
+ def initialize
232
+ end
233
+
234
+ def s(*a) # bypass lexer/lineno stuff that RP overrides in
235
+ Kernel.send :s, *a
236
+ end
237
+ end
238
+
239
+ class TestValueExpr < Minitest::Test
240
+ def assert_value_expr exp, input
241
+ assert_equal exp, Fake20.new.value_expr(input.line(1))
242
+ end
243
+
244
+ def assert_remove_begin exp, input
245
+ assert_equal exp, Fake20.new.remove_begin(input.line(1))
246
+ end
247
+
248
+ def test_value_expr
249
+ assert_value_expr s(:nil), s(:begin)
250
+ assert_value_expr s(:nil), s(:begin, s(:nil))
251
+ assert_value_expr s(:nil), s(:begin, s(:begin, s(:nil)))
252
+ assert_value_expr s(:begin, s(:nil), s(:nil)), s(:begin, s(:nil), s(:nil))
253
+ end
254
+
255
+ def test_remove_begin
256
+ assert_remove_begin s(:nil), s(:begin)
257
+ assert_remove_begin s(:nil), s(:begin, s(:nil))
258
+ assert_remove_begin s(:nil), s(:begin, s(:begin, s(:nil)))
259
+ assert_remove_begin s(:begin, s(:nil), s(:nil)), s(:begin, s(:nil), s(:nil))
260
+ end
261
+ end
@@ -1,4 +1,4 @@
1
- #!/usr/bin/ruby -ws
1
+ #!/usr/bin/env ruby -ws
2
2
 
3
3
  $v ||= false
4
4
 
@@ -118,6 +118,8 @@ def munge s
118
118
 
119
119
  /@(\d+)(\s+|$)/, "",
120
120
  /\$?@(\d+) */, "", # TODO: remove?
121
+
122
+ /_EXPR/, "",
121
123
  ]
122
124
 
123
125
  renames.each_slice(2) do |(a, b)|
@@ -151,7 +153,7 @@ ARGF.each_line do |line|
151
153
  next if last_token == token
152
154
  puts "next token is %p (%p)" % [token, last_token]
153
155
  last_token = token
154
- when /^Next token is token (\S+)/ then
156
+ when /^Next token is token ("[^"]+"|\S+)/ then
155
157
  token = munge $1
156
158
  next if last_token == token
157
159
  puts "next token is %p (%p)" % [token, last_token]
@@ -194,10 +196,13 @@ ARGF.each_line do |line|
194
196
  # TODO: make pretty, but still informative w/ line numbers etc
195
197
  puts line.gsub("true", "1").gsub("false", "0")
196
198
  when /^lex_state: :?([\w|]+) -> :?([\w|]+)(?: (?:at|from) (.*))?/ then
197
- if $3 && $v then
198
- puts "lex_state: #{$1.upcase} -> #{$2.upcase} at #{$3}"
199
+ a, b, c = $1.upcase, $2.upcase, $3
200
+ a.gsub! /EXPR_/, ""
201
+ b.gsub! /EXPR_/, ""
202
+ if c && $v then
203
+ puts "lex_state: #{a} -> #{b} at #{c}"
199
204
  else
200
- puts "lex_state: #{$1.upcase} -> #{$2.upcase}"
205
+ puts "lex_state: #{a} -> #{b}"
201
206
  end
202
207
  when /debug|FUCK/ then
203
208
  puts line.chomp
@@ -11,14 +11,25 @@ if ARGV.empty? then
11
11
  ARGV << "-"
12
12
  end
13
13
 
14
+ class MySexpBuilder < Ripper::SexpBuilderPP
15
+ def on_parse_error msg
16
+ Kernel.warn msg
17
+ end
18
+ end
19
+
14
20
  ARGV.each do |path|
15
21
  src = path == "-" ? $stdin.read : File.read(path)
16
- rip = Ripper::SexpBuilderPP.new src
22
+ rip = MySexpBuilder.new src
17
23
  rip.yydebug = $d
18
24
 
19
25
  sexp = rip.parse
20
26
 
21
- puts "accept" unless rip.error?
27
+ if rip.error? then
28
+ warn "skipping"
29
+ next
30
+ end
31
+
32
+ puts "accept"
22
33
 
23
34
  if $p then
24
35
  pp sexp
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.13.1
4
+ version: 3.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBAzANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
13
+ MIIDPjCCAiagAwIBAgIBBTANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
14
14
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
- GRYDY29tMB4XDTE4MTIwNDIxMzAxNFoXDTE5MTIwNDIxMzAxNFowRTETMBEGA1UE
15
+ GRYDY29tMB4XDTIwMTIyMjIwMzgzMFoXDTIxMTIyMjIwMzgzMFowRTETMBEGA1UE
16
16
  AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
17
17
  JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
18
18
  b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
@@ -22,14 +22,14 @@ cert_chain:
22
22
  qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
23
23
  gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
24
24
  HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
25
- AQCbJwLmpJR2PomLU+Zzw3KRzH/hbyUWc/ftru71AopZ1fy4iY9J/BW5QYKVYwbP
26
- V0FSBWtvfI/RdwfKGtuGhPKECZgmLieGuZ3XCc09qPu1bdg7i/tu1p0t0c6163ku
27
- nDMDIC/t/DAFK0TY9I3HswuyZGbLW7rgF0DmiuZdN/RPhHq2pOLMLXJmFclCb/im
28
- 9yToml/06TJdUJ5p64mkBs0TzaK66DIB1Smd3PdtfZqoRV+EwaXMdx0Hb3zdR1JR
29
- Em82dBUFsipwMLCYj39kcyHWAxyl6Ae1Cn9r/ItVBCxoeFdrHjfavnrIEoXUt4bU
30
- UfBugfLD19bu3nvL+zTAGx/U
25
+ AQAE3XRm1YZcCVjAJy5yMZvTOFrS7B2SYErc+0QwmKYbHztTTDY2m5Bii+jhpuxh
26
+ H+ETcU1z8TUKLpsBUP4kUpIRowkVN1p/jKapV8T3Rbwq+VuYFe+GMKsf8wGZSecG
27
+ oMQ8DzzauZfbvhe2kDg7G9BBPU0wLQlY25rDcCy9bLnD7R0UK3ONqpwvsI5I7x5X
28
+ ZIMXR0a9/DG+55mawwdGzCQobDKiSNLK89KK7OcNTALKU0DfgdTkktdgKchzKHqZ
29
+ d/AHw/kcnU6iuMUoJEcGiJd4gVCTn1l3cDcIvxakGslCA88Jubw0Sqatan0TnC9g
30
+ KToW560QIey7SPfHWduzFJnV
31
31
  -----END CERTIFICATE-----
32
- date: 2019-03-26 00:00:00.000000000 Z
32
+ date: 2021-01-11 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: sexp_processor
@@ -113,19 +113,19 @@ dependencies:
113
113
  requirements:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: '3.17'
116
+ version: '3.22'
117
117
  type: :development
118
118
  prerelease: false
119
119
  version_requirements: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: '3.17'
123
+ version: '3.22'
124
124
  description: |-
125
125
  ruby_parser (RP) is a ruby parser written in pure ruby (utilizing
126
- racc--which does by default use a C extension). RP's output is
127
- the same as ParseTree's output: s-expressions using ruby's arrays and
128
- base types.
126
+ racc--which does by default use a C extension). It outputs
127
+ s-expressions which can be manipulated and converted back to ruby via
128
+ the ruby2ruby gem.
129
129
 
130
130
  As an example:
131
131
 
@@ -186,6 +186,8 @@ files:
186
186
  - lib/ruby25_parser.y
187
187
  - lib/ruby26_parser.rb
188
188
  - lib/ruby26_parser.y
189
+ - lib/ruby27_parser.rb
190
+ - lib/ruby27_parser.y
189
191
  - lib/ruby_lexer.rb
190
192
  - lib/ruby_lexer.rex
191
193
  - lib/ruby_lexer.rex.rb
@@ -200,8 +202,10 @@ files:
200
202
  homepage: https://github.com/seattlerb/ruby_parser
201
203
  licenses:
202
204
  - MIT
203
- metadata: {}
204
- post_install_message:
205
+ metadata:
206
+ homepage_uri: https://github.com/seattlerb/ruby_parser
207
+ bug_tracker_uri: https://github.com/seattlerb/ruby_parser/issues
208
+ post_install_message:
205
209
  rdoc_options:
206
210
  - "--main"
207
211
  - README.rdoc
@@ -211,15 +215,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
211
215
  requirements:
212
216
  - - ">="
213
217
  - !ruby/object:Gem::Version
214
- version: '0'
218
+ version: '2.1'
219
+ - - "<"
220
+ - !ruby/object:Gem::Version
221
+ version: '4'
215
222
  required_rubygems_version: !ruby/object:Gem::Requirement
216
223
  requirements:
217
224
  - - ">="
218
225
  - !ruby/object:Gem::Version
219
226
  version: '0'
220
227
  requirements: []
221
- rubygems_version: 3.0.2
222
- signing_key:
228
+ rubygems_version: 3.1.4
229
+ signing_key:
223
230
  specification_version: 4
224
231
  summary: ruby_parser (RP) is a ruby parser written in pure ruby (utilizing racc--which
225
232
  does by default use a C extension)
metadata.gz.sig CHANGED
Binary file