tools/unitCycles.hs
changeset 4367 f4a0ec067601
parent 4355 4554c4df9f1a
child 4382 935de6cd5ea3
equal deleted inserted replaced
4365:4f2b1a152979 4367:f4a0ec067601
    12 
    12 
    13 extractUnits :: PascalUnit -> (String, [String])
    13 extractUnits :: PascalUnit -> (String, [String])
    14 extractUnits (Program (Identificator name) (Implementation (Uses idents) _ _) _) = ("program " ++ name, map unident idents)
    14 extractUnits (Program (Identificator name) (Implementation (Uses idents) _ _) _) = ("program " ++ name, map unident idents)
    15 extractUnits (Unit (Identificator name) (Interface (Uses idents1) _) (Implementation (Uses idents2) _ _) _ _) = (name, map unident $ idents1 ++ idents2)
    15 extractUnits (Unit (Identificator name) (Interface (Uses idents1) _) (Implementation (Uses idents2) _ _) _ _) = (name, map unident $ idents1 ++ idents2)
    16 
    16 
    17 -- stronglyConnComp :: Ord key => [(node, key, [key])] -> [SCC node]
       
    18 
       
    19 f :: [(String, [String])] -> String
    17 f :: [(String, [String])] -> String
    20 f = unlines . map showSCC . stronglyConnComp . map (\(a, b) -> (a, a, b))
    18 f = unlines . map showSCC . stronglyConnComp . map (\(a, b) -> (a, a, b))
    21     where
    19     where
    22     showSCC (AcyclicSCC v) = v
    20     showSCC (AcyclicSCC v) = v
    23     showSCC (CyclicSCC vs) = intercalate ", " vs
    21     showSCC (CyclicSCC vs) = intercalate ", " vs