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
|
2015-10-14 12:48:42 +02:00
|
|
|
def set_main main
|
2015-10-13 15:42:53 +02:00
|
|
|
@clazz = Virtual.machine.space.get_class_by_name :Object
|
2015-10-14 12:48:42 +02:00
|
|
|
@method = main
|
2015-10-10 09:02:28 +02:00
|
|
|
end
|
2014-06-25 14:20:46 +02:00
|
|
|
end
|
2015-10-14 12:48:42 +02:00
|
|
|
def set_main compiler
|
|
|
|
compiler.set_main Virtual.machine.space.get_main
|
|
|
|
end
|
2015-10-10 09:02:28 +02:00
|
|
|
def check
|
2015-10-13 15:42:53 +02:00
|
|
|
machine = Virtual.machine
|
|
|
|
machine.boot unless machine.booted
|
2015-10-10 09:02:28 +02:00
|
|
|
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
|
2015-10-14 12:48:42 +02:00
|
|
|
set_main(compiler)
|
2015-10-10 09:02:28 +02:00
|
|
|
produced = compiler.process( parts )
|
|
|
|
assert @output , "No output given"
|
2015-10-13 15:42:53 +02:00
|
|
|
assert_equal produced.class, @output , "Wrong class"
|
2015-05-24 17:05:20 +02:00
|
|
|
end
|
2015-10-10 09:02:28 +02:00
|
|
|
|
2015-05-24 17:05:20 +02:00
|
|
|
end
|