I am working on an assignment for converting Regular Expressions into an NFA and for converting an NFA to DFA in OCAML. I have been writing my code in a separate file in order to test each "function" individually, but I have come across a problem when using the as-pattern.
NFA Definition:
(* Imports not shown. *)
let sidx = ref 0
let new_state() = sidx := !sidx + 1; !sidx
type state = int
type states = state BatSet.t
type delta = (state * alphabet, state BatSet.t) BatMap.t
type e_delta = (state, state BatSet.t) BatMap.t
type final = state BatSet.t
type init = state
(* ... *)
type t = states * delta * e_delta * init * final
(* create a new NFA with a single start state *)
let create_new_nfa () =
let is = new_state () in
(BatSet.singleton is, BatMap.empty, BatMap.empty, is, BatSet.empty)
(* ... More Function(s) Not Shown.*)
When I compile the code below on its own (i.e. I don't use a make file, but rather type the compile command input manually), I have no problem and it works just like how it is suppose too:
let regex2nfa : Regex.t -> Nfa.t
=fun regex ->
let ((state, delta, e_delta, init, final) as nfa) = Nfa.create_new_nfa () in (*Line 9*)
nfa
But when I use their make file, it complains by saying the following:
This doesn't make any sense. Nfa.t is of type:
'a * 'b * 'c * 'd * 'e
as shown with its declaration of:
type t = states * delta * e_delta * init * final
If I take out that tuple and just assigned the name "nfa" to the output of the create_new_nfa function, then it compiles just fine, but why on earth is this happening?
For reference, the make file can be found here