From b66b5ceff737876f593199ea1bd1fd86734e2514 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sat, 10 May 2014 11:23:45 +0300 Subject: [PATCH] fix the runner to handle list of expressiosn --- test/test_runner.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/test_runner.rb b/test/test_runner.rb index e430cc46..be2a7355 100644 --- a/test/test_runner.rb +++ b/test/test_runner.rb @@ -21,16 +21,18 @@ class TestRunner < MiniTest::Test string = File.read(file) parser = Parser::Crystal.new program = Vm::Program.new "Arm" - parts = string.split "SPLIT" + syntax = parser.parse_with_debug(string) + parts = Parser::Transform.new.apply(syntax) + # file is a list of expressions, al but the last must be a function + # and the last is wrapped as a main parts.each_with_index do |part,index| puts "parsing #{index}=#{part}" - syntax = parser.parse_with_debug(part) - funct = Parser::Transform.new.apply(syntax) - expr = funct.compile( program.context ) + expr = part.compile( program.context ) if index = parts.length program.main = expr else raise "should be function definition for now" unless expr.is_a? Function + program.add_function expr end end