Class: Base::Compiler
- Inherits:
-
Object
- Object
- Base::Compiler
- Defined in:
- lib/base/compiler.rb
Constant Summary collapse
- Error =
Class.new(StandardError)
Instance Method Summary collapse
- #compile(file) ⇒ Object
-
#initialize ⇒ Compiler
constructor
A new instance of Compiler.
Constructor Details
#initialize ⇒ Compiler
Returns a new instance of Compiler.
5 6 7 8 9 10 |
# File 'lib/base/compiler.rb', line 5 def initialize @parsing = [] @memory = [] @labels = {} @macros = {} end |
Instance Method Details
#compile(file) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/base/compiler.rb', line 12 def compile(file) lines = File.read(file).split("\n") parse(lines) main = @labels["main"] || 0 [main] + @memory end |