ruby_parser 3.20.3 → 3.21.1
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/History.rdoc +38 -0
- data/Manifest.txt +14 -24
- data/README.rdoc +3 -3
- data/Rakefile +113 -115
- data/compare/normalize.rb +2 -0
- data/lib/ruby_lexer.rb +9 -16
- data/lib/ruby_lexer.rex.rb +1 -2
- data/lib/ruby_parser.rb +15 -13
- data/lib/{ruby_parser.yy → ruby_parser2.yy} +3 -10
- data/lib/{ruby20_parser.rb → ruby_parser20.rb} +9 -12
- data/lib/{ruby21_parser.rb → ruby_parser21.rb} +9 -12
- data/lib/{ruby22_parser.rb → ruby_parser22.rb} +9 -12
- data/lib/{ruby23_parser.rb → ruby_parser23.rb} +9 -12
- data/lib/{ruby24_parser.rb → ruby_parser24.rb} +9 -12
- data/lib/{ruby25_parser.rb → ruby_parser25.rb} +9 -12
- data/lib/{ruby26_parser.rb → ruby_parser26.rb} +9 -12
- data/lib/{ruby27_parser.rb → ruby_parser27.rb} +9 -12
- data/lib/{ruby3_parser.yy → ruby_parser3.yy} +7 -33
- data/lib/{ruby30_parser.rb → ruby_parser30.rb} +11 -35
- data/lib/{ruby31_parser.rb → ruby_parser31.rb} +11 -35
- data/lib/{ruby32_parser.rb → ruby_parser32.rb} +11 -35
- data/lib/ruby_parser33.rb +13577 -0
- data/lib/ruby_parser_extras.rb +35 -17
- data/test/test_ruby_lexer.rb +5 -5
- data/test/test_ruby_parser.rb +22 -20
- data.tar.gz.sig +0 -0
- metadata +41 -51
- metadata.gz.sig +0 -0
- data/lib/ruby20_parser.y +0 -2707
- data/lib/ruby21_parser.y +0 -2724
- data/lib/ruby22_parser.y +0 -2735
- data/lib/ruby23_parser.y +0 -2737
- data/lib/ruby24_parser.y +0 -2745
- data/lib/ruby25_parser.y +0 -2745
- data/lib/ruby26_parser.y +0 -2760
- data/lib/ruby27_parser.y +0 -3360
- data/lib/ruby30_parser.y +0 -3508
- data/lib/ruby31_parser.y +0 -3542
- data/lib/ruby32_parser.y +0 -3543
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0b41ca88f3f31d39c43cf26e8ce115b9e3207ec8154715b6cc1daebcce4068c
|
4
|
+
data.tar.gz: f2f175619f399a717112e921562b3e0dede90fcef89988a45ea673c97aa4e208
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c387b27b007b9516813e12aefcb66545250b606dddfe3eeb940c9301ff02e0561edc7325a855fe0cc1eb9f5b98b09d80d44862956d68e321ad7cb1170b6865e
|
7
|
+
data.tar.gz: 5d037adb3906afb8ffbf58ba2980c6531cc9de15753c7d6229f605aa09f13c42ab5367ef2aba936ad702a510251d32956dfcde48b5614a4277d3cfa38b780b95
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,41 @@
|
|
1
|
+
=== 3.21.1 / 2024-07-09
|
2
|
+
|
3
|
+
* 1 bug fix:
|
4
|
+
|
5
|
+
* Fix errors created when string literals are frozen.
|
6
|
+
|
7
|
+
=== 3.21.0 / 2024-01-15
|
8
|
+
|
9
|
+
* 18 minor enhancements:
|
10
|
+
|
11
|
+
* (internal) Added simple RubyLexer#comment.
|
12
|
+
* (internal) Removed RubyLexer#comments and #ignore_body_comments.
|
13
|
+
* (internal) Removed RubyParser#comments.
|
14
|
+
* (internal) Renamed files from lib/ruby##_parser.* to lib/ruby_parser##.*
|
15
|
+
* (internal) Renamed lib/ruby3_parser.yy to lib/ruby_parser3.yy
|
16
|
+
* (internal) Renamed lib/ruby_parser.yy to lib/ruby_parser2.yy
|
17
|
+
* Added tentative 3.2 support. (torrocus)
|
18
|
+
* Made `rake compare` a multitask (28s -> 10s!!).
|
19
|
+
* Made `rake compare` depend on `generate` (from clean: 28s -> 18s).
|
20
|
+
* No longer package versioned .y files.
|
21
|
+
* Overhaul of parser/lexer comment processing.
|
22
|
+
* Parser productions for k_class/k_module/k_def carry their comment with them.
|
23
|
+
* Restructured build tasks to utilize Hoe's .yy support! 8.5s -> 1.2s!!!
|
24
|
+
* RubyParser new_(class|module|defn|defs) handle comment processing via sexp.
|
25
|
+
* RubyParser new_(class|module|defn|defs) handle normalizing production sexps.
|
26
|
+
* RubyParser#next_token clears out lexer's comment when applicable.
|
27
|
+
* Simplified parser productions for defn_head, defs_head. No more normalizing.
|
28
|
+
* Updated `rake compare` steps for lrama in ruby 3.3+.
|
29
|
+
|
30
|
+
* 6 bug fixes:
|
31
|
+
|
32
|
+
* Cleaned out cruft from `rake compare` code.
|
33
|
+
* Fixed compare/normalize.rb for lrama differences.
|
34
|
+
* Made `parser` task depend on `isolate` task to pick up racc generator.
|
35
|
+
* Made racc a runtime dependency (was dev only) now that ruby 3.3 doesn't ship with the racc runtime. (wildmaples)
|
36
|
+
* Updated README.rdoc updating instructions to match current filenames.
|
37
|
+
* Updated compare versions and added 3.3.
|
38
|
+
|
1
39
|
=== 3.20.3 / 2023-07-11
|
2
40
|
|
3
41
|
* 2 minor enhancements:
|
data/Manifest.txt
CHANGED
@@ -11,35 +11,25 @@ gauntlet.md
|
|
11
11
|
lib/.document
|
12
12
|
lib/rp_extensions.rb
|
13
13
|
lib/rp_stringscanner.rb
|
14
|
-
lib/ruby20_parser.rb
|
15
|
-
lib/ruby20_parser.y
|
16
|
-
lib/ruby21_parser.rb
|
17
|
-
lib/ruby21_parser.y
|
18
|
-
lib/ruby22_parser.rb
|
19
|
-
lib/ruby22_parser.y
|
20
|
-
lib/ruby23_parser.rb
|
21
|
-
lib/ruby23_parser.y
|
22
|
-
lib/ruby24_parser.rb
|
23
|
-
lib/ruby24_parser.y
|
24
|
-
lib/ruby25_parser.rb
|
25
|
-
lib/ruby25_parser.y
|
26
|
-
lib/ruby26_parser.rb
|
27
|
-
lib/ruby26_parser.y
|
28
|
-
lib/ruby27_parser.rb
|
29
|
-
lib/ruby27_parser.y
|
30
|
-
lib/ruby30_parser.rb
|
31
|
-
lib/ruby30_parser.y
|
32
|
-
lib/ruby31_parser.rb
|
33
|
-
lib/ruby31_parser.y
|
34
|
-
lib/ruby32_parser.rb
|
35
|
-
lib/ruby32_parser.y
|
36
|
-
lib/ruby3_parser.yy
|
37
14
|
lib/ruby_lexer.rb
|
38
15
|
lib/ruby_lexer.rex
|
39
16
|
lib/ruby_lexer.rex.rb
|
40
17
|
lib/ruby_lexer_strings.rb
|
41
18
|
lib/ruby_parser.rb
|
42
|
-
lib/
|
19
|
+
lib/ruby_parser2.yy
|
20
|
+
lib/ruby_parser20.rb
|
21
|
+
lib/ruby_parser21.rb
|
22
|
+
lib/ruby_parser22.rb
|
23
|
+
lib/ruby_parser23.rb
|
24
|
+
lib/ruby_parser24.rb
|
25
|
+
lib/ruby_parser25.rb
|
26
|
+
lib/ruby_parser26.rb
|
27
|
+
lib/ruby_parser27.rb
|
28
|
+
lib/ruby_parser3.yy
|
29
|
+
lib/ruby_parser30.rb
|
30
|
+
lib/ruby_parser31.rb
|
31
|
+
lib/ruby_parser32.rb
|
32
|
+
lib/ruby_parser33.rb
|
43
33
|
lib/ruby_parser_extras.rb
|
44
34
|
test/test_ruby_lexer.rb
|
45
35
|
test/test_ruby_parser.rb
|
data/README.rdoc
CHANGED
@@ -65,15 +65,15 @@ You can also use Ruby19Parser, Ruby18Parser, or RubyParser.for_current_ruby:
|
|
65
65
|
|
66
66
|
To add a new version:
|
67
67
|
|
68
|
-
* New parser should be generated from lib/
|
69
|
-
* Extend lib/
|
68
|
+
* New parser should be generated from lib/ruby_parser[23].yy.
|
69
|
+
* Extend lib/ruby_parser[23].yy with new class name.
|
70
70
|
* Add new version number to V2/V3 in Rakefile for rule creation.
|
71
71
|
* Add new `ruby_parse "x.y.z"` line to Rakefile for rake compare (line ~300).
|
72
72
|
* Require generated parser in lib/ruby_parser.rb.
|
73
73
|
* Add new V## = ::Ruby##Parser; end to ruby_parser.rb (bottom of file).
|
74
74
|
* Add empty TestRubyParserShared##Plus module and TestRubyParserV## to test/test_ruby_parser.rb.
|
75
75
|
* Extend Manifest.txt with generated file names.
|
76
|
-
* Add new version number to sexp_processor's pt_testcase.rb in all_versions
|
76
|
+
* Add new version number to sexp_processor's pt_testcase.rb in all_versions.
|
77
77
|
|
78
78
|
Until all of these are done, you won't have a clean test run.
|
79
79
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
|
3
|
-
require "rubygems"
|
4
3
|
require "hoe"
|
5
4
|
|
6
5
|
Hoe.plugin :seattlerb
|
@@ -15,38 +14,34 @@ Hoe.add_include_dirs "../../oedipus_lex/dev/lib"
|
|
15
14
|
Hoe.add_include_dirs "../../ruby2ruby/dev/lib"
|
16
15
|
|
17
16
|
V2 = %w[20 21 22 23 24 25 26 27]
|
18
|
-
V3 = %w[30 31 32]
|
17
|
+
V3 = %w[30 31 32 33]
|
19
18
|
|
20
19
|
VERS = V2 + V3
|
21
20
|
|
22
21
|
ENV["FAST"] = VERS.last if ENV["FAST"] && !VERS.include?(ENV["FAST"])
|
23
22
|
VERS.replace [ENV["FAST"]] if ENV["FAST"]
|
24
23
|
|
24
|
+
racc_flags = nil
|
25
|
+
|
25
26
|
Hoe.spec "ruby_parser" do
|
26
27
|
developer "Ryan Davis", "ryand-ruby@zenspider.com"
|
27
28
|
|
28
29
|
license "MIT"
|
29
30
|
|
30
|
-
dependency "sexp_processor", "~>
|
31
|
-
dependency "
|
32
|
-
dependency "
|
33
|
-
|
34
|
-
# NOTE: Ryan!!! Stop trying to fix this dependency! Isolate just
|
35
|
-
# can't handle having a faux-gem half-installed! Stop! Just `gem
|
36
|
-
# install racc` and move on. Revisit this ONLY once racc-compiler
|
37
|
-
# gets split out.
|
38
|
-
|
39
|
-
dependency "racc", "~> 1.5", :developer
|
31
|
+
dependency "sexp_processor", "~> 4.16"
|
32
|
+
dependency "racc", "~> 1.5"
|
33
|
+
dependency "rake", [">= 10", "< 15"], :developer
|
34
|
+
dependency "oedipus_lex", "~> 2.6", :developer
|
40
35
|
|
41
36
|
require_ruby_version [">= 2.6", "< 4"]
|
42
37
|
|
43
38
|
if plugin? :perforce then # generated files
|
44
39
|
VERS.each do |n|
|
45
|
-
self.perforce_ignore << "lib/
|
40
|
+
self.perforce_ignore << "lib/ruby_parser#{n}.rb"
|
46
41
|
end
|
47
42
|
|
48
43
|
VERS.each do |n|
|
49
|
-
self.perforce_ignore << "lib/
|
44
|
+
self.perforce_ignore << "lib/ruby_parser#{n}.y"
|
50
45
|
end
|
51
46
|
|
52
47
|
self.perforce_ignore << "lib/ruby_lexer.rex.rb"
|
@@ -55,7 +50,7 @@ Hoe.spec "ruby_parser" do
|
|
55
50
|
if plugin?(:racc)
|
56
51
|
self.racc_flags << " -t" if ENV["DEBUG"]
|
57
52
|
self.racc_flags << " --superclass RubyParser::Parser"
|
58
|
-
|
53
|
+
racc_flags = self.racc_flags
|
59
54
|
end
|
60
55
|
end
|
61
56
|
|
@@ -84,34 +79,30 @@ def unifdef?
|
|
84
79
|
EOM
|
85
80
|
end
|
86
81
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end
|
82
|
+
def racc?
|
83
|
+
@racc ||= system("which racc") or abort <<~EOM
|
84
|
+
racc not found! `gem install racc`
|
85
|
+
EOM
|
86
|
+
end
|
93
87
|
|
94
|
-
|
88
|
+
generate_parser = proc do |t|
|
89
|
+
unifdef?
|
90
|
+
racc?
|
91
|
+
n = t.name[/\d+/]
|
92
|
+
sh "unifdef -tk -DV=%s %s | racc %s /dev/stdin -o %s" % [n, t.source, racc_flags, t.name]
|
93
|
+
maybe_add_to_top t.name, "# frozen_string_literal: true"
|
95
94
|
end
|
96
95
|
|
97
|
-
|
98
|
-
file "lib/
|
99
|
-
|
100
|
-
cmd = 'unifdef -tk -DV=%s -UDEAD %s > %s || true' % [n, t.source, t.name]
|
101
|
-
sh cmd
|
102
|
-
end
|
96
|
+
V2.each do |n|
|
97
|
+
file "lib/ruby_parser#{n}.rb" => "lib/ruby_parser2.yy", &generate_parser
|
98
|
+
end
|
103
99
|
|
104
|
-
|
100
|
+
V3.each do |n|
|
101
|
+
file "lib/ruby_parser#{n}.rb" => "lib/ruby_parser3.yy", &generate_parser
|
105
102
|
end
|
106
103
|
|
107
104
|
file "lib/ruby_lexer.rex.rb" => "lib/ruby_lexer.rex"
|
108
105
|
|
109
|
-
task :parser do |t|
|
110
|
-
t.prerequisite_tasks.grep(Rake::FileTask).select(&:already_invoked).each do |f|
|
111
|
-
maybe_add_to_top f.name, "# frozen_string_literal: true"
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
106
|
task :generate => [:lexer, :parser]
|
116
107
|
|
117
108
|
task :clean do
|
@@ -119,8 +110,8 @@ task :clean do
|
|
119
110
|
Dir["diff.diff"] + # not all diffs. bit me too many times
|
120
111
|
Dir["coverage.info"] +
|
121
112
|
Dir["coverage"] +
|
122
|
-
Dir["lib/
|
123
|
-
Dir["lib/
|
113
|
+
Dir["lib/ruby_parser2*.y"] +
|
114
|
+
Dir["lib/ruby_parser3*.y"] +
|
124
115
|
Dir["lib/*.output"])
|
125
116
|
end
|
126
117
|
|
@@ -140,74 +131,78 @@ end
|
|
140
131
|
|
141
132
|
task :isolate => :phony
|
142
133
|
|
143
|
-
def
|
144
|
-
Dir.chdir "compare" do
|
145
|
-
yield
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def dl v
|
134
|
+
def dl v, f
|
150
135
|
dir = v[/^\d+\.\d+/]
|
151
136
|
url = "https://cache.ruby-lang.org/pub/ruby/#{dir}/ruby-#{v}.tar.xz"
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
end
|
137
|
+
|
138
|
+
warn "Downloading ruby #{v}"
|
139
|
+
system "curl -s -o #{f} #{url}"
|
156
140
|
end
|
157
141
|
|
142
|
+
task :parser => :isolate
|
143
|
+
|
144
|
+
multitask :compare_build
|
145
|
+
task :compare_build => :generate
|
146
|
+
task :compare => :compare_build
|
147
|
+
|
158
148
|
def ruby_parse version
|
159
149
|
v = version[/^\d+\.\d+/].delete "."
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
rp_out = "lib/
|
167
|
-
|
168
|
-
rp_y_rb = "lib/ruby#{v}_parser.rb"
|
169
|
-
|
170
|
-
c_diff = "compare/#{diff}"
|
171
|
-
c_rp_txt = "compare/#{rp_txt}"
|
172
|
-
c_mri_txt = "compare/#{mri_txt}"
|
173
|
-
c_parse_y = "compare/#{parse_y}"
|
174
|
-
c_tarball = "compare/#{tarball}"
|
150
|
+
diff = "compare/diff#{v}.diff"
|
151
|
+
rp_txt = "compare/rp#{v}.txt"
|
152
|
+
mri_txt = "compare/mri#{v}.txt"
|
153
|
+
parse_y = "compare/parse#{v}.y"
|
154
|
+
tarball = "compare/ruby-#{version}.tar.xz"
|
155
|
+
ruby_dir = "compare/ruby-#{version}"
|
156
|
+
rp_out = "lib/ruby_parser#{v}.output"
|
157
|
+
rp_y_rb = "lib/ruby_parser#{v}.rb"
|
175
158
|
normalize = "compare/normalize.rb"
|
176
159
|
|
177
|
-
file
|
178
|
-
|
179
|
-
dl version
|
180
|
-
end
|
160
|
+
file tarball do
|
161
|
+
dl version, tarball
|
181
162
|
end
|
182
163
|
|
183
164
|
desc "fetch all tarballs"
|
184
|
-
task :fetch =>
|
185
|
-
|
186
|
-
file
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
165
|
+
task :fetch => tarball
|
166
|
+
|
167
|
+
file parse_y => tarball do
|
168
|
+
extract_glob = case
|
169
|
+
when version > "3.3" then
|
170
|
+
"{id.h,parse.y,tool/{id2token.rb,lrama},defs/id.def}"
|
171
|
+
when version > "3.2" then
|
172
|
+
"{id.h,parse.y,tool/id2token.rb,defs/id.def}"
|
173
|
+
when version > "2.7" then
|
174
|
+
"{id.h,parse.y,tool/{id2token.rb,lib/vpath.rb}}"
|
175
|
+
else
|
176
|
+
"{id.h,parse.y,tool/{id2token.rb,vpath.rb}}"
|
177
|
+
end
|
178
|
+
system "tar xf #{tarball} -C compare #{File.basename ruby_dir}/#{extract_glob}"
|
179
|
+
|
180
|
+
# Debugging a new parse build system:
|
181
|
+
#
|
182
|
+
# Unpack the ruby tarball in question, configure, and run the following:
|
183
|
+
#
|
184
|
+
# % touch parse.y; make -n parse.c
|
185
|
+
# ...
|
186
|
+
# echo generating parse.c
|
187
|
+
# /Users/ryan/.rubies.current/bin/ruby --disable=gems ./tool/id2token.rb parse.y | \
|
188
|
+
# ruby ./tool/lrama/exe/lrama -oparse.c -Hparse.h - parse.y
|
189
|
+
#
|
190
|
+
# Then integrate these commands into the mess below:
|
191
|
+
|
192
|
+
d = ruby_dir
|
193
|
+
cmd = if version > "3.2" then
|
194
|
+
"ruby #{d}/tool/id2token.rb #{d}/parse.y | expand > #{parse_y}"
|
195
|
+
else
|
196
|
+
"ruby #{d}/tool/id2token.rb --path-separator=.:./ #{d}/id.h #{d}/parse.y | expand | ruby -pe 'gsub(/^%pure-parser/, \"%define api.pure\")' > #{parse_y}"
|
197
|
+
end
|
198
|
+
|
199
|
+
sh cmd
|
200
|
+
|
201
|
+
if File.exist? "#{d}/tool/lrama" then # UGH: this is dumb
|
202
|
+
rm_rf "compare/lrama"
|
203
|
+
sh "mv #{d}/tool/lrama compare"
|
210
204
|
end
|
205
|
+
sh "rm -rf #{d}"
|
211
206
|
end
|
212
207
|
|
213
208
|
bison = Dir["/opt/homebrew/opt/bison/bin/bison",
|
@@ -215,46 +210,48 @@ def ruby_parse version
|
|
215
210
|
`which bison`.chomp,
|
216
211
|
].first
|
217
212
|
|
218
|
-
file
|
219
|
-
|
213
|
+
file mri_txt => [parse_y, normalize] do
|
214
|
+
if version > "3.3" then
|
215
|
+
sh "./compare/lrama/exe/lrama -r all -ocompare/parse#{v}.tab.c #{parse_y}"
|
216
|
+
else
|
220
217
|
sh "#{bison} -r all #{parse_y}"
|
221
|
-
|
222
|
-
rm ["parse#{v}.output", "parse#{v}.tab.c"]
|
218
|
+
mv Dir["parse#{v}.*"], "compare"
|
223
219
|
end
|
220
|
+
|
221
|
+
sh "#{normalize} compare/parse#{v}.output > #{mri_txt}"
|
222
|
+
rm ["compare/parse#{v}.output", "compare/parse#{v}.tab.c"]
|
224
223
|
end
|
225
224
|
|
226
225
|
file rp_out => rp_y_rb
|
227
226
|
|
228
|
-
file
|
229
|
-
|
230
|
-
sh "./normalize.rb ../#{rp_out} > #{rp_txt}"
|
231
|
-
end
|
227
|
+
file rp_txt => [rp_out, normalize] do
|
228
|
+
sh "#{normalize} #{rp_out} > #{rp_txt}"
|
232
229
|
end
|
233
230
|
|
234
231
|
compare = "compare#{v}"
|
232
|
+
compare_build = "compare_build#{v}"
|
235
233
|
|
236
234
|
desc "Compare all grammars to MRI"
|
237
235
|
task :compare => compare
|
236
|
+
task :compare_build => compare_build
|
238
237
|
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
238
|
+
task compare_build => diff
|
239
|
+
|
240
|
+
file diff => [mri_txt, rp_txt] do
|
241
|
+
sh "diff -du #{mri_txt} #{rp_txt} > #{diff}; true"
|
243
242
|
end
|
244
243
|
|
245
244
|
desc "Compare #{v} grammar to MRI #{version}"
|
246
|
-
task compare =>
|
247
|
-
|
248
|
-
system "wc -l #{diff}"
|
249
|
-
end
|
245
|
+
task compare => diff do
|
246
|
+
system "wc -l #{diff}"
|
250
247
|
end
|
251
248
|
|
252
249
|
task :clean do
|
253
|
-
rm_f Dir[
|
250
|
+
rm_f Dir[mri_txt, rp_txt]
|
254
251
|
end
|
255
252
|
|
256
253
|
task :realclean do
|
257
|
-
rm_f Dir[
|
254
|
+
rm_f Dir[parse_y, tarball]
|
258
255
|
end
|
259
256
|
end
|
260
257
|
|
@@ -297,10 +294,11 @@ ruby_parse "2.3.8"
|
|
297
294
|
ruby_parse "2.4.10"
|
298
295
|
ruby_parse "2.5.9"
|
299
296
|
ruby_parse "2.6.10"
|
300
|
-
ruby_parse "2.7.
|
301
|
-
ruby_parse "3.0.
|
302
|
-
ruby_parse "3.1.
|
303
|
-
ruby_parse "3.2.
|
297
|
+
ruby_parse "2.7.8"
|
298
|
+
ruby_parse "3.0.6"
|
299
|
+
ruby_parse "3.1.4"
|
300
|
+
ruby_parse "3.2.2"
|
301
|
+
ruby_parse "3.3.0"
|
304
302
|
|
305
303
|
task :debug => :isolate do
|
306
304
|
ENV["V"] ||= VERS.last
|
data/compare/normalize.rb
CHANGED
data/lib/ruby_lexer.rb
CHANGED
@@ -113,7 +113,8 @@ class RubyLexer
|
|
113
113
|
# Last token read via next_token.
|
114
114
|
attr_accessor :token
|
115
115
|
|
116
|
-
|
116
|
+
# Last comment lexed, or nil
|
117
|
+
attr_accessor :comment
|
117
118
|
|
118
119
|
def initialize _ = nil
|
119
120
|
@lex_state = nil # remove one warning under $DEBUG
|
@@ -134,16 +135,6 @@ class RubyLexer
|
|
134
135
|
is_after_operator? ? EXPR_ARG : EXPR_BEG
|
135
136
|
end
|
136
137
|
|
137
|
-
def ignore_body_comments
|
138
|
-
@comments.clear
|
139
|
-
end
|
140
|
-
|
141
|
-
def comments # TODO: remove this... maybe comment_string + attr_accessor
|
142
|
-
c = @comments.join
|
143
|
-
@comments.clear
|
144
|
-
c
|
145
|
-
end
|
146
|
-
|
147
138
|
def debug n
|
148
139
|
raise "debug #{n}"
|
149
140
|
end
|
@@ -258,14 +249,15 @@ class RubyLexer
|
|
258
249
|
end
|
259
250
|
|
260
251
|
def process_begin text
|
261
|
-
|
252
|
+
self.comment ||= +""
|
253
|
+
self.comment << matched
|
262
254
|
|
263
255
|
unless scan(/.*?\n=end( |\t|\f)*[^\n]*(\n|\z)/m) then
|
264
|
-
|
256
|
+
self.comment = nil
|
265
257
|
rb_compile_error("embedded document meets end of file")
|
266
258
|
end
|
267
259
|
|
268
|
-
|
260
|
+
self.comment << matched
|
269
261
|
self.lineno += matched.count("\n") # HACK?
|
270
262
|
|
271
263
|
nil # TODO
|
@@ -447,7 +439,8 @@ class RubyLexer
|
|
447
439
|
|
448
440
|
while scan(/\s*\#.*(\n+|\z)/) do
|
449
441
|
self.lineno += matched.count "\n"
|
450
|
-
|
442
|
+
self.comment ||= +""
|
443
|
+
self.comment << matched.gsub(/^ +#/, "#").gsub(/^ +$/, "")
|
451
444
|
end
|
452
445
|
|
453
446
|
return nil if end_of_stream?
|
@@ -768,7 +761,7 @@ class RubyLexer
|
|
768
761
|
self.lineno = 1
|
769
762
|
self.brace_nest = 0
|
770
763
|
self.command_start = true
|
771
|
-
self.
|
764
|
+
self.comment = nil
|
772
765
|
self.lex_state = EXPR_NONE
|
773
766
|
self.lex_strterm = nil
|
774
767
|
self.lpar_beg = nil
|
data/lib/ruby_lexer.rex.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# encoding: UTF-8
|
3
3
|
#--
|
4
4
|
# This file is automatically generated. Do not modify it.
|
5
|
-
# Generated by: oedipus_lex version 2.6.
|
5
|
+
# Generated by: oedipus_lex version 2.6.2.
|
6
6
|
# Source: lib/ruby_lexer.rex
|
7
7
|
#++
|
8
8
|
|
@@ -91,7 +91,6 @@ class RubyLexer
|
|
91
91
|
old_pos - start_of_current_line_pos
|
92
92
|
end
|
93
93
|
|
94
|
-
|
95
94
|
##
|
96
95
|
# The current scanner class. Must be overridden in subclasses.
|
97
96
|
|
data/lib/ruby_parser.rb
CHANGED
@@ -69,23 +69,25 @@ end
|
|
69
69
|
##
|
70
70
|
# Unfortunately a problem with racc is that it won't let me namespace
|
71
71
|
# properly, so instead of RubyParser::V25, I still have to generate
|
72
|
-
# the old
|
73
|
-
|
74
|
-
require "
|
75
|
-
require "
|
76
|
-
require "
|
77
|
-
require "
|
78
|
-
require "
|
79
|
-
require "
|
80
|
-
require "
|
81
|
-
require "
|
82
|
-
require "
|
83
|
-
require "
|
84
|
-
require "
|
72
|
+
# the old RubyParser25 and shove it in as V25.
|
73
|
+
|
74
|
+
require "ruby_parser20"
|
75
|
+
require "ruby_parser21"
|
76
|
+
require "ruby_parser22"
|
77
|
+
require "ruby_parser23"
|
78
|
+
require "ruby_parser24"
|
79
|
+
require "ruby_parser25"
|
80
|
+
require "ruby_parser26"
|
81
|
+
require "ruby_parser27"
|
82
|
+
require "ruby_parser30"
|
83
|
+
require "ruby_parser31"
|
84
|
+
require "ruby_parser32"
|
85
|
+
require "ruby_parser33"
|
85
86
|
|
86
87
|
class RubyParser # HACK
|
87
88
|
VERSIONS.clear # also a HACK caused by racc namespace issues
|
88
89
|
|
90
|
+
class V33 < ::Ruby33Parser; end
|
89
91
|
class V32 < ::Ruby32Parser; end
|
90
92
|
class V31 < ::Ruby31Parser; end
|
91
93
|
class V30 < ::Ruby30Parser; end
|
@@ -1468,7 +1468,6 @@ rule
|
|
1468
1468
|
{
|
1469
1469
|
result = new_class val
|
1470
1470
|
self.env.unextend
|
1471
|
-
self.lexer.ignore_body_comments
|
1472
1471
|
}
|
1473
1472
|
| k_class tLSHFT
|
1474
1473
|
expr
|
@@ -1486,7 +1485,6 @@ rule
|
|
1486
1485
|
{
|
1487
1486
|
result = new_sclass val
|
1488
1487
|
self.env.unextend
|
1489
|
-
self.lexer.ignore_body_comments
|
1490
1488
|
}
|
1491
1489
|
| k_module
|
1492
1490
|
cpath
|
@@ -1500,7 +1498,6 @@ rule
|
|
1500
1498
|
{
|
1501
1499
|
result = new_module val
|
1502
1500
|
self.env.unextend
|
1503
|
-
self.lexer.ignore_body_comments
|
1504
1501
|
}
|
1505
1502
|
| k_def fname
|
1506
1503
|
{
|
@@ -1519,8 +1516,6 @@ rule
|
|
1519
1516
|
lexer.cmdarg.pop
|
1520
1517
|
self.env.unextend
|
1521
1518
|
self.in_def = in_def
|
1522
|
-
|
1523
|
-
self.lexer.ignore_body_comments
|
1524
1519
|
}
|
1525
1520
|
| k_def singleton dot_or_colon
|
1526
1521
|
{
|
@@ -1559,8 +1554,6 @@ rule
|
|
1559
1554
|
self.in_single -= 1
|
1560
1555
|
|
1561
1556
|
# TODO: restore cur_arg ? what's cur_arg?
|
1562
|
-
|
1563
|
-
self.lexer.ignore_body_comments
|
1564
1557
|
}
|
1565
1558
|
| kBREAK
|
1566
1559
|
{
|
@@ -1598,15 +1591,15 @@ rule
|
|
1598
1591
|
k_for: kFOR
|
1599
1592
|
k_class: kCLASS
|
1600
1593
|
{
|
1601
|
-
|
1594
|
+
result << self.lexer.comment
|
1602
1595
|
}
|
1603
1596
|
k_module: kMODULE
|
1604
1597
|
{
|
1605
|
-
|
1598
|
+
result << self.lexer.comment
|
1606
1599
|
}
|
1607
1600
|
k_def: kDEF
|
1608
1601
|
{
|
1609
|
-
|
1602
|
+
result << self.lexer.comment
|
1610
1603
|
}
|
1611
1604
|
k_do: kDO
|
1612
1605
|
k_do_block: kDO_BLOCK
|