Module Ft_turing.Lang

type direction =
| Left
| Right

Type for action fields in transition definitions

type transition = string * string * direction

Type for transitions to_state:string * write:string * direction: Left | Right

val from_direction : direction -> string

from_direction action Function is used for printing and conversion of type direction to string

val to_direction : string -> direction

to_direction action Function is used in parsing to encode action fields in transitions definitions

val to_string : string -> Yojson.Basic.t -> string

to_string field json extracts string date from field in a Yojson.Basic.t object json. Calls Utils.err_invalid_type if type is incorrect

val to_string_list : string -> Yojson.Basic.t -> string list

to_string_option field json extracts string list data from field in a Yojson.Basic.t object json. Calls Utils.err_invalid_type if type is incorrect

val to_assoc_knv_list : string -> Yojson.Basic.t -> (string * Yojson.Basic.t) list

to_assoc_knv_list field json extracts a (string * Yojson.Basic.t) list from field that is contained in the json object. Calls Utils.err_invalid_type if type is incorrect

val get_transitions : Yojson.Basic.t -> (string * (string * string * direction)) list

get_transitions v returns a (read:string * (to_state:string * write:read * action:direction)) list found in Yojson.Basic.t object v. Calls Utils.err_invalid_type if type is incorrect

val to_transition_table : string list -> (string * Yojson.Basic.t) list -> ( string * string, transition ) Stdlib.Hashtbl.t

to_transition_table alphabet states transitions returns a (state:string * read:string) (to_state:string * write:read * action:direction) Hashtbl.t. This function also runs several kinds of sanity checks on the validity of transitions described in the json file

val to_transitions_tbl : string list -> string -> Yojson.Basic.t -> ( string * string, transition ) Stdlib.Hashtbl.t

to_transitions_tbl alphabet states field json converts the value contained in field in the json object to (string * Yojson.Basic.t) list and feeds to the function handling the conversion to a type Hashtbl.t

val to_states_tbl : Stdlib.String.t -> Stdlib.String.t list -> Stdlib.String.t list -> ( Stdlib.String.t, bool * bool ) Stdlib.Hashtbl.t

to_states_tbl initial finals states takes a string list of states, and converts it to a string (is_initial:bool * is_final:bool) Hashtbl and calls Utils.error if a given state appears several times in the "states" field in the json file

val get_value_and_check : string -> string -> ( string -> bool ) -> string

get_value_and_check errmsg v check simple generic function that takes an error message to feed to Utils.error if needed, a value v and a check function of type (v:string -> bool)

val convert_json : string -> Yojson.Basic.t

convert_json jsonfile takes jsonfile and converts it to a Yojson.Basic.t json object

val get_name : Yojson.Basic.t -> string -> Stdlib.String.t
val get_alphabet : Yojson.Basic.t -> string list
val get_blank : Yojson.Basic.t -> string list -> string
val get_initial : Yojson.Basic.t -> string list -> string
val get_final : Yojson.Basic.t -> string list -> string list
val to_machine : string -> Stdlib.String.t * string list * string * ( Stdlib.String.t, bool * bool ) Stdlib.Hashtbl.t * string * string list * ( string * string, transition ) Stdlib.Hashtbl.t

to_machnine jsonfile function parses the jsonfile and does all necessary sanity checks and conversions for the interpreter