juggle into the machine
This commit is contained in:
parent
5d61fd1b37
commit
5add9c42f2
@ -33,11 +33,22 @@ module Virtual
|
|||||||
class Machine
|
class Machine
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
|
@parser = Parser::Salama.new
|
||||||
the_end = Halt.new
|
the_end = Halt.new
|
||||||
@message = Message.new(the_end , the_end , :Object)
|
@message = Message.new(the_end , the_end , :Object)
|
||||||
end
|
end
|
||||||
attr_reader :message
|
attr_reader :message
|
||||||
|
|
||||||
|
def self.boot
|
||||||
|
machine = Machine.new
|
||||||
|
machine.boot
|
||||||
|
end
|
||||||
|
|
||||||
|
def read string
|
||||||
|
syntax = @parser.parse_with_debug(string)
|
||||||
|
Parser::Transform.new.apply(syntax)
|
||||||
|
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
|
||||||
def run instruction
|
def run instruction
|
||||||
|
@ -8,10 +8,8 @@ module VirtualHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def check
|
def check
|
||||||
parser = Parser::Salama.new
|
|
||||||
syntax = parser.parse_with_debug(@string_input)
|
|
||||||
parts = Parser::Transform.new.apply(syntax)
|
|
||||||
machine = Virtual::Machine.new
|
machine = Virtual::Machine.new
|
||||||
|
parts = machine.read @string_input
|
||||||
main = Virtual::MethodDefinition.main
|
main = Virtual::MethodDefinition.main
|
||||||
expressions = parts.compile( main, machine.message )
|
expressions = parts.compile( main, machine.message )
|
||||||
should = YAML.load(@output.gsub("RETURN_MARKER" , "\n"))
|
should = YAML.load(@output.gsub("RETURN_MARKER" , "\n"))
|
||||||
|
Loading…
Reference in New Issue
Block a user