1 module FAunion
    2 
    3 ( unionTNFA
    4 )
    5 
    6 where
    7 
    8 
    9 import Set
   10 import FiniteMap
   11 
   12 import Stuff
   13 import Options
   14 
   15 import TA
   16 import FAtypes
   17 import Ids
   18 
   19 import FAmap
   20 import FAcmpct
   21 import FAconv
   22 
   23 ---------------------------------------------------------------------
   24 
   25 unionTNFA :: Opts -> TNFA Int -> TNFA Int -> TNFA Int
   26 unionTNFA opts x1 x2 =
   27     let 
   28         TNFA cons1 all1 starts1 moves1 = x1
   29         n1 = maximum (0 : (setToList all1)) + 1
   30 
   31         TNFA cons2 all2 starts2 moves2 = mapTNFA opts (n1 + )  x2
   32 
   33 --      added 17-sep-98
   34 --      this was sitting here for half a year at least.
   35 --      find out why it is wrong!
   36 --      top = maximum (0  : (setToList all2)) + 1
   37 
   38 --      and why this is better:
   39         top = maximum (n1 : (setToList all2)) + 1
   40 
   41         cons = cons1 `unionSet` cons2
   42 
   43         y = ETNFA cons 
   44                 ((all1 `unionSet` all2) `unionSet` unitSet top)
   45                 (unitSet top)
   46                 (plusFM_C (error "unionTNFA") moves1 moves2)
   47                 (unitFM top (starts1 `unionSet` starts2))
   48 
   49         e = etnfa2tnfa opts y
   50         f = cmpctTNFA opts e
   51 
   52 
   53     in  
   54 
   55 --      trace ("\nunionTNFA.x1 = " ++ show x1) $
   56 --      trace ("\nunionTNFA.x2 = " ++ show x2) $
   57 --      trace ("\nunionTNFA.n1 = " ++ show n1) $
   58 --      trace ("\nunionTNFA.top = " ++ show top) $
   59 --      trace ("\nunionTNFA.cons = " ++ show cons) $
   60 --      trace ("\nunionTNFA.y = " ++ show y) $
   61 --      trace ("\nunionTNFA.e = " ++ show e) $
   62 
   63         trinfo opts "union" f $
   64 
   65         f
   66 
   67 -------------------------------------------------------------------------