aboutsummaryrefslogtreecommitdiff
path: root/src/tmachines.nim
blob: 2d1d190f61fb7033d5071b53ca9bae326399681e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os, strutils

import docopt

from tmachinespkg/tm import nil

const tmname {.strdefine.}: string = ""

when tmname.len > 0:
  const tmd = parse(slurp(tmname))
  if paramCount() >= 1:
    echo makeDTM(tmd, paramStr(1)).test()
  else:
    echo "please specify a single string argument"
else:
  const doc = slurp("../USAGE.txt")

  let args = docopt(doc)
  let file = $args["<machine>"]

  if file.ends_with(".tm") or file.ends_with(".dtm"):
    let tmd = tm.parse(readFile($args["<machine>"]))
    echo tm.test(tm.makeDTM(tmd, $args["<input>"]), not args["--quiet"])