Skip to content

Commit

Permalink
Command line tool works
Browse files Browse the repository at this point in the history
  • Loading branch information
Josep M. Bach committed Feb 13, 2014
1 parent 6284558 commit 57cf1c0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bin/lambra
Expand Up @@ -37,8 +37,13 @@ end
display = proc do |file, code, ev=true, binding=nil| display = proc do |file, code, ev=true, binding=nil|
begin begin
if settings[:ast] if settings[:ast]
ast = Lambra::Parser.parse_file(file) ast = if file == '(eval)'
info.call(:ast, 'AST') { Rubinius::AST::AsciiGrapher.new(ast).print } Lambra::Parser.parse_string(code)
else
Lambra::Parser.parse_file(file)
end

info.call(:ast, 'AST') { RBX::AST::AsciiGrapher.new(ast).print }
end end


info.call(:bc, "Bytecode") { puts Lambra::Compiler.compile_string(code, file).decode } info.call(:bc, "Bytecode") { puts Lambra::Compiler.compile_string(code, file).decode }
Expand Down
4 changes: 4 additions & 0 deletions lib/lambra/bytecode_compiler.rb
Expand Up @@ -43,6 +43,10 @@ def visit_EvalExpression(o)
o.body.accept(self) o.body.accept(self)
end end


def visit_Script(o)
o.body.accept(self)
end

def visit_List(o) def visit_List(o)
set_line(o) set_line(o)
return g.push_nil if o.elements.count.zero? return g.push_nil if o.elements.count.zero?
Expand Down
6 changes: 6 additions & 0 deletions spec/compiler_spec.rb
Expand Up @@ -31,4 +31,10 @@
'(let [x 2 y 3] (* x y))'.should eval_to 6 '(let [x 2 y 3] (* x y))'.should eval_to 6
end end
end end

describe 'spawn' do
it 'spawns a new process' do
'(spawn (fn [] (sleep 10)))'.should eval_to_kind_of(Integer)
end
end
end end

0 comments on commit 57cf1c0

Please sign in to comment.