I'm totally newbie at Ruby. What is wrong whit this code

class Hexagrid

    @@grid = [%w{ 0 1 2 3 }, %w{ 4 5 6 7 }, %w{ 8 9 A B }, %w{ C D E F
}]

    def initialize
        @stacks = Hash.new
    end

    def parse( string )
        while string =~ /^\s*(\S+)\s*\{([^\}]+)\}\s*;?\s*(.*)/

            output = ''
            stack = @stacks[$1] ||= Hash.new
            data = stack[:data] ||= Array.new
            pointer = stack[:pointer] ||= [0,0]

            $2.split(//).each do |c|
                  if c == '>' then pointer[1] += 1
               elsif c == '<' then pointer[1] -= 1
               elsif c == 'v' then pointer[0] += 1
               elsif c == '^' then pointer[0] -= 1
               elsif c == '!' then pointer = [0,0]; data.clear
               elsif c == '+' then data.unshift
@@grid[pointer[0]][pointer[1]]
               elsif c == 'o' then output << data.join
               end
            end
            string = $3
        end
        return output.reverse
    end

    def english( string )
        return parse(string).scan(/.{2}/).collect{ |tuple| tuple.hex.chr
}.join
    end
end

hex = Hexagrid.new
while not $stdin.eof?
  puts hex.english(gets)
end

I've got D:\NetBeansProjects\InterpreterHexagrid\lib\main.rb:33:in
`parse': undefined method `reverse' for nil:NilClass (NoMethodError)
        from D:\NetBeansProjects\InterpreterHexagrid\lib\main.rb:37:in
`english'
        from D:\NetBeansProjects\InterpreterHexagrid\lib\main.rb:43

-- 
Posted via http://www.ruby-forum.com/.