summaryrefslogtreecommitdiff
path: root/lex
diff options
context:
space:
mode:
authorDamien Doligez <damien.doligez-inria.fr>2010-01-22 12:48:24 +0000
committerDamien Doligez <damien.doligez-inria.fr>2010-01-22 12:48:24 +0000
commit04b1656222698bd7e92f213e9a718b7a4185643a (patch)
tree6186d1ba1e00adb1232908f95cb92c299902a943 /lex
parentbdc0fadee2dc9669818955486b4c3497016edda5 (diff)
downloadocaml-04b1656222698bd7e92f213e9a718b7a4185643a.tar.gz
clean up spaces and tabs
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9547 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'lex')
-rw-r--r--lex/compact.ml7
-rw-r--r--lex/compact.mli2
-rw-r--r--lex/cset.ml2
-rw-r--r--lex/cset.mli5
-rw-r--r--lex/lexgen.ml66
-rw-r--r--lex/lexgen.mli5
-rw-r--r--lex/main.ml9
-rw-r--r--lex/table.mli4
8 files changed, 44 insertions, 56 deletions
diff --git a/lex/compact.ml b/lex/compact.ml
index 9475ab6e57..abbf5a5036 100644
--- a/lex/compact.ml
+++ b/lex/compact.ml
@@ -169,7 +169,7 @@ type lex_tables =
tbl_backtrk_code : int array; (* nothing / code when Remember *)
(* moves to execute before transitions (compacted) *)
tbl_default_code : int array;
- tbl_trans_code : int array;
+ tbl_trans_code : int array;
tbl_check_code : int array;
(* byte code itself *)
tbl_code: int array;}
@@ -200,7 +200,7 @@ let compact_tables state_v =
base_code.(i) <- b_moves; default_code.(i) <- d_moves ;
done;
let code = Table.trim code in
- let tables =
+ let tables =
if Array.length code > 1 then
{ tbl_base = base;
tbl_backtrk = backtrk;
@@ -229,6 +229,3 @@ let compact_tables state_v =
reset_compact trans ;
reset_compact moves ;
tables
-
-
-
diff --git a/lex/compact.mli b/lex/compact.mli
index e52dc7d2c8..18363c3d4d 100644
--- a/lex/compact.mli
+++ b/lex/compact.mli
@@ -24,7 +24,7 @@ type lex_tables =
tbl_backtrk_code : int array; (* nothing / code when Remember *)
(* moves to execute before transitions (compacted) *)
tbl_default_code : int array;
- tbl_trans_code : int array;
+ tbl_trans_code : int array;
tbl_check_code : int array;
(* byte code itself *)
tbl_code: int array;}
diff --git a/lex/cset.ml b/lex/cset.ml
index ec68ee1c8b..c4594540ec 100644
--- a/lex/cset.ml
+++ b/lex/cset.ml
@@ -95,5 +95,3 @@ let env_to_array env = match env with
c)
rem ;
res
-
-
diff --git a/lex/cset.mli b/lex/cset.mli
index fc2c9930c3..3160cc908b 100644
--- a/lex/cset.mli
+++ b/lex/cset.mli
@@ -15,7 +15,7 @@
(* Set of characters encoded as list of intervals *)
-type t
+type t
exception Bad
val empty : t
@@ -32,6 +32,3 @@ val inter : t -> t -> t
val diff : t -> t -> t
val complement : t -> t
val env_to_array : (t * 'a) list -> 'a array
-
-
-
diff --git a/lex/lexgen.ml b/lex/lexgen.ml
index 1a12f0d49d..775e78b056 100644
--- a/lex/lexgen.ml
+++ b/lex/lexgen.ml
@@ -37,7 +37,7 @@ type regexp =
| Star of regexp
type tag_base = Start | End | Mem of int
-type tag_addr = Sum of (tag_base * int)
+type tag_addr = Sum of (tag_base * int)
type ident_info =
| Ident_string of bool * tag_addr * tag_addr
| Ident_char of bool * tag_addr
@@ -298,7 +298,7 @@ let rec encode_regexp char_vars act = function
(* Optimisation,
Static optimization :
Replace tags by offsets relative to the beginning
- or end of matched string.
+ or end of matched string.
Dynamic optimization:
Replace some non-optional, non-double tags by offsets w.r.t
a previous similar tag.
@@ -448,7 +448,7 @@ let opt_regexp all_vars char_vars optional_vars double_vars r =
let a = get_tag_addr (n.id,n.start) in
r,Some a
end
-
+
| Empty -> r,pos
| Chars (_,is_eof) -> r,(if is_eof then pos else add_pos pos 1)
| Seq (r1,r2) ->
@@ -465,10 +465,10 @@ let opt_regexp all_vars char_vars optional_vars double_vars r =
| Action _ -> assert false in
let r,_ = alloc_exp None r in
- let m =
+ let m =
IdSet.fold
(fun ((name,_) as x) r ->
-
+
let v =
if IdSet.mem x char_vars then
Ident_char
@@ -482,8 +482,8 @@ let opt_regexp all_vars char_vars optional_vars double_vars r =
all_vars [] in
m,r, !loc_count
-
-
+
+
let encode_casedef casedef =
let r =
List.fold_left
@@ -520,7 +520,7 @@ let encode_lexdef def =
(chr, entry_list)
(* To generate directly a NFA from a regular expression.
- Confer Aho-Sethi-Ullman, dragon book, chap. 3
+ Confer Aho-Sethi-Ullman, dragon book, chap. 3
Extension to tagged automata.
Confer
Ville Larikari
@@ -533,7 +533,7 @@ let encode_lexdef def =
*)
type t_transition =
- OnChars of int
+ OnChars of int
| ToAction of int
type transition = t_transition * Tags.t
@@ -608,7 +608,7 @@ let followpos size entry_list =
fill (TransSet.union (firstpos r) s) r in
List.iter (fun (entry,_,_) -> fill TransSet.empty entry.lex_regexp) entry_list ;
v
-
+
(************************)
(* The algorithm itself *)
(************************)
@@ -654,7 +654,7 @@ let dstate {final=(act,(_,m)) ; others=o} =
(fun () -> prerr_endline "")
o
-
+
let dfa_state_empty =
{final=(no_action, (max_int,TagMap.empty)) ;
others=MemMap.empty}
@@ -663,7 +663,7 @@ and dfa_state_is_empty {final=(act,_) ; others=o} =
act = no_action &&
o = MemMap.empty
-
+
(* A key is an abstraction on a dfa state,
two states with the same key can be made the same by
copying some memory cells into others *)
@@ -688,14 +688,14 @@ type dfa_key = {kstate : StateSet.t ; kmem : MemKey.t}
(* Map a state to its key *)
let env_to_class m =
- let env1 =
+ let env1 =
MemMap.fold
(fun _ (tag,s) r ->
try
let ss = TagMap.find tag r in
let r = TagMap.remove tag r in
TagMap.add tag (StateSetSet.add s ss) r
- with
+ with
| Not_found ->
TagMap.add tag (StateSetSet.add s StateSetSet.empty) r)
m TagMap.empty in
@@ -739,23 +739,23 @@ let key_compare k1 k2 = match StateSet.compare k1.kstate k2.kstate with
| r -> r
(* Association dfa_state -> state_num *)
-
+
module StateMap =
Map.Make(struct type t = dfa_key let compare = key_compare end)
let state_map = ref (StateMap.empty : int StateMap.t)
-let todo = Stack.create()
+let todo = Stack.create()
let next_state_num = ref 0
let next_mem_cell = ref 0
let temp_pending = ref false
-let tag_cells = Hashtbl.create 17
+let tag_cells = Hashtbl.create 17
let state_table = Table.create dfa_state_empty
(* Initial reset of state *)
let reset_state () =
Stack.clear todo;
- next_state_num := 0 ;
+ next_state_num := 0 ;
let _ = Table.trim state_table in
()
@@ -878,14 +878,14 @@ let get_map t st = match t with
m
let dest = function | Copy (d,_) | Set d -> d
-and orig = function | Copy (_,o) -> o | Set _ -> -1
+and orig = function | Copy (_,o) -> o | Set _ -> -1
let pmv oc mv = fprintf oc "%d <- %d" (dest mv) (orig mv)
let pmvs oc mvs =
List.iter (fun mv -> fprintf oc "%a " pmv mv) mvs ;
output_char oc '\n' ; flush oc
-
+
(* Topological sort << a la louche >> *)
let sort_mvs mvs =
let rec do_rec r mvs = match mvs with
@@ -917,7 +917,7 @@ let sort_mvs mvs =
end
| _ -> do_rec (here@r) rem in
do_rec [] mvs
-
+
let move_to mem_key src tgt =
let mvs =
MemKey.fold
@@ -943,7 +943,7 @@ let move_to mem_key src tgt =
sort_mvs mvs
-let get_state st =
+let get_state st =
let key = get_key st in
try
let num = StateMap.find key !state_map in
@@ -992,7 +992,7 @@ let add_tags_to_map gen tags m =
let apply_transition gen r pri m = function
| ToAction n,tags ->
let on,(opri,_) = r.final in
- if n < on || (on=n && pri < opri) then
+ if n < on || (on=n && pri < opri) then
let m = add_tags_to_map gen tags m in
{r with final=n,(pri,m)}
else r
@@ -1000,7 +1000,7 @@ let apply_transition gen r pri m = function
try
let (opri,_) = MemMap.find n r.others in
if pri < opri then
- let m = add_tags_to_map gen tags m in
+ let m = add_tags_to_map gen tags m in
{r with others=MemMap.add n (pri,m) (MemMap.remove n r.others)}
else
r
@@ -1018,7 +1018,7 @@ let apply_transitions gen r pri m ts =
ts r
-(* For a given nfa_state pos, refine char partition *)
+(* For a given nfa_state pos, refine char partition *)
let rec split_env gen follow pos m s = function
| [] -> (* Can occur ! because of non-matching regexp ([^'\000'-'\255']) *)
[]
@@ -1033,20 +1033,20 @@ let rec split_env gen follow pos m s = function
rem
else
split_env gen follow pos m rest rem
- and new_st = apply_transitions gen st1 pos m follow in
+ and new_st = apply_transitions gen st1 pos m follow in
let stay = Cset.diff s1 here in
if Cset.is_empty stay then
(here, new_st)::rem
else
(stay, st1)::(here, new_st)::rem
-
+
(* For all nfa_state pos in a dfa state st *)
let comp_shift gen chars follow st =
MemMap.fold
(fun pos (_,m) env -> split_env gen follow.(pos) pos m chars.(pos) env)
st [Cset.all_chars_eof,dfa_state_empty]
-
+
let reachs chars follow st =
let gen = create_new_addr_gen () in
@@ -1058,7 +1058,7 @@ let reachs chars follow st =
(fun (s,dfa_state) -> s,goto_state dfa_state) env in
(* finally build the char indexed array -> new state num *)
let shift = Cset.env_to_array env in
- shift
+ shift
let get_tag_mem n env t =
@@ -1082,8 +1082,8 @@ let do_tag_actions n env m =
used,r)
env.(n) (used,r) in
r
-
-
+
+
let translate_state shortest_match tags chars follow st =
let (n,(_,m)) = st.final in
if MemMap.empty = st.others then
@@ -1106,7 +1106,7 @@ let dtags chan tags =
Tags.iter
(fun t -> fprintf chan " %a" dtag t)
tags
-
+
let dtransset s =
TransSet.iter
(fun trans -> match trans with
@@ -1169,7 +1169,7 @@ let make_dfa lexdef =
map_on_all_states
(translate_state shortest tags chars follow) !r_states ;
{ auto_name = le.lex_name;
- auto_args = args ;
+ auto_args = args ;
auto_mem_size =
(if !temp_pending then !next_mem_cell+1 else !next_mem_cell) ;
auto_initial_state = init_num ;
diff --git a/lex/lexgen.mli b/lex/lexgen.mli
index 5c9c1bc757..5136f8f283 100644
--- a/lex/lexgen.mli
+++ b/lex/lexgen.mli
@@ -14,7 +14,7 @@
(* raised when there are too many bindings (>= 254 memory cells) *)
-exception Memory_overflow
+exception Memory_overflow
(* Representation of automata *)
@@ -39,7 +39,7 @@ type ident = string * Syntax.location
(* Representation of entry points *)
type tag_base = Start | End | Mem of int
-type tag_addr = Sum of (tag_base * int)
+type tag_addr = Sum of (tag_base * int)
type ident_info =
| Ident_string of bool * tag_addr * tag_addr
| Ident_char of bool * tag_addr
@@ -58,4 +58,3 @@ type ('args,'action) automata_entry =
val make_dfa :
('args, 'action) Syntax.entry list ->
('args, 'action) automata_entry list * automata array
-
diff --git a/lex/main.ml b/lex/main.ml
index 280537ca1b..5540c97285 100644
--- a/lex/main.ml
+++ b/lex/main.ml
@@ -36,7 +36,7 @@ let specs =
"-q", Arg.Set Common.quiet_mode, " Do not display informational messages";
"-v", Arg.Unit print_version_string, " Print version and exit";
"-version", Arg.Unit print_version_string, " Print version and exit";
- ]
+ ]
let _ =
Arg.parse
@@ -44,11 +44,11 @@ let _ =
(fun name -> source_name := Some name)
usage
-
+
let main () =
let source_name = match !source_name with
- | None -> Arg.usage specs usage ; exit 2
+ | None -> Arg.usage specs usage ; exit 2
| Some name -> name in
let dest_name = match !output_name with
| Some name -> name
@@ -105,7 +105,7 @@ let main () =
| Lexgen.Memory_overflow ->
Printf.fprintf stderr
"File \"%s\":\n Position memory overflow, too many bindings\n"
- source_name
+ source_name
| Output.Table_overflow ->
Printf.fprintf stderr
"File \"%s\":\ntransition table overflow, automaton is too big\n"
@@ -116,4 +116,3 @@ let main () =
exit 3
let _ = (* Printexc.catch *) main (); exit 0
-
diff --git a/lex/table.mli b/lex/table.mli
index e5d55f9652..b88d7d3454 100644
--- a/lex/table.mli
+++ b/lex/table.mli
@@ -13,7 +13,7 @@
(* Table used for code emission, ie extensible arrays *)
type 'a t
-val create : 'a -> 'a t
+val create : 'a -> 'a t
val emit : 'a t -> 'a -> unit
@@ -29,5 +29,3 @@ val get : 'a t -> int -> 'a
val size : 'a t -> int
-
-