Rakefile in ruby_parser-3.14.2 vs Rakefile in ruby_parser-3.15.0
- old
+ new
@@ -6,15 +6,16 @@
Hoe.plugin :seattlerb
Hoe.plugin :racc
Hoe.plugin :isolate
Hoe.plugin :rdoc
+Hoe.add_include_dirs "lib"
Hoe.add_include_dirs "../../sexp_processor/dev/lib"
Hoe.add_include_dirs "../../minitest/dev/lib"
Hoe.add_include_dirs "../../oedipus_lex/dev/lib"
-V2 = %w[20 21 22 23 24 25 26]
+V2 = %w[20 21 22 23 24 25 26 27]
V2.replace [V2.last] if ENV["FAST"] # HACK
Hoe.spec "ruby_parser" do
developer "Ryan Davis", "ryand-ruby@zenspider.com"
@@ -22,11 +23,11 @@
dependency "sexp_processor", "~> 4.9"
dependency "rake", "< 11", :developer
dependency "oedipus_lex", "~> 2.5", :developer
- require_ruby_version "~> 2.2"
+ require_ruby_version [">= 2.1", "< 3.1"]
if plugin? :perforce then # generated files
V2.each do |n|
self.perforce_ignore << "lib/ruby#{n}_parser.rb"
end
@@ -54,10 +55,12 @@
file "lib/ruby#{n}_parser.rb" => "lib/ruby#{n}_parser.y"
end
file "lib/ruby_lexer.rex.rb" => "lib/ruby_lexer.rex"
+task :generate => [:lexer, :parser]
+
task :clean do
rm_rf(Dir["**/*~"] +
Dir["diff.diff"] + # not all diffs. bit me too many times
Dir["coverage.info"] +
Dir["coverage"] +
@@ -121,17 +124,26 @@
end
end
file c_parse_y => c_tarball do
in_compare do
- system "tar yxf #{tarball} #{ruby_dir}/{id.h,parse.y,tool/{id2token.rb,vpath.rb}}"
+ extract_glob = case version
+ when /2\.7/
+ "{id.h,parse.y,tool/{id2token.rb,lib/vpath.rb}}"
+ else
+ "{id.h,parse.y,tool/{id2token.rb,vpath.rb}}"
+ end
+ system "tar yxf #{tarball} #{ruby_dir}/#{extract_glob}"
+
Dir.chdir ruby_dir do
if File.exist? "tool/id2token.rb" then
sh "ruby tool/id2token.rb --path-separator=.:./ id.h parse.y | expand > ../#{parse_y}"
else
sh "expand parse.y > ../#{parse_y}"
end
+
+ ruby "-pi", "-e", 'gsub(/^%define\s+api\.pure/, "%pure-parser")', "../#{parse_y}"
end
sh "rm -rf #{ruby_dir}"
end
end
@@ -180,20 +192,21 @@
ruby_parse "2.0.0-p648"
ruby_parse "2.1.9"
ruby_parse "2.2.9"
ruby_parse "2.3.8"
-ruby_parse "2.4.5"
-ruby_parse "2.5.3"
-ruby_parse "2.6.1"
+ruby_parse "2.4.9"
+ruby_parse "2.5.8"
+ruby_parse "2.6.6"
+ruby_parse "2.7.1"
task :debug => :isolate do
ENV["V"] ||= V2.last
Rake.application[:parser].invoke # this way we can have DEBUG set
Rake.application[:lexer].invoke # this way we can have DEBUG set
- $: << "lib"
+ $:.unshift "lib"
require "ruby_parser"
require "pp"
klass = Object.const_get("Ruby#{ENV["V"]}Parser") rescue nil
raise "Unsupported version #{ENV["V"]}" unless klass
@@ -212,12 +225,13 @@
end
begin
pp parser.process(ruby, file, time)
- rescue Racc::ParseError => e
+ rescue ArgumentError, Racc::ParseError => e
p e
+ puts e.backtrace.join "\n "
ss = parser.lexer.ss
src = ss.string
lines = src[0..ss.pos].split(/\n/)
abort "on #{file}:#{lines.size}"
end
@@ -230,13 +244,18 @@
abort "Need a file to parse, via: F=path.rb" unless file
ENV.delete "V"
+ sh "ruby -v"
sh "ruby -y #{file} 2>&1 | #{munge} > tmp/ruby"
sh "./tools/ripper.rb -d #{file} | #{munge} > tmp/rip"
- sh "rake debug F=#{file} DEBUG=1 V=25 2>&1 | #{munge} > tmp/rp"
+ sh "rake debug F=#{file} DEBUG=1 2>&1 | #{munge} > tmp/rp"
sh "diff -U 999 -d tmp/{rip,rp}"
+end
+
+task :cmp do
+ sh %(emacsclient --eval '(ediff-files "tmp/ruby" "tmp/rp")')
end
task :cmp3 do
sh %(emacsclient --eval '(ediff-files3 "tmp/ruby" "tmp/rip" "tmp/rp")')
end