diff options
author | Nathan Lasseter <nathan@4574.co.uk> | 2014-03-30 16:21:25 +0100 |
---|---|---|
committer | Nathan Lasseter <nathan@4574.co.uk> | 2014-03-30 16:21:25 +0100 |
commit | 752b10d4b0b607344d6ef2113231378ec295d3b8 (patch) | |
tree | fdf9372b48b0c2c91fedcc5a8d7b01e3ed806731 /lib | |
parent | 1e799f72df429beceb42aa8d1ce640e5e2c5210e (diff) |
Diffstat (limited to 'lib')
-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 |