Permalink
Browse files

Command line tool works

  • Loading branch information...
1 parent 6284558 commit 57cf1c0c14ee27da08434bf8259e5405497bad4e @txus committed Feb 13, 2014
Showing with 17 additions and 2 deletions.
  1. +7 −2 bin/lambra
  2. +4 −0 lib/lambra/bytecode_compiler.rb
  3. +6 −0 spec/compiler_spec.rb
View
@@ -37,8 +37,13 @@ end
display = proc do |file, code, ev=true, binding=nil|
begin
if settings[:ast]
- ast = Lambra::Parser.parse_file(file)
- info.call(:ast, 'AST') { Rubinius::AST::AsciiGrapher.new(ast).print }
+ ast = if file == '(eval)'
+ Lambra::Parser.parse_string(code)
+ else
+ Lambra::Parser.parse_file(file)
+ end
+
+ info.call(:ast, 'AST') { RBX::AST::AsciiGrapher.new(ast).print }
end
info.call(:bc, "Bytecode") { puts Lambra::Compiler.compile_string(code, file).decode }
@@ -43,6 +43,10 @@ def visit_EvalExpression(o)
o.body.accept(self)
end
+ def visit_Script(o)
+ o.body.accept(self)
+ end
+
def visit_List(o)
set_line(o)
return g.push_nil if o.elements.count.zero?
View
@@ -31,4 +31,10 @@
'(let [x 2 y 3] (* x y))'.should eval_to 6
end
end
+
+ describe 'spawn' do
+ it 'spawns a new process' do
+ '(spawn (fn [] (sleep 10)))'.should eval_to_kind_of(Integer)
+ end
+ end
end

0 comments on commit 57cf1c0

Please sign in to comment.