read_list(tokens) list = [:list] tokens.shift # pop our opening paren while tokens.first !~ /(\)|\])/ list << read_form(tokens) end tokens.shift # pop our closing paren list end
read_atom(token) case token when /^-?\d+$/ [:integer, token.to_i] when 'true' [:boolean, :true] when 'false' [:boolean, :false] when /^\D+$/ [:symbol, token] else raise 'Reader error: Unknown token' end end
super @left_operand = left_operand @right_operand = right_operand end def bytecode(g) pos(g) @left_operand.bytecode(g) @right_operand.bytecode(g) g.send(:+, 1) end end