Commit 7bab897a authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-03-23 10:08:53 by cvscast] Empty log message

Original author: cvscast
Date: 2003-03-23 10:08:54+00:00
parent c05be6dd
......@@ -51,10 +51,14 @@ struct
match (a,b) with
| Split (h1,x1, p1,i1,n1), Split (h2,x2, p2,i2,n2) ->
(h1 == h2) &&
(X.equal x1 x2) && (equal p1 p2) & (equal i1 i2) &&
(equal n1 n2)
(equal p1 p2) && (equal i1 i2) &&
(equal n1 n2) && (X.equal x1 x2)
| _ -> false
(* Idea: add a mutable "unique" identifier and set it to
the minimum of the two when egality ... *)
let rec compare a b =
if (a == b) then 0
else match (a,b) with
......@@ -133,6 +137,7 @@ struct
| True -> (pos,neg) :: accu
| False -> accu
| Split (_,x, p,i,n) ->
(*OPT: can avoid creating this list cell when pos or neg =False *)
let accu = get accu (x::pos) neg p in
let accu = get accu pos (x::neg) n in
let accu = get accu pos neg i in
......@@ -175,6 +180,31 @@ struct
- no ``subsumption'
*)
let rec simplify a b =
if equal a b then False
else match (a,b) with
| False,_ | _, True -> False
| a, False -> a
| True, _ -> True
| Split (_,x1,p1,i1,n1), Split (_,x2,p2,i2,n2) ->
let c = X.compare x1 x2 in
if c = 0 then
let p1' = simplify (simplify p1 i2) p2
and i1' = simplify i1 i2
and n1' = simplify (simplify n1 i2) n2 in
if (p1 != p1') || (n1 != n1') || (i1 != i1')
then split x1 p1' i1' n1'
else a
else if c > 0 then
simplify a i2
else
let p1' = simplify p1 b
and i1' = simplify i1 b
and n1' = simplify n1 b in
if (p1 != p1') || (n1 != n1') || (i1 != i1')
then split x1 p1' i1' n1'
else a
(*
let rec simplify a l =
if (a = False) then False else simpl_aux1 a [] l
and simpl_aux1 a accu = function
......@@ -209,9 +239,10 @@ struct
simpl_aux2 x p i n (b :: ap) (b :: ai) (b :: an) l
else
simpl_aux2 x p i n (p2 :: i2 :: ap) (i2 :: ai) (n2 :: i2 :: an) l
*)
let split x p i n =
split x (simplify p [i]) i (simplify n [i])
split x (simplify p i) i (simplify n i)
let rec ( ++ ) a b =
(* if equal a b then a *)
......
......@@ -463,7 +463,9 @@ let fun do_table (X_table -> String) _ -> raise "<table> nothandled";;
do_tbodies
*)
match load_xml "tst_html2latex.xml" with
| x & X_html -> print (do_html x)
| _ -> raise "Input file is not XHTML !";;
......@@ -2,10 +2,10 @@ include "../web/xhtml-strict.cd";;
let fun f (x : Xhtml) : [ Xhtml ] =
ttree [ x ] with <a>t -> [];;
let fun g (x : Xhtml) : [ Xhtml ] =
ttree [ x ] with <a>t -> [ <b>t ];;
(*
type T = <a>[ <b>[] T* <b>[] ];;
......
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