Skip to content

Commit

Permalink
works with 1.8.7. woot
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Nov 30, 2008
1 parent b591621 commit 458a8a4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 30 deletions.
28 changes: 0 additions & 28 deletions lib/racc/compat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,3 @@ class Array
end
end
end

unless Enumerable.method_defined?(:map)
module Enumerable
alias map collect
end
end

unless File.respond_to?(:read)
def File.read(path)
File.open(path) {|f| return f.read }
end
end

unless Enumerable.method_defined?(:each_slice)
module Enumerable
def each_slice(n)
buf = []
each do |x|
buf.push x
if buf.size == n
yield(*buf)
buf.clear
end
end
yield(*buf) unless buf.empty?
end
end
end
3 changes: 2 additions & 1 deletion lib/racc/parserfilegenerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# For details of the GNU LGPL, see the file "COPYING".
#

require 'enumerator'
require 'racc/compat'
require 'racc/sourcetext'
require 'racc/parser-text'
Expand Down Expand Up @@ -364,7 +365,7 @@ def serialize_integer_list_compressed(name, table)
def serialize_integer_list_std(name, table)
sep = ''
line "#{name} = ["
table.each_slice(10) do |*ns|
table.each_slice(10) do |ns|
@f.print sep; sep = ",\n"
@f.print ns.map {|n| sprintf('%6s', n ? n.to_s : 'nil') }.join(',')
end
Expand Down
5 changes: 4 additions & 1 deletion test/test_parserfilegenerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ def setup
def test_compile_chk_y
generator = Racc::ParserFileGenerator.new(@states, @result.params.dup)

fork { eval(generator.generate_parser) }
fork {
eval(generator.generate_parser)
}
Process.wait
assert_equal 0, $?.exitstatus

grammar = @states.grammar

Expand Down

0 comments on commit 458a8a4

Please sign in to comment.