remove soml parser from tests

This commit is contained in:
Torsten Ruger 2016-12-08 19:39:16 +02:00
parent e2236cf703
commit 4cd979e3e9
9 changed files with 105 additions and 6 deletions

View File

@ -1,6 +1,6 @@
require_relative 'helper'
module Soml
module Typed
class TestWord < MiniTest::Test
include Fragments

View File

@ -21,6 +21,8 @@ class TestRunner < MiniTest::Test
string = File.read(file)
parser = Parser::Salama.new
object_space = Register::Program.new "Arm"
#TODO : files would have to include s-expressions now
# those can be obtained with to_code utility in soml-parser
syntax = parser.parse_with_debug(string, reporter: Parslet::ErrorReporter::Deepest.new)
assert syntax
parts = Parser::Transform.new.apply(syntax)

View File

@ -1,10 +1,11 @@
require_relative "../helper"
class HelloTest < MiniTest::Test
include AST::Sexp
def check
machine = Register.machine.boot
machine.parse_and_compile @string_input
Typed.compile( @input )
machine.collect
machine.translate_arm
writer = Elf::ObjectWriter.new
@ -19,6 +20,20 @@ class Object
end
end
HERE
@input = s(:statements,
s(:class, :Object,
s(:derives, nil),
s(:statements,
s(:function, :Integer,
s(:name, :main),
s(:parameters),
s(:statements,
s(:return,
s(:call,
s(:name, :putstring),
s(:arguments),
s(:receiver,
s(:string, "Hello again\\n")))))))))
check
end
end

View File

@ -2,13 +2,11 @@ require_relative "../../helper"
require "register/interpreter"
module Ticker
include AST::Sexp
def setup
machine = Register.machine.boot
syntax = Parser::Salama.new.parse_with_debug(@string_input, reporter: Parslet::ErrorReporter::Deepest.new)
parts = Parser::Transform.new.apply(syntax)
#puts parts.inspect
Typed.compile( parts )
Typed.compile( @input )
machine.collect
@interpreter = Register::Interpreter.new
@interpreter.start Register.machine.init

View File

@ -11,6 +11,18 @@ class Space
end
end
HERE
@input = s(:statements,
s(:class, :Space,
s(:derives, nil),
s(:statements,
s(:function, :Integer,
s(:name, :main),
s(:parameters),
s(:statements,
s(:return,
s(:operator_value, :+,
s(:int, 5),
s(:int, 7))))))))
super
end

View File

@ -19,6 +19,40 @@ class Space
end
end
HERE
@input = s(:statements,
s(:class, :Space,
s(:derives, nil),
s(:statements,
s(:function, :Integer,
s(:name, :itest),
s(:parameters,
s(:parameter, :Integer, :n)),
s(:statements,
s(:if_statement, :zero,
s(:condition,
s(:operator_value, :-,
s(:name, :n),
s(:int, 12))),
s(:true_statements,
s(:call,
s(:name, :putstring),
s(:arguments),
s(:receiver,
s(:string, "then")))),
s(:false_statements,
s(:call,
s(:name, :putstring),
s(:arguments),
s(:receiver,
s(:string, "else"))))))),
s(:function, :Integer,
s(:name, :main),
s(:parameters),
s(:statements,
s(:call,
s(:name, :itest),
s(:arguments,
s(:int, 20))))))))
super
end

View File

@ -11,7 +11,20 @@ class Space
return #{2**31} * #{2**31}
end
end
HERE
@input = s(:statements,
s(:class, :Space,
s(:derives, nil),
s(:statements,
s(:function, :Integer,
s(:name, :main),
s(:parameters),
s(:statements,
s(:return,
s(:operator_value, :*,
s(:int, 2147483648),
s(:int, 2147483648))))))))
super
end

View File

@ -11,6 +11,18 @@ class Space
end
end
HERE
@input = s(:statements,
s(:class, :Space,
s(:derives, nil),
s(:statements,
s(:function, :Integer,
s(:name, :main),
s(:parameters),
s(:statements,
s(:return,
s(:operator_value, :+,
s(:int, 4611686018427387903),
s(:int, 1))))))))
super
end

View File

@ -11,6 +11,19 @@ class Space
end
end
HERE
@input = s(:statements,
s(:class, :Space,
s(:derives, nil),
s(:statements,
s(:function, :Integer,
s(:name, :main),
s(:parameters),
s(:statements,
s(:call,
s(:name, :putstring),
s(:arguments),
s(:receiver,
s(:string, "Hello again"))))))))
super
end