2014-06-25 14:20:46 +02:00
|
|
|
require_relative '../helper'
|
|
|
|
require 'parslet/convenience'
|
|
|
|
|
2015-10-10 09:02:28 +02:00
|
|
|
module CompilerHelper
|
2015-07-02 09:44:44 +02:00
|
|
|
|
2015-10-10 09:02:28 +02:00
|
|
|
Phisol::Compiler.class_eval do
|
|
|
|
def set_main
|
|
|
|
@method = Virtual.machine.space.get_main
|
|
|
|
end
|
2014-06-25 14:20:46 +02:00
|
|
|
end
|
2015-10-10 09:02:28 +02:00
|
|
|
def check
|
|
|
|
machine = Virtual.machine.boot
|
|
|
|
parser = Parser::Salama.new
|
|
|
|
parser = parser.send @root
|
|
|
|
syntax = parser.parse_with_debug(@string_input)
|
|
|
|
parts = Parser::Transform.new.apply(syntax)
|
|
|
|
#puts parts.inspect
|
|
|
|
compiler = Phisol::Compiler.new
|
|
|
|
compiler.set_main
|
|
|
|
produced = compiler.process( parts )
|
|
|
|
produced = [produced] unless produced.is_a? Array
|
|
|
|
assert @output , "No output given"
|
|
|
|
assert_equal produced.length, @output.length , "Block length"
|
|
|
|
produced.each_with_index do |b,i|
|
|
|
|
codes = @output[i]
|
|
|
|
assert_equal codes , b.class , "Class #{i} "
|
2015-05-24 17:05:20 +02:00
|
|
|
end
|
|
|
|
end
|
2015-10-10 09:02:28 +02:00
|
|
|
|
2015-05-24 17:05:20 +02:00
|
|
|
end
|