Torsten Ruger 229f5896c6 update to use new ast
soml was updated to have a typed ast layer to make programatic creation
easier
this brings LOTS of syntax change with it, that does not really mean
anything at all
All tests pass again so back to the same
2016-03-07 11:55:28 +02:00

35 lines
922 B
Ruby

require_relative '../../helper'
require 'parslet/convenience'
Soml::Compiler.class_eval do
def set_main main
@clazz = Register.machine.space.get_class_by_name :Object
@method = main
@current = main.instructions.next
end
end
module ExpressionHelper
def set_main compiler
compiler.set_main Register.machine.space.get_main
end
def check
machine = Register.machine
machine.boot unless machine.booted
parser = Parser::Salama.new
parser = parser.send @root
syntax = parser.parse_with_debug(@string_input, reporter: Parslet::ErrorReporter::Deepest.new)
parts = Parser::Transform.new.apply(syntax)
codes = Soml.ast_to_code parts
#puts parts.inspect
compiler = Soml::Compiler.new
set_main(compiler)
produced = compiler.process( codes )
assert @output , "No output given"
assert_equal produced.class, @output , "Wrong class"
produced
end
end