more machinery to the machine
This commit is contained in:
parent
5add9c42f2
commit
8effcc866a
2
lib/parfait/object.rb
Normal file
2
lib/parfait/object.rb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
class Object
|
||||||
|
end
|
@ -42,12 +42,25 @@ module Virtual
|
|||||||
def self.boot
|
def self.boot
|
||||||
machine = Machine.new
|
machine = Machine.new
|
||||||
machine.boot
|
machine.boot
|
||||||
|
machine
|
||||||
end
|
end
|
||||||
|
|
||||||
def read string
|
def boot
|
||||||
syntax = @parser.parse_with_debug(string)
|
# read all the files needed for a minimal system at compile
|
||||||
Parser::Transform.new.apply(syntax)
|
classes = ["object"]
|
||||||
|
classes.each do |clazz|
|
||||||
|
bytes = File.read(File.join( File.dirname( __FILE__ ) , ".." , "parfait" , "#{clazz}.rb") )
|
||||||
|
# expression = compile_main(bytes)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def compile_main bytes
|
||||||
|
syntax = @parser.parse_with_debug(bytes)
|
||||||
|
parts = Parser::Transform.new.apply(syntax)
|
||||||
|
main = Virtual::MethodDefinition.main
|
||||||
|
expressions = parts.compile( main , self.message )
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# run the instruction stream given. Instructions are a graph and executing means traversing it.
|
# run the instruction stream given. Instructions are a graph and executing means traversing it.
|
||||||
# If there is no next instruction the machine stops
|
# If there is no next instruction the machine stops
|
||||||
|
@ -8,10 +8,8 @@ module VirtualHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def check
|
def check
|
||||||
machine = Virtual::Machine.new
|
machine = Virtual::Machine.boot
|
||||||
parts = machine.read @string_input
|
expressions = machine.compile_main @string_input
|
||||||
main = Virtual::MethodDefinition.main
|
|
||||||
expressions = parts.compile( main, machine.message )
|
|
||||||
should = YAML.load(@output.gsub("RETURN_MARKER" , "\n"))
|
should = YAML.load(@output.gsub("RETURN_MARKER" , "\n"))
|
||||||
assert_equal should , expressions , expressions.to_yaml.gsub("\n" , "RETURN_MARKER") + "\n" + expressions.to_yaml
|
assert_equal should , expressions , expressions.to_yaml.gsub("\n" , "RETURN_MARKER") + "\n" + expressions.to_yaml
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user