Class: Base::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/base/compiler.rb

Constant Summary collapse

Error =
Class.new(StandardError)

Instance Method Summary collapse

Constructor Details

#initialize(program) ⇒ Compiler

Returns a new instance of Compiler.



5
6
7
8
9
10
# File 'lib/base/compiler.rb', line 5

def initialize(program)
  @program = program
  @parsing = []
  @labels = {}
  @macros = {}
end

Instance Method Details

#compile(data) ⇒ Object



12
13
14
15
16
17
# File 'lib/base/compiler.rb', line 12

def compile(data)
  lines = data.split("\n")
  parse(lines)
  @program.start_location = @labels["main"] || 0
  true
end