ruby_parser 3.20.3 → 3.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/History.rdoc +32 -0
  4. data/Manifest.txt +14 -24
  5. data/README.rdoc +3 -3
  6. data/Rakefile +113 -115
  7. data/compare/normalize.rb +2 -0
  8. data/lib/ruby_lexer.rb +9 -16
  9. data/lib/ruby_lexer.rex.rb +1 -2
  10. data/lib/ruby_parser.rb +15 -13
  11. data/lib/{ruby_parser.yy → ruby_parser2.yy} +3 -10
  12. data/lib/{ruby20_parser.rb → ruby_parser20.rb} +9 -12
  13. data/lib/{ruby21_parser.rb → ruby_parser21.rb} +9 -12
  14. data/lib/{ruby22_parser.rb → ruby_parser22.rb} +9 -12
  15. data/lib/{ruby23_parser.rb → ruby_parser23.rb} +9 -12
  16. data/lib/{ruby24_parser.rb → ruby_parser24.rb} +9 -12
  17. data/lib/{ruby25_parser.rb → ruby_parser25.rb} +9 -12
  18. data/lib/{ruby26_parser.rb → ruby_parser26.rb} +9 -12
  19. data/lib/{ruby27_parser.rb → ruby_parser27.rb} +9 -12
  20. data/lib/{ruby3_parser.yy → ruby_parser3.yy} +7 -33
  21. data/lib/{ruby30_parser.rb → ruby_parser30.rb} +11 -35
  22. data/lib/{ruby31_parser.rb → ruby_parser31.rb} +11 -35
  23. data/lib/{ruby32_parser.rb → ruby_parser32.rb} +11 -35
  24. data/lib/ruby_parser33.rb +13577 -0
  25. data/lib/ruby_parser_extras.rb +34 -17
  26. data/test/test_ruby_lexer.rb +5 -5
  27. data/test/test_ruby_parser.rb +21 -19
  28. data.tar.gz.sig +0 -0
  29. metadata +41 -51
  30. metadata.gz.sig +0 -0
  31. data/lib/ruby20_parser.y +0 -2707
  32. data/lib/ruby21_parser.y +0 -2724
  33. data/lib/ruby22_parser.y +0 -2735
  34. data/lib/ruby23_parser.y +0 -2737
  35. data/lib/ruby24_parser.y +0 -2745
  36. data/lib/ruby25_parser.y +0 -2745
  37. data/lib/ruby26_parser.y +0 -2760
  38. data/lib/ruby27_parser.y +0 -3360
  39. data/lib/ruby30_parser.y +0 -3508
  40. data/lib/ruby31_parser.y +0 -3542
  41. data/lib/ruby32_parser.y +0 -3543
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c0c3e107b8953bdbaf64c24c32d5428696fa648398c4fdc896cba560547341b
4
- data.tar.gz: b268454b6584eee700d5d90e37c7986e252a024b89422d47db69d5c0cfd7f917
3
+ metadata.gz: 6130eb28e9d379051c5b2f5c83b2c77ca217e82e0ca0aa53736128810fd1ff35
4
+ data.tar.gz: 7359cfb0974a66a0d07bb75899d92c2082a23e326bd6aed56ae5c7790e2819be
5
5
  SHA512:
6
- metadata.gz: f466e027ad5467b7a799a44378756fb082cd86d59c7696815347af2be9360b21f2ff9f5f5e8687b7073cc9ab2432330808a07eaee57e8802783ffe6b6a16b602
7
- data.tar.gz: 8eb1af21a6936f44bcc8ea42b8dae4773e1a86a8e4815c67a536e1d10363e5c95123d77c04402f156e8f9e7b786b21ff382d3134a650c6428f903552a61ec495
6
+ metadata.gz: 0d9e8d398b4f7f412406c23ec13557d4c80f4c10fffbf9563992df2cbbda7c0c9ca46e933025c20930d7434336b63d6485d8cb5463e484e5a04c676d7207a8eb
7
+ data.tar.gz: a34f3b845c73d919b5e502d07f2683e823dd126372cac137eb7c4b504ad4b90f6a25f46f8eb30ef62cba55ef50b7eb3b148d426dcdeabeca87e3465b0622b548
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,35 @@
1
+ === 3.21.0 / 2024-01-15
2
+
3
+ * 18 minor enhancements:
4
+
5
+ * (internal) Added simple RubyLexer#comment.
6
+ * (internal) Removed RubyLexer#comments and #ignore_body_comments.
7
+ * (internal) Removed RubyParser#comments.
8
+ * (internal) Renamed files from lib/ruby##_parser.* to lib/ruby_parser##.*
9
+ * (internal) Renamed lib/ruby3_parser.yy to lib/ruby_parser3.yy
10
+ * (internal) Renamed lib/ruby_parser.yy to lib/ruby_parser2.yy
11
+ * Added tentative 3.2 support. (torrocus)
12
+ * Made `rake compare` a multitask (28s -> 10s!!).
13
+ * Made `rake compare` depend on `generate` (from clean: 28s -> 18s).
14
+ * No longer package versioned .y files.
15
+ * Overhaul of parser/lexer comment processing.
16
+ * Parser productions for k_class/k_module/k_def carry their comment with them.
17
+ * Restructured build tasks to utilize Hoe's .yy support! 8.5s -> 1.2s!!!
18
+ * RubyParser new_(class|module|defn|defs) handle comment processing via sexp.
19
+ * RubyParser new_(class|module|defn|defs) handle normalizing production sexps.
20
+ * RubyParser#next_token clears out lexer's comment when applicable.
21
+ * Simplified parser productions for defn_head, defs_head. No more normalizing.
22
+ * Updated `rake compare` steps for lrama in ruby 3.3+.
23
+
24
+ * 6 bug fixes:
25
+
26
+ * Cleaned out cruft from `rake compare` code.
27
+ * Fixed compare/normalize.rb for lrama differences.
28
+ * Made `parser` task depend on `isolate` task to pick up racc generator.
29
+ * Made racc a runtime dependency (was dev only) now that ruby 3.3 doesn't ship with the racc runtime. (wildmaples)
30
+ * Updated README.rdoc updating instructions to match current filenames.
31
+ * Updated compare versions and added 3.3.
32
+
1
33
  === 3.20.3 / 2023-07-11
2
34
 
3
35
  * 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/ruby_parser.yy
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/ruby[3]_parser.yy.
69
- * Extend lib/ruby[3]_parser.yy with new class name.
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", "~> 4.16"
31
- dependency "rake", [">= 10", "< 15"], :developer
32
- dependency "oedipus_lex", "~> 2.6", :developer
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/ruby#{n}_parser.rb"
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/ruby#{n}_parser.y"
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
- # self.racc_flags << " --runtime ruby_parser" # TODO: broken in racc
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
- V2.each do |n|
88
- file "lib/ruby#{n}_parser.y" => "lib/ruby_parser.yy" do |t|
89
- unifdef?
90
- cmd = 'unifdef -tk -DV=%s -UDEAD %s > %s || true' % [n, t.source, t.name]
91
- sh cmd
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
- file "lib/ruby#{n}_parser.rb" => "lib/ruby#{n}_parser.y"
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
- V3.each do |n|
98
- file "lib/ruby#{n}_parser.y" => "lib/ruby3_parser.yy" do |t|
99
- unifdef?
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
- file "lib/ruby#{n}_parser.rb" => "lib/ruby#{n}_parser.y"
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/ruby2*_parser.y"] +
123
- Dir["lib/ruby3*_parser.y"] +
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 in_compare
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
- path = File.basename url
153
- unless File.exist? path then
154
- system "curl -O #{url}"
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
- rp_txt = "rp#{v}.txt"
161
- mri_txt = "mri#{v}.txt"
162
- parse_y = "parse#{v}.y"
163
- tarball = "ruby-#{version}.tar.xz"
164
- ruby_dir = "ruby-#{version}"
165
- diff = "diff#{v}.diff"
166
- rp_out = "lib/ruby#{v}_parser.output"
167
- _rp_y = "lib/ruby#{v}_parser.y"
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 c_tarball do
178
- in_compare do
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 => c_tarball
185
-
186
- file c_parse_y => c_tarball do
187
- in_compare do
188
- extract_glob = case
189
- # defs/id.def
190
- when version > "3.2" then
191
- "{id.h,parse.y,tool/{id2token.rb,lib/vpath.rb},defs/id.def}"
192
- when version > "2.7" then
193
- "{id.h,parse.y,tool/{id2token.rb,lib/vpath.rb}}"
194
- else
195
- "{id.h,parse.y,tool/{id2token.rb,vpath.rb}}"
196
- end
197
- system "tar Jxf #{tarball} #{ruby_dir}/#{extract_glob}"
198
-
199
- Dir.chdir ruby_dir do
200
- if File.exist? "tool/id2token.rb" then
201
- args = version < "3.2" ? "--path-separator=.:./ id.h" : ""
202
- sh "ruby tool/id2token.rb #{args} parse.y | expand > ../#{parse_y}"
203
- else
204
- sh "expand parse.y > ../#{parse_y}"
205
- end
206
-
207
- ruby "-pi", "-e", 'gsub(/^%pure-parser/, "%define api.pure")', "../#{parse_y}"
208
- end
209
- sh "rm -rf #{ruby_dir}"
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 c_mri_txt => [c_parse_y, normalize] do
219
- in_compare do
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
- sh "./normalize.rb parse#{v}.output > #{mri_txt}"
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 c_rp_txt => [rp_out, normalize] do
229
- in_compare do
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
- file c_diff => [c_mri_txt, c_rp_txt] do
240
- in_compare do
241
- sh "diff -du #{mri_txt} #{rp_txt} > #{diff}; true"
242
- end
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 => c_diff do
247
- in_compare do
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[c_mri_txt, c_rp_txt]
250
+ rm_f Dir[mri_txt, rp_txt]
254
251
  end
255
252
 
256
253
  task :realclean do
257
- rm_f Dir[c_parse_y, c_tarball]
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.7"
301
- ruby_parse "3.0.5"
302
- ruby_parse "3.1.3"
303
- ruby_parse "3.2.1"
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
@@ -202,6 +202,8 @@ ARGF.each_line do |line|
202
202
  break
203
203
  when /^Terminals/ then # yacc
204
204
  break
205
+ when /^State \d/ then # lrama
206
+ break
205
207
  when /^\cL/ then # byacc
206
208
  break
207
209
  else
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
- attr_writer :comments
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
- @comments << matched
252
+ self.comment ||= +""
253
+ self.comment << matched
262
254
 
263
255
  unless scan(/.*?\n=end( |\t|\f)*[^\n]*(\n|\z)/m) then
264
- @comments.clear
256
+ self.comment = nil
265
257
  rb_compile_error("embedded document meets end of file")
266
258
  end
267
259
 
268
- @comments << matched
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
- @comments << matched.gsub(/^ +#/, "#").gsub(/^ +$/, "")
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.comments = []
764
+ self.comment = nil
772
765
  self.lex_state = EXPR_NONE
773
766
  self.lex_strterm = nil
774
767
  self.lpar_beg = nil
@@ -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.1.
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 Ruby25Parser and shove it in as V25.
73
-
74
- require "ruby20_parser"
75
- require "ruby21_parser"
76
- require "ruby22_parser"
77
- require "ruby23_parser"
78
- require "ruby24_parser"
79
- require "ruby25_parser"
80
- require "ruby26_parser"
81
- require "ruby27_parser"
82
- require "ruby30_parser"
83
- require "ruby31_parser"
84
- require "ruby32_parser"
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
- self.comments.push self.lexer.comments
1594
+ result << self.lexer.comment
1602
1595
  }
1603
1596
  k_module: kMODULE
1604
1597
  {
1605
- self.comments.push self.lexer.comments
1598
+ result << self.lexer.comment
1606
1599
  }
1607
1600
  k_def: kDEF
1608
1601
  {
1609
- self.comments.push self.lexer.comments
1602
+ result << self.lexer.comment
1610
1603
  }
1611
1604
  k_do: kDO
1612
1605
  k_do_block: kDO_BLOCK