Class: Q::VM

Inherits:
Object
  • Object
show all
Defined in:
lib/q/vm.rb

Instance Method Summary collapse

Constructor Details

#initializeVM

Returns a new instance of VM.



50
51
52
53
54
55
# File 'lib/q/vm.rb', line 50

def initialize
  Q.load

  @scope  = ToplevelScope.new
  @parser = QParser.new
end

Instance Method Details

#eval(input) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/q/vm.rb', line 57

def eval input
  parsed = @parser.parse input

  if parsed.nil?
    raise ParsingException.new input, @parser.failure_line, @parser.failure_index, @parser.failure_reason
  end

  parsed.eval @scope
end

#reset(with_scope = false) ⇒ Object



67
68
69
70
# File 'lib/q/vm.rb', line 67

def reset with_scope = false
  @parser = QParser.new
  @scope  = Q::Scope.new if with_scope
end