Module: BrainLove
- Defined in:
- lib/brain_love.rb,
lib/brain_love/vm.rb,
lib/brain_love/ast.rb,
lib/brain_love/parser.rb,
lib/brain_love/version.rb,
lib/brain_love/compiler.rb,
lib/brain_love/transformer.rb
Defined Under Namespace
Modules: AST
Classes: Compiler, Parser, Transformer, VM
Constant Summary
collapse
- VERSION =
"0.0.3"
Class Method Summary
collapse
Class Method Details
.run_file(file, input = STDIN, output = STDOUT) ⇒ Object
18
19
20
21
|
# File 'lib/brain_love.rb', line 18
def run_file(file, input = STDIN, output = STDOUT)
code = File.open(file) { |f| f.read }
run_string(code, input, output)
end
|
.run_string(code, input = STDIN, output = STDOUT) ⇒ Object
10
11
12
13
14
15
|
# File 'lib/brain_love.rb', line 10
def run_string(code, input = STDIN, output = STDOUT)
ast = Transformer.new.apply(Parser.new.parse(code))
compiler = Compiler.new
ast.accept(compiler)
VM.new(compiler.bytecode, input, output).execute
end
|