ruby_parser 3.18.0 → 3.19.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +40 -0
- data/Manifest.txt +2 -0
- data/README.rdoc +8 -6
- data/Rakefile +18 -7
- data/gauntlet.md +19 -18
- data/lib/ruby20_parser.rb +5880 -2029
- data/lib/ruby20_parser.y +23 -30
- data/lib/ruby21_parser.rb +5856 -2052
- data/lib/ruby21_parser.y +23 -30
- data/lib/ruby22_parser.rb +5978 -2077
- data/lib/ruby22_parser.y +23 -30
- data/lib/ruby23_parser.rb +5982 -2081
- data/lib/ruby23_parser.y +23 -30
- data/lib/ruby24_parser.rb +6070 -2101
- data/lib/ruby24_parser.y +23 -30
- data/lib/ruby25_parser.rb +6070 -2101
- data/lib/ruby25_parser.y +23 -30
- data/lib/ruby26_parser.rb +6072 -2100
- data/lib/ruby26_parser.y +23 -30
- data/lib/ruby27_parser.rb +6871 -2402
- data/lib/ruby27_parser.y +28 -44
- data/lib/ruby30_parser.rb +7177 -2676
- data/lib/ruby30_parser.y +77 -93
- data/lib/ruby31_parser.rb +13622 -0
- data/lib/ruby31_parser.y +3481 -0
- data/lib/ruby3_parser.yy +161 -92
- data/lib/ruby_parser.rb +2 -0
- data/lib/ruby_parser.yy +28 -44
- data/lib/ruby_parser_extras.rb +55 -2
- data/test/test_ruby_parser.rb +526 -344
- data.tar.gz.sig +1 -4
- metadata +18 -13
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2901404db3548ad6415060c14df20ae11431fff4a97420659187601a534eb256
|
4
|
+
data.tar.gz: 69705481ccbd6a8ffafbb81c25c40890a4683a19440196a19bbcc119f093612a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a5d89ba1fed1a0a49b5eb71eeb8cc6f80a396d6eaf49bec5742d62cd503916b90136ae689de4fa3a5de180544ba3ef6e8fca03e52bd8349b32c65dfa7962a28
|
7
|
+
data.tar.gz: c68ae86de3cbd9a1b86b6c5acbd0ecc8d809a30c42f7b50217d5038f262a6f61a3baa739332285d59158af9d3c9c3c8d8742e2eca499cf41536f14332e9f7eb9
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,43 @@
|
|
1
|
+
=== 3.19.1 / 2022-04-05
|
2
|
+
|
3
|
+
* 2 bug fixes:
|
4
|
+
|
5
|
+
* Added comments to endless defn and defs. (mvz)
|
6
|
+
* Fixed endless method bug handling attrset names.
|
7
|
+
|
8
|
+
=== 3.19.0 / 2022-03-29
|
9
|
+
|
10
|
+
* 1 major enhancement:
|
11
|
+
|
12
|
+
* Added tentative 3.1 support.
|
13
|
+
|
14
|
+
* 7 minor enhancements:
|
15
|
+
|
16
|
+
* 3.1: bare RHS assoc: { y: } => s(:hash, s(:lit, :y), nil)
|
17
|
+
* 3.1: calls w/ unnamed block args (bare &)
|
18
|
+
* 3.1: endless defn/defs w/ paren-less calls (aka commands)
|
19
|
+
* 3.1: pattern capture to nonlocal vars, eg: ^@a, ^$b, ^@@c
|
20
|
+
* 3.1: pattern: ^(expr) => expr
|
21
|
+
* Improved steps for adding new versions.
|
22
|
+
* Improved steps for running gauntlets.
|
23
|
+
|
24
|
+
* 2 bug fixes:
|
25
|
+
|
26
|
+
* Bumped 2.6+ cached versions for rake compare.
|
27
|
+
* Skip test_regexp_esc_C_slash on ruby 3.1.0 because of MRI bug.
|
28
|
+
|
29
|
+
=== 3.18.1 / 2021-11-10
|
30
|
+
|
31
|
+
* 1 minor enhancement:
|
32
|
+
|
33
|
+
* All parser tests are now explicitly testing line numbers at every level.
|
34
|
+
|
35
|
+
* 3 bug fixes:
|
36
|
+
|
37
|
+
* Fixed endless method with noargs. (mitsuru)
|
38
|
+
* Fixed line numbers on some yield forms.
|
39
|
+
* Handle and clearly report if unifdef is missing.
|
40
|
+
|
1
41
|
=== 3.18.0 / 2021-10-27
|
2
42
|
|
3
43
|
Holy crap... 58 commits! 2.7 and 3.0 are feature complete. Strings
|
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
@@ -33,6 +33,9 @@ Tested against 801,039 files from the latest of all rubygems (as of 2013-05):
|
|
33
33
|
* 1.9 parser is at 99.9940% accuracy, 4.013 sigma
|
34
34
|
* 2.0 parser is at 99.9939% accuracy, 4.008 sigma
|
35
35
|
* 2.6 parser is at 99.9972% accuracy, 4.191 sigma
|
36
|
+
* 3.0 parser has a 100% parse rate.
|
37
|
+
* Tested against 2,672,412 unique ruby files across 167k gems.
|
38
|
+
* As do all the others now, basically.
|
36
39
|
|
37
40
|
== FEATURES/PROBLEMS:
|
38
41
|
|
@@ -62,15 +65,14 @@ You can also use Ruby19Parser, Ruby18Parser, or RubyParser.for_current_ruby:
|
|
62
65
|
|
63
66
|
To add a new version:
|
64
67
|
|
65
|
-
* New parser should be generated from lib/
|
66
|
-
* Extend lib/
|
67
|
-
* Add new version number to V2 in Rakefile for rule creation.
|
68
|
+
* New parser should be generated from lib/ruby[3]_parser.yy.
|
69
|
+
* Extend lib/ruby[3]_parser.yy with new class name.
|
70
|
+
* Add new version number to V2/V3 in Rakefile for rule creation.
|
71
|
+
* Add new (full) version to `ruby_parse` section of Rakefile for rake compare
|
68
72
|
* Require generated parser in lib/ruby_parser.rb.
|
69
73
|
* Add empty TestRubyParserShared##Plus module and TestRubyParserV## to test/test_ruby_parser.rb.
|
70
74
|
* Extend Manifest.txt with generated file names.
|
71
|
-
*
|
72
|
-
* add_19tests needs to have the version added
|
73
|
-
* VER_RE needs to have the regexp expanded
|
75
|
+
* Add new version number to sexp_processor's pt_testcase.rb in all_versions
|
74
76
|
|
75
77
|
Until all of these are done, you won't have a clean test run.
|
76
78
|
|
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ Hoe.add_include_dirs "../../minitest/dev/lib"
|
|
14
14
|
Hoe.add_include_dirs "../../oedipus_lex/dev/lib"
|
15
15
|
|
16
16
|
V2 = %w[20 21 22 23 24 25 26 27]
|
17
|
-
V3 = %w[30]
|
17
|
+
V3 = %w[30 31]
|
18
18
|
|
19
19
|
VERS = V2 + V3
|
20
20
|
|
@@ -75,8 +75,17 @@ def maybe_add_to_top path, string
|
|
75
75
|
File.rename tmp_path, path
|
76
76
|
end
|
77
77
|
|
78
|
+
def unifdef?
|
79
|
+
@unifdef ||= system("which unifdef") or abort <<~EOM
|
80
|
+
unifdef not found!
|
81
|
+
|
82
|
+
Please install 'unifdef' package on your system or `rake generate` on a mac.
|
83
|
+
EOM
|
84
|
+
end
|
85
|
+
|
78
86
|
V2.each do |n|
|
79
87
|
file "lib/ruby#{n}_parser.y" => "lib/ruby_parser.yy" do |t|
|
88
|
+
unifdef?
|
80
89
|
cmd = 'unifdef -tk -DV=%s -UDEAD %s > %s || true' % [n, t.source, t.name]
|
81
90
|
sh cmd
|
82
91
|
end
|
@@ -86,6 +95,7 @@ end
|
|
86
95
|
|
87
96
|
V3.each do |n|
|
88
97
|
file "lib/ruby#{n}_parser.y" => "lib/ruby3_parser.yy" do |t|
|
98
|
+
unifdef?
|
89
99
|
cmd = 'unifdef -tk -DV=%s -UDEAD %s > %s || true' % [n, t.source, t.name]
|
90
100
|
sh cmd
|
91
101
|
end
|
@@ -174,8 +184,8 @@ def ruby_parse version
|
|
174
184
|
|
175
185
|
file c_parse_y => c_tarball do
|
176
186
|
in_compare do
|
177
|
-
extract_glob = case
|
178
|
-
when
|
187
|
+
extract_glob = case
|
188
|
+
when version > "2.7" then
|
179
189
|
"{id.h,parse.y,tool/{id2token.rb,lib/vpath.rb}}"
|
180
190
|
else
|
181
191
|
"{id.h,parse.y,tool/{id2token.rb,vpath.rb}}"
|
@@ -248,7 +258,7 @@ task :versions do
|
|
248
258
|
require "net/http" # avoid require issues in threads
|
249
259
|
require "net/https"
|
250
260
|
|
251
|
-
versions =
|
261
|
+
versions = VERS.map { |s| s.split(//).join "." }
|
252
262
|
|
253
263
|
base_url = "https://cache.ruby-lang.org/pub/ruby"
|
254
264
|
|
@@ -281,9 +291,10 @@ ruby_parse "2.2.10"
|
|
281
291
|
ruby_parse "2.3.8"
|
282
292
|
ruby_parse "2.4.10"
|
283
293
|
ruby_parse "2.5.9"
|
284
|
-
ruby_parse "2.6.
|
285
|
-
ruby_parse "2.7.
|
286
|
-
ruby_parse "3.0.
|
294
|
+
ruby_parse "2.6.9"
|
295
|
+
ruby_parse "2.7.5"
|
296
|
+
ruby_parse "3.0.3"
|
297
|
+
ruby_parse "3.1.1"
|
287
298
|
|
288
299
|
task :debug => :isolate do
|
289
300
|
ENV["V"] ||= VERS.last
|
data/gauntlet.md
CHANGED
@@ -19,10 +19,10 @@ an external disk. Here is the config:
|
|
19
19
|
And I update using rake:
|
20
20
|
|
21
21
|
```
|
22
|
-
% cd
|
22
|
+
% cd GIT/rubygems/rubygems-mirror
|
23
23
|
% git down
|
24
24
|
% rake mirror:latest
|
25
|
-
% /Volumes/StuffA/gauntlet/bin/cleanup.rb
|
25
|
+
% /Volumes/StuffA/gauntlet/bin/cleanup.rb -y -v
|
26
26
|
```
|
27
27
|
|
28
28
|
This rather quickly updates my mirror to the latest versions of
|
@@ -34,22 +34,23 @@ bit, but it is pretty minimal (currently ~20 bad gems).
|
|
34
34
|
## Curating an Archive of Ruby Files
|
35
35
|
|
36
36
|
Next, I process the gem mirror into a much more digestable structure
|
37
|
-
using `
|
37
|
+
using `unpack_gems.rb`.
|
38
38
|
|
39
39
|
```
|
40
|
-
% cd RP
|
41
|
-
% /Volumes/StuffA/gauntlet/bin/unpack_gems.rb
|
40
|
+
% cd RP/gauntlet
|
41
|
+
% time caffeinate /Volumes/StuffA/gauntlet/bin/unpack_gems.rb -v [-a] ; say done
|
42
42
|
... waaaait ...
|
43
|
-
%
|
44
|
-
%
|
45
|
-
%
|
43
|
+
% DIR=gauntlet.$(today).(all|new).noindex
|
44
|
+
% mv hashed.noindex $DIR
|
45
|
+
% tar vc -T <(fd -tf . $DIR | sort) | zstd -5 -T0 --long > archives/$DIR.tar.zst ; say done
|
46
|
+
% ./bin/sync.sh
|
46
47
|
```
|
47
48
|
|
48
|
-
This script filters all the newer gems (
|
49
|
-
finds all the files that look like they're valid
|
50
|
-
valid ruby (using the current version of ruby to
|
51
|
-
then moves them into a SHA dir structure that looks
|
52
|
-
this:
|
49
|
+
This script filters all the newer (< 1 year old) gems (unless `-a` is
|
50
|
+
used), unpacks them, finds all the files that look like they're valid
|
51
|
+
ruby, ensures they're valid ruby (using the current version of ruby to
|
52
|
+
compile them), and then moves them into a SHA dir structure that looks
|
53
|
+
something like this:
|
53
54
|
|
54
55
|
```
|
55
56
|
hashed.noindex/a/b/c/<full_file_sha>.rb
|
@@ -64,8 +65,8 @@ Unpacking, validating, SHA'ing everything is disk and CPU intensive.
|
|
64
65
|
The `.noindex` extension stops spotlight from indexing the continous
|
65
66
|
churn of files being unpacked and moved and saves time.
|
66
67
|
|
67
|
-
Finally, I rename and archive it all up (currently using
|
68
|
-
|
68
|
+
Finally, I rename and archive it all up (currently using zstd to
|
69
|
+
compress).
|
69
70
|
|
70
71
|
### Stats
|
71
72
|
|
@@ -73,7 +74,7 @@ I'm not in love with it).
|
|
73
74
|
9696 % find gauntlet.$(today).noindex -type f | lc
|
74
75
|
561270
|
75
76
|
3.5G gauntlet.2021-08-06.noindex
|
76
|
-
239M gauntlet.2021-08-06.noindex.tar.
|
77
|
+
239M gauntlet.2021-08-06.noindex.tar.zst
|
77
78
|
```
|
78
79
|
|
79
80
|
So I wind up with a little over half a million unique ruby files to
|
@@ -84,7 +85,7 @@ parse. It's about 3.5g but compresses very nicely down to 240m
|
|
84
85
|
Assuming you're starting from scratch, unpack the archive once:
|
85
86
|
|
86
87
|
```
|
87
|
-
%
|
88
|
+
% zstdcat gauntlet.$(today).noindex.tar.zst | tar x
|
88
89
|
```
|
89
90
|
|
90
91
|
Then, either run a single process (easier to read):
|
@@ -96,7 +97,7 @@ Then, either run a single process (easier to read):
|
|
96
97
|
Or max out your machine using xargs (note the `-P 16` and choose accordingly):
|
97
98
|
|
98
99
|
```
|
99
|
-
% ls -d gauntlet/*.noindex/?/? | xargs -n 1 -P 16 ./gauntlet/bin/gauntlet.rb
|
100
|
+
% ls -d gauntlet/*.noindex/?/? | time xargs -n 1 -P 16 ./gauntlet/bin/gauntlet.rb
|
100
101
|
```
|
101
102
|
|
102
103
|
In another terminal I usually monitor the progress like so:
|