1995-08-09 08:06:35 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Objective Caml *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* Automatique. Distributed only by permission. *)
|
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
(* Auxiliaries for the parser. *)
|
|
|
|
|
|
|
|
open Syntax
|
|
|
|
|
|
|
|
let regexp_for_string s =
|
|
|
|
let l = String.length s in
|
|
|
|
if l = 0 then
|
|
|
|
Epsilon
|
|
|
|
else begin
|
|
|
|
let re = ref(Characters [String.get s (l - 1)]) in
|
|
|
|
for i = l - 2 downto 0 do
|
|
|
|
re := Sequence(Characters [String.get s i], !re)
|
|
|
|
done;
|
|
|
|
!re
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
let char_class c1 c2 =
|
1996-04-30 07:53:58 -07:00
|
|
|
let cl = ref [] in
|
1995-05-04 03:15:53 -07:00
|
|
|
for i = Char.code c2 downto Char.code c1 do
|
1996-04-30 07:53:58 -07:00
|
|
|
cl := Char.chr i :: !cl
|
1995-05-04 03:15:53 -07:00
|
|
|
done;
|
1996-04-30 07:53:58 -07:00
|
|
|
!cl
|
1995-05-04 03:15:53 -07:00
|
|
|
|
|
|
|
|
|
|
|
let all_chars = char_class '\001' '\255'
|
|
|
|
|
|
|
|
|
|
|
|
let rec subtract l1 l2 =
|
|
|
|
match l1 with
|
|
|
|
[] -> []
|
|
|
|
| a::l -> if List.mem a l2 then subtract l l2 else a :: subtract l l2
|
|
|
|
|