diff options
Diffstat (limited to 'lib/machine.rb')
-rw-r--r-- | lib/machine.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/machine.rb b/lib/machine.rb new file mode 100644 index 0000000..ae8b6de --- /dev/null +++ b/lib/machine.rb @@ -0,0 +1,42 @@ +module VFSM + class Machine + attr_reader :currentnodes + + def initialize(machineDefinition) + @currentnodes = [] + end + + def handleinput(inputString) + end + + class << self + def printnodes nodes + print "{ " + (0..(nodes.length - 1)).each do |x| + if nodes[x].accepting? then + print "((#{nodes[x].id}))" + else + print "(#{nodes[x].id})" + end + print ", " unless x == (nodes.length - 1) + end + print " }" + end + + def recurse nodeslist + begin + oldlist = nodeslist.dup + oldlist.each do |node| + tmp = node.goto :lambda + unless tmp == :reject then + tmp.each do |x| + nodeslist.push x + end + end + end + nodeslist.uniq! + end while oldlist != nodeslist + end + end + end +end |