class Python::REPL

Constants

ParsingError

Public Class Methods

new(output) click to toggle source
# File lib/python/repl.rb, line 8
def initialize(output)
  @output = output
  @env = Environment.new
end

Public Instance Methods

eval(exp) click to toggle source
# File lib/python/repl.rb, line 31
def eval(exp)
  exp.eval(@env)
end
print(obj) click to toggle source
prompt() click to toggle source
# File lib/python/repl.rb, line 43
def prompt
  @output.print "python.rb> "
end
read(code) click to toggle source
# File lib/python/repl.rb, line 21
def read(code)
  parser = Parser::StatementParser.stmt_list
  result = parser.parse(code)
  if result.is_a?(Parser::Succeeded) && result.rest.chomp == ""
    result.parsed
  else
    raise ParsingError.new
  end
end
read_eval_print(code) click to toggle source
# File lib/python/repl.rb, line 17
def read_eval_print(code)
  print(eval(read(code)))
end
start() click to toggle source
# File lib/python/repl.rb, line 13
def start
  prompt
end