Mentions légales du service

Skip to content
Snippets Groups Projects
Commit ff8c47d7 authored by POTTIER Francois's avatar POTTIER Francois
Browse files

Modified [E] to use [MySet] instead of [MyMap].

No speed gain, but this allows removing [MyMap].
parent 9fdf7eef
No related branches found
No related tags found
No related merge requests found
...@@ -88,7 +88,6 @@ let foreach_terminal_not_causing_an_error s f = ...@@ -88,7 +88,6 @@ let foreach_terminal_not_causing_an_error s f =
(* ------------------------------------------------------------------------ *) (* ------------------------------------------------------------------------ *)
let id x = x let id x = x
let some x = Some x
let update add find none some key m f = let update add find none some key m f =
match find key m with match find key m with
...@@ -102,12 +101,6 @@ let update add find none some key m f = ...@@ -102,12 +101,6 @@ let update add find none some key m f =
let data' = f none in let data' = f none in
add key data' m add key data' m
module MyMap (X : Map.OrderedType) = struct
include Map.Make(X)
let update none some key m f =
update add find none some key m f
end
module W : sig module W : sig
type word type word
...@@ -375,9 +368,9 @@ end = struct ...@@ -375,9 +368,9 @@ end = struct
(* For now, we implement a mapping of [s, nt, a, z] to [w]. *) (* For now, we implement a mapping of [s, nt, a, z] to [w]. *)
module M = module M =
MyMap(struct MySet.Make(struct
type t = Nonterminal.t * Terminal.t * Terminal.t type t = Nonterminal.t * Terminal.t * Terminal.t * W.word
let compare (nt1, a1, z1) (nt2, a2, z2) = let compare (nt1, a1, z1, _w1) (nt2, a2, z2, _w2) =
let c = Nonterminal.compare nt1 nt2 in let c = Nonterminal.compare nt1 nt2 in
if c <> 0 then c else if c <> 0 then c else
let c = Terminal.compare a1 a2 in let c = Terminal.compare a1 a2 in
...@@ -394,13 +387,7 @@ end = struct ...@@ -394,13 +387,7 @@ end = struct
let i = Lr1.number s in let i = Lr1.number s in
let m = table.(i) in let m = table.(i) in
let a = W.first w z in let a = W.first w z in
let m' = M.update None some (nt, a, z) m (function let m' = M.add (nt, a, z, w) m in
| None ->
w
| Some earlier_w ->
earlier_w
)
in
m != m' && begin m != m' && begin
incr count; incr count;
table.(i) <- m'; table.(i) <- m';
...@@ -410,8 +397,9 @@ end = struct ...@@ -410,8 +397,9 @@ end = struct
let query s nt a z f = let query s nt a z f =
let i = Lr1.number s in let i = Lr1.number s in
let m = table.(i) in let m = table.(i) in
match M.find (nt, a, z) m with let dummy = W.epsilon in
| w -> f w match M.find (nt, a, z, dummy) m with
| (_, _, _, w) -> f w
| exception Not_found -> () | exception Not_found -> ()
let stats () = let stats () =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment