tools/unitCycles.hs
changeset 4353 671d66ba3af6
child 4355 4554c4df9f1a
equal deleted inserted replaced
4351:9d155da5b417 4353:671d66ba3af6
       
     1 module Main where
       
     2 
       
     3 import PascalParser
       
     4 import System
       
     5 import Control.Monad
       
     6 import Data.Either
       
     7 import Data.List
       
     8 
       
     9 unident :: Identificator -> String
       
    10 unident (Identificator s) = s
       
    11 
       
    12 extractUnits :: PascalUnit -> (String, [String])
       
    13 extractUnits (Program (Identificator name) (Implementation (Uses idents) _ _) _) = ("program " ++ name, map unident idents)
       
    14 extractUnits (Unit (Identificator name) (Interface (Uses idents1) _) (Implementation (Uses idents2) _ _) _ _) = (name, map unident $ idents1 ++ idents2)
       
    15 
       
    16 main = do
       
    17     fileNames <- getArgs
       
    18     files <- mapM readFile fileNames
       
    19     mapM_ (putStrLn . show . extractUnits) . rights . map parsePascalUnit $ files