Skip to content

An interpreter for Turing Machines described in json files. All interesting information for formatting and specifications can be found in the pdf file.

License

Notifications You must be signed in to change notification settings

RadioPotin/ft-turing42

Repository files navigation

Ft_Turing Actions Status coverage percentage

Building

dune build @all

creates an executable

_build/default/src/ft-turing.exe

to which you can feed a .json file in which a given Turing machine is defined as well as an input to feed to said Turing Machine.

Testing

dune runtest

This will run all tests contained in the folder test.

Usage

./_build/default/src/ft-turing.exe <turingmachine.json> <input>

<input> being the input to feed to the turing machine described in

<turingmachine.json> being a file that defines a turing machine as follows:

    name: The name of the described machine.

    alphabet: Both input and work alphabet of the machine merged into a single alphabet for simplicity’s sake, including the blank character. Each character of the alphabet must be a string of length strictly equal to 1.

    blank: The blank character, must be part of the alphabet, must NOT be part of the input.

    states: The exhaustive list of the machine’s states names.

    initial: The initial state of the machine, must be part of the states list.

    finals: The exhaustive list of the machine’s final states. This list must be a sub-list of the states list.

    transitions: A dictionnary of the machine’s transitions indexed by state name. Each transition is a list of dictionnaries, and each dictionnary describes the transition fora given character under the head of the machine. A transition is defined as follows:

      read: The character of the machine’s alphabet on the tape under the machine’shead.

      to_state: The new state of the machine after the transition is done.

      write: The character of the machine’s alphabet to write on the tape before moving the head.

      action: Movement of the head for this transition, either LEFT, or RIGHT

    Running in Docker

    The repo has a Dockerfile with everything necessary for you to just run.

    Building image

    docker build -t <user>:<imagename> .
    

    Make sure to replace build name and user accordingly.

    Interactive mode

    docker run --rm -it --entrypoint bash <user>:<name>
    

    Running cli inside docker Either:

    1. Wrap commands in opam exec
    $ opam exec -- dune exec -- src/main.exe <machine> <input>
    
    1. eval $(opam env) to have all required binaries in your path
    $ eval $(opam env)
    $ dune exec -- src/main.exe <machine> <input>
    

About

An interpreter for Turing Machines described in json files. All interesting information for formatting and specifications can be found in the pdf file.

Resources

License

Stars

Watchers

Forks