项目作者: magnostherobot

项目描述 :
Turing Machine Emulator written in Nim
高级语言: Nim
项目地址: git://github.com/magnostherobot/machines.git
创建时间: 2018-06-12T14:40:35Z
项目社区:https://github.com/magnostherobot/machines

开源协议:

下载


Running the Emulator

The source provided can be compiled in two separate ways: interpreter and
crunched.

Interpreter Mode

Interpreter is the recommended method for viewing the emulator’s
features, and is used as so:

  1. nim c tm.nim

This line produces the executable tm as an interpreter, used as such:

  1. ./tm DESCRIPTION INPUT

where DESCRIPTION is the name of a Turing machine description file (less the
.tm extension) and INPUT the string to test in the described TM.
The emulator will print, for each transition: the tape contents around the
selected cell; the name of the current state; and the number of iterations
since initialisation. If the emulation halts, true is printed if it halted
in an accepting state, and false is printed otherwise.

Crunched Mode

Crunched mode reads in a selected TM description file and creates an
executable binary file capable of checking input strings for the described TM.

Crunching is done like so:

  1. nim c -d:tmname=DESCRIPTION tm.nim

Alternatively, a utility script compile has been included in the submission.
The following line crunches a TM description file woa.tm and produces
executable woa:

  1. ./compile woa

Using the cruched executable woa would be done like so:

  1. ./woa INPUT

Crunched executables only output a true/false, and are
designed with testing and long-running emulation in mind.

enihcaM gniruT

A second program, mt.nim, is provided. It can read in the validation tests,
and create a TM that passes only on the input strings provided as true in the
test files. It can then output the description of this TM (if passed no
arguments), or run it against an input string. This program takes in the
validation test file at compile-time, like so:

  1. nim c -d:tmname=VALIDATION mt.nim

where VALIDATION is the name of the validation test file to be crunched, less
the file extension.

Emulator Design

The emulator written in Nim takes any valid TM description file and creates an
internal representation of the described TM in memory.