Commit d2ea8627 authored by POTTIER Francois's avatar POTTIER Francois

Updated tests.

parent 627b3ec7
......@@ -4,14 +4,14 @@ let map = List.map
(* -------------------------------------------------------------------------- *)
(* Instantiate Brzozowski with an alphabet restricted to 'a'-'z', ' ', '$'. *)
(* Instantiate Brzozowski with an alphabet restricted to 'a'-'e' and '$'. *)
module B = Brzozowski.Make(struct
include Char
let hash = Hashtbl.hash
let foreach f =
for i = Char.code 'a' to Char.code 'z' do f (Char.chr i) done;
List.iter f [ ' '; '$' ]
for i = Char.code 'a' to Char.code 'e' do f (Char.chr i) done;
List.iter f [ '$' ]
let print c =
Printf.sprintf "%c" c
end)
......@@ -133,31 +133,33 @@ let _ =
rejected = [ "ca$"; "ac$"; "abcb$"; ];
}
(* A keyword recognizer. *)
(* An automaton that tests whether a word belongs in a dictionary. *)
let keywords =
[ "if"; "then"; "else"; "begin"; "end"; "do"; "done"; ]
[ "cab"; "bed"; "ace"; "add"; "dead"; "dad"; ]
let k =
one @@ (keywords |> map word |> disjunction)
let dict =
keywords |> map word |> disjunction
let _ =
register {
basename = "k";
regexp = k;
accepted = [ "if"; "we are not done eating"; "until the end of time"; ];
rejected = [ "never shall he come back"; ];
basename = "dict";
regexp = dict;
accepted = [ "cab"; "added"; "dead"; ];
rejected = [ "deed"; ];
}
let kd =
k @@ eof
(* An automaton that searches for a word that belongs in a dictionary. *)
let k =
one @@ (keywords |> map word |> disjunction)
let _ =
register {
basename = "kd";
regexp = kd;
accepted = [ "if$"; ];
rejected = [ "iff"; "if"; "toto"; ];
basename = "k";
regexp = k;
accepted = [ "abed"; "bace"; ];
rejected = [ "beca"; ];
}
(* Main. *)
......
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