File: turing-graph.rb

package info (click to toggle)
ruby-tins 1.32.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,248 kB
  • sloc: ruby: 6,659; makefile: 3
file content (17 lines) | stat: -rwxr-xr-x 380 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env ruby

load File.join(File.dirname(__FILE__), 'turing.rb')
include Turing

filename, *tapes = ARGV
machine_type =
  case ext = File.extname(filename)
  when '.stm'
    SingleTapeMachine
  when '.mtm'
    MultiTapeMachine
  else
    raise "unknown turing machine suffix: #{ext}, use .stm or .mtm"
  end
tm = machine_type.new(File.read(filename))
print tm.to_graphviz