fix the runner to handle list of expressiosn
This commit is contained in:
parent
8f2a22d12f
commit
b66b5ceff7
@ -21,16 +21,18 @@ class TestRunner < MiniTest::Test
|
|||||||
string = File.read(file)
|
string = File.read(file)
|
||||||
parser = Parser::Crystal.new
|
parser = Parser::Crystal.new
|
||||||
program = Vm::Program.new "Arm"
|
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|
|
parts.each_with_index do |part,index|
|
||||||
puts "parsing #{index}=#{part}"
|
puts "parsing #{index}=#{part}"
|
||||||
syntax = parser.parse_with_debug(part)
|
expr = part.compile( program.context )
|
||||||
funct = Parser::Transform.new.apply(syntax)
|
|
||||||
expr = funct.compile( program.context )
|
|
||||||
if index = parts.length
|
if index = parts.length
|
||||||
program.main = expr
|
program.main = expr
|
||||||
else
|
else
|
||||||
raise "should be function definition for now" unless expr.is_a? Function
|
raise "should be function definition for now" unless expr.is_a? Function
|
||||||
|
program.add_function expr
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user