Commit 48411ba4 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2006-09-09 20:16:08 by afrisch] Print regexp of the form [ t? ... ]

Original author: afrisch
Date: 2006-09-09 20:16:08+00:00
parent b480a9dd
...@@ -497,9 +497,12 @@ module Decompile(H : TABLE)(S : S) = struct ...@@ -497,9 +497,12 @@ module Decompile(H : TABLE)(S : S) = struct
let s = slot n in let s = slot n in
if not s.ok then ( if not s.ok then (
s.ok <- true; s.ok <- true;
let (tr,f) = trans n in match trans n with
if f then add_trans s final epsilon; | `T (tr,f) ->
List.iter (fun (l,dst) -> add_trans s (conv dst) (rtrans l)) tr; if f then add_trans s final epsilon;
List.iter (fun (l,dst) -> add_trans s (conv dst) (rtrans l)) tr
| `Eps (l,dst) ->
add_trans s (conv dst) (alt (rtrans l) epsilon)
); );
s in s in
......
...@@ -26,5 +26,7 @@ end ...@@ -26,5 +26,7 @@ end
module Decompile(X : TABLE)(S : S) module Decompile(X : TABLE)(S : S)
: sig : sig
val decompile: (X.key -> (S.t * X.key) list * bool) -> X.key -> S.t regexp val decompile: (X.key -> [ `T of (S.t * X.key) list * bool
| `Eps of S.t * X.key]
) -> X.key -> S.t regexp
end end
...@@ -1544,8 +1544,26 @@ struct ...@@ -1544,8 +1544,26 @@ struct
let tr = Product.get t in let tr = Product.get t in
let tr = Product.clean_normal tr in let tr = Product.clean_normal tr in
let tr = List.map (fun (l,t) -> prepare l, t) tr in let eps = Atoms.contains nil_atom t.atoms in
tr, Atoms.contains nil_atom t.atoms) let tr_cons = List.map (fun (li,ti) -> (cons li, cons ti)) tr in
try
let (l0,t0) = List.find
(fun ((l0,t0) as tr0) ->
let t'' =
List.fold_left
(fun accu ((li,ti) as tri) ->
if tr0 == tri then accu
else cup accu (times li ti)
)
(if eps then nil_type else empty)
tr_cons
in
equiv (descr t0) t'' ) tr_cons in
`Eps (prepare (descr l0), descr t0)
with Not_found ->
let tr = List.map (fun (l,t) -> prepare l, t) tr in
`T (tr, eps))
d d
let gen = ref 0 let gen = ref 0
......
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