Commit ecbab0ba authored by POTTIER Francois's avatar POTTIER Francois

Use more local modules.

parent 96b7dc56
...@@ -270,10 +270,8 @@ let neg (e : regexp) : regexp = ...@@ -270,10 +270,8 @@ let neg (e : regexp) : regexp =
(* We memoize this function. (This is optional.) *) (* We memoize this function. (This is optional.) *)
module M =
Memoize.ForHashedType(R)
let nullable : regexp -> bool = let nullable : regexp -> bool =
let module M = Memoize.ForHashedType(R) in
M.fix (fun nullable e -> M.fix (fun nullable e ->
match skeleton e with match skeleton e with
| EChar _ -> | EChar _ ->
...@@ -303,12 +301,10 @@ let nullable : regexp -> bool = ...@@ -303,12 +301,10 @@ let nullable : regexp -> bool =
star.) More precisely, for every character [a], [delta a] is a function of star.) More precisely, for every character [a], [delta a] is a function of
type [regexp -> regexp]: we memoize every function [delta a] separately. *) type [regexp -> regexp]: we memoize every function [delta a] separately. *)
(* A tabulator for functions of type [char -> _] is used for this purpose. *)
module T =
Tabulate.ForHashedType(Char)(Char)
let delta : Char.t -> regexp -> regexp = let delta : Char.t -> regexp -> regexp =
let module T = Tabulate.ForHashedType(Char)(Char) in
let module M = Memoize.ForHashedType(R) in
T.tabulate (fun a -> T.tabulate (fun a ->
M.fix (fun delta e -> M.fix (fun delta e ->
match skeleton e with match skeleton e with
...@@ -430,6 +426,7 @@ let dfa (e : regexp) : dfa = ...@@ -430,6 +426,7 @@ let dfa (e : regexp) : dfa =
(* There remains to tabulate the transition function. *) (* There remains to tabulate the transition function. *)
let transition = let transition =
let module Q = Tabulate.ForIntSegment(N) in let module Q = Tabulate.ForIntSegment(N) in
let module T = Tabulate.ForHashedType(Char)(Char) in
Q.tabulate (fun q -> T.tabulate (fun a -> Q.tabulate (fun q -> T.tabulate (fun a ->
encode (delta a (decode q)) encode (delta a (decode q))
)) ))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment