Module Bmdfsmc (.ml)


module Bmdfsmc: sig .. end
Bombs-Must-Detonate: FSM Syntax Extension Compiler

Bombs-Must-Detonate: FSM Syntax Extension Signature
Author(s): Brian Go, Brian Go


exception Fsm_error of string
val raise_fsm_error : string list -> 'a
val concat : string list -> string
type state_node = int * int list * bool Pervasives.ref 
A node in the state graph used for connectivity checking

id, target id list, visited flag

A node in the state graph used for connectivity checking

id, target id list, visited flag

val node_list : (int * int list * bool Pervasives.ref) list Pervasives.ref
State Graph
val state_env : (int * string) list Pervasives.ref
State Id -> State name association
val get_state_name : int -> string
Returns the state name given an id
val reverse_assoc : ('a * 'b) list -> ('b * 'a) list
Reverses key/value pairs of an association list
val get_state_helper : (int * 'a * 'b) list -> int -> int * 'a * 'b
Retrieves the state_node object with the given id from the given graph
val get_state : int -> int * int list * bool Pervasives.ref
Retrieves the state_node object with the given id from the globally defined graph
val visit_graph : (int * int list * bool Pervasives.ref) list -> unit
Visit all nodes stemming from nodes in node_list
val check_connected : (int * int list * bool Pervasives.ref) list ->
(int * 'a * bool Pervasives.ref) list -> unit
Check if the graph node_list with root(s) start_nodes is connected
val cur_id : int Pervasives.ref
Used by make_id()
val make_id : unit -> int
Returns a unique integer every call
val get_first : ('a * 'b) list -> 'a list
Returns the first element of any 2-tuple
val get_state_names : ('a * 'b * 'c) list -> 'a list
Gets a string list of state names from a list of state_nodes
val append_string : string -> string -> string
Appends the first string to the second
val get_id : 'a -> ('a * int) list -> int * ('a * int) list
Checks if the id is associated with some name in the environment. If it is, returns the name, and then unchanged environment. If it isn't, creates a new ID, adds it to the environment, and returns them
val varify : string -> Ast.value_producer
Turns a string into a AST variable identifier
val compile_callbacks : Ast.fsm_callback list -> string -> Ast.expression list
Compiles the callback list of a state
val compile_transition_target : 'a * float ->
string -> ('a * int) list -> Ast.expression list * ('a * int) list * int
Compile a transition target of a state. A transition target is a state name with a weight. If there are multiple targets then the individual weight divided by the total weight is the probability that target state is visited next.
val compile_transition_targets : ('a * float) list ->
string -> ('a * int) list -> Ast.expression list * ('a * int) list * int list
Compiles all transition targets of a given state. See compile_transition_target
val compile_transition : string list * ('a * float) list ->
string -> ('a * int) list -> Ast.expression list * ('a * int) list * int list
Compiles a given transition in a state. A transition is a list of predicates which act on the fsmStateInformation object (see lib_fsm.bmd), all of which much be satisfied to visit (non-deterministaically) one of the transition targets.
val compile_transitions : (string list * ('a * float) list) list ->
string -> ('a * int) list -> Ast.expression list * ('a * int) list * int list
Compiles all transitions of a given state. See compile_transition
val compile_states_helper : (string * Ast.fsm_callback list * (string list * (string * float) list) list)
list -> (string * int) list -> Ast.expression list
Compiles all states. A state has an initialization function called every time it is visited, a set of game event callback functions, and transitions to other states. The mechanism of state transition is described in lib_fsm.bmd.
val compile_set_statelist : string list -> 'a -> Ast.expression list
Produces code to set the state list of the finite state machine to the given state names
val compile_states : (string * Ast.fsm_callback list * (string list * (string * float) list) list)
list -> 'a -> Ast.expression list
Compiles the state list and sets the initial state of the FSM. See compile_states_helper.
val compile_fsm : Ast.global_expression list -> Ast.global_expression list
Compiles each state machine described in the AST, leaving other syntax elements untouched.

Performs source-to-source compilation on the finite state machine code. The result of any state machine declaration is a function which returns the described state machine as a finiteStateMachine (see lib_fsm.bmd).