ruby_parser 3.13.0 → 3.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.autotest +18 -29
- data/History.rdoc +123 -0
- data/Manifest.txt +2 -0
- data/README.rdoc +3 -3
- data/Rakefile +41 -24
- data/bin/ruby_parse +3 -1
- data/bin/ruby_parse_extract_error +18 -35
- data/compare/normalize.rb +43 -3
- data/debugging.md +39 -0
- data/lib/rp_extensions.rb +1 -1
- data/lib/ruby20_parser.rb +3654 -3466
- data/lib/ruby20_parser.y +504 -327
- data/lib/ruby21_parser.rb +3643 -3455
- data/lib/ruby21_parser.y +512 -334
- data/lib/ruby22_parser.rb +3669 -3492
- data/lib/ruby22_parser.y +513 -335
- data/lib/ruby23_parser.rb +3692 -3499
- data/lib/ruby23_parser.y +513 -335
- data/lib/ruby24_parser.rb +3685 -3463
- data/lib/ruby24_parser.y +517 -331
- data/lib/ruby25_parser.rb +3685 -3462
- data/lib/ruby25_parser.y +517 -331
- data/lib/ruby26_parser.rb +3696 -3471
- data/lib/ruby26_parser.y +523 -335
- data/lib/ruby27_parser.rb +7224 -0
- data/lib/ruby27_parser.y +2657 -0
- data/lib/ruby_lexer.rb +611 -495
- data/lib/ruby_lexer.rex +27 -28
- data/lib/ruby_lexer.rex.rb +71 -31
- data/lib/ruby_parser.rb +31 -27
- data/lib/ruby_parser.yy +529 -336
- data/lib/ruby_parser_extras.rb +720 -449
- data/test/test_ruby_lexer.rb +1560 -1412
- data/test/test_ruby_parser.rb +2611 -1912
- data/test/test_ruby_parser_extras.rb +39 -4
- data/tools/munge.rb +12 -6
- data/tools/ripper.rb +19 -3
- metadata +25 -18
- metadata.gz.sig +4 -1
@@ -16,11 +16,11 @@ class TestStackState < Minitest::Test
|
|
16
16
|
p = RubyParser.latest
|
17
17
|
s = nil
|
18
18
|
|
19
|
-
out, err = capture_io
|
19
|
+
out, err = capture_io {
|
20
20
|
s = p.handle_encoding str
|
21
|
-
|
21
|
+
}
|
22
22
|
|
23
|
-
assert_equal orig_str.sub(/\357\273\277/,
|
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 !
|
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
|
data/tools/munge.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/ruby -ws
|
1
|
+
#!/usr/bin/env ruby -ws
|
2
2
|
|
3
3
|
$v ||= false
|
4
4
|
|
@@ -107,6 +107,7 @@ def munge s
|
|
107
107
|
|
108
108
|
'"defined?"', "kDEFINED",
|
109
109
|
|
110
|
+
"<none>", "none",
|
110
111
|
|
111
112
|
'"do (for condition)"', "kDO_COND",
|
112
113
|
'"do (for lambda)"', "kDO_LAMBDA",
|
@@ -117,6 +118,8 @@ def munge s
|
|
117
118
|
|
118
119
|
/@(\d+)(\s+|$)/, "",
|
119
120
|
/\$?@(\d+) */, "", # TODO: remove?
|
121
|
+
|
122
|
+
/_EXPR/, "",
|
120
123
|
]
|
121
124
|
|
122
125
|
renames.each_slice(2) do |(a, b)|
|
@@ -150,7 +153,7 @@ ARGF.each_line do |line|
|
|
150
153
|
next if last_token == token
|
151
154
|
puts "next token is %p (%p)" % [token, last_token]
|
152
155
|
last_token = token
|
153
|
-
when /^Next token is token (
|
156
|
+
when /^Next token is token ("[^"]+"|\S+)/ then
|
154
157
|
token = munge $1
|
155
158
|
next if last_token == token
|
156
159
|
puts "next token is %p (%p)" % [token, last_token]
|
@@ -167,7 +170,7 @@ ARGF.each_line do |line|
|
|
167
170
|
item = $1
|
168
171
|
stack << munge(item)
|
169
172
|
when /^-> \$\$ = (?:token|nterm) (.+) \(.*\)/ then
|
170
|
-
stack << "
|
173
|
+
stack << "none" if stack.empty?
|
171
174
|
item = munge $1
|
172
175
|
x = stack.map { |s| s.strip }.join " "
|
173
176
|
if x != item then # prevent kdef -> kdef
|
@@ -193,10 +196,13 @@ ARGF.each_line do |line|
|
|
193
196
|
# TODO: make pretty, but still informative w/ line numbers etc
|
194
197
|
puts line.gsub("true", "1").gsub("false", "0")
|
195
198
|
when /^lex_state: :?([\w|]+) -> :?([\w|]+)(?: (?:at|from) (.*))?/ then
|
196
|
-
|
197
|
-
|
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}"
|
198
204
|
else
|
199
|
-
puts "lex_state: #{
|
205
|
+
puts "lex_state: #{a} -> #{b}"
|
200
206
|
end
|
201
207
|
when /debug|FUCK/ then
|
202
208
|
puts line.chomp
|
data/tools/ripper.rb
CHANGED
@@ -6,14 +6,30 @@ $p ||= false
|
|
6
6
|
require "ripper/sexp"
|
7
7
|
require "pp" if $p
|
8
8
|
|
9
|
+
if ARGV.empty? then
|
10
|
+
warn "reading from stdin"
|
11
|
+
ARGV << "-"
|
12
|
+
end
|
13
|
+
|
14
|
+
class MySexpBuilder < Ripper::SexpBuilderPP
|
15
|
+
def on_parse_error msg
|
16
|
+
Kernel.warn msg
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
9
20
|
ARGV.each do |path|
|
10
|
-
src = File.read
|
11
|
-
rip =
|
21
|
+
src = path == "-" ? $stdin.read : File.read(path)
|
22
|
+
rip = MySexpBuilder.new src
|
12
23
|
rip.yydebug = $d
|
13
24
|
|
14
25
|
sexp = rip.parse
|
15
26
|
|
16
|
-
|
27
|
+
if rip.error? then
|
28
|
+
warn "skipping"
|
29
|
+
next
|
30
|
+
end
|
31
|
+
|
32
|
+
puts "accept"
|
17
33
|
|
18
34
|
if $p then
|
19
35
|
pp sexp
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -10,9 +10,9 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13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EnQBBK+wAe4Pek8o1V1TTOxL1kGPewVOitX1p3xoN
|
30
|
+
h7iEjga8iM1LbZUfiISZ+WrB
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
32
|
+
date: 2020-09-01 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.
|
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.
|
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).
|
127
|
-
|
128
|
-
|
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,7 +202,9 @@ files:
|
|
200
202
|
homepage: https://github.com/seattlerb/ruby_parser
|
201
203
|
licenses:
|
202
204
|
- MIT
|
203
|
-
metadata:
|
205
|
+
metadata:
|
206
|
+
homepage_uri: https://github.com/seattlerb/ruby_parser
|
207
|
+
bug_tracker_uri: https://github.com/seattlerb/ruby_parser/issues
|
204
208
|
post_install_message:
|
205
209
|
rdoc_options:
|
206
210
|
- "--main"
|
@@ -211,14 +215,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
211
215
|
requirements:
|
212
216
|
- - ">="
|
213
217
|
- !ruby/object:Gem::Version
|
214
|
-
version: '
|
218
|
+
version: '2.1'
|
219
|
+
- - "<"
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '3.1'
|
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.
|
228
|
+
rubygems_version: 3.1.4
|
222
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
|
metadata.gz.sig
CHANGED
@@ -1 +1,4 @@
|
|
1
|
-
|
1
|
+
Y9~��:��
|
2
|
+
X�����-�)4Or[�#���C-�����pZs3W���حg���ۼL}�m�A'�G��ka���%I�N��B�N�>e���:����n�P�Kĉ�'���-�6p�������`��[je2�A���K�p�(<0(�}6E2 ��D��56W��R+���hPՎP�;��� �t�*��1]�.9�f��#=���?cW�pN�ͧ��DM���g�qxj3�!eP!���H��X�/�
|
3
|
+
��
|
4
|
+
�f
|