Commit 96b7dc56 authored by POTTIER Francois's avatar POTTIER Francois

Movement.

parent 8fad94a2
......@@ -140,11 +140,6 @@ end
include R
(* This makes it easy to define memoizing functions of type [regexp -> _]. *)
module M =
Memoize.ForHashedType(R)
(* -------------------------------------------------------------------------- *)
(* The empty expression [0] is encoded as 0-ary disjunction. *)
......@@ -187,6 +182,23 @@ let rec (@@) (e1 : regexp) (e2 : regexp) : regexp =
(* -------------------------------------------------------------------------- *)
(* Iteration. *)
let star (e : regexp) : regexp =
match skeleton e with
| EEpsilon
| EStar _ ->
(* [epsilon*] is [epsilon]. *)
(* [e**] is [e*]. *)
e
| EDisj [] ->
(* [0*] is [epsilon]. *)
epsilon
| _ ->
make (EStar e)
(* -------------------------------------------------------------------------- *)
(* Disjunction. *)
let universal e =
......@@ -235,21 +247,6 @@ let (&&&) e1 e2 =
(* -------------------------------------------------------------------------- *)
(* Iteration. *)
let star (e : regexp) : regexp =
match skeleton e with
| EEpsilon
| EStar _ ->
(* [epsilon*] is [epsilon]. *)
(* [e**] is [e*]. *)
e
| EDisj [] ->
(* [0*] is [epsilon]. *)
epsilon
| _ ->
make (EStar e)
(* Negation. *)
let neg (e : regexp) : regexp =
......@@ -273,6 +270,9 @@ let neg (e : regexp) : regexp =
(* We memoize this function. (This is optional.) *)
module M =
Memoize.ForHashedType(R)
let nullable : regexp -> bool =
M.fix (fun nullable e ->
match skeleton e with
......
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