adl.hs revision e9458b1a7a19a63aa4c179f9ab20f4d50681c168
446N/A{-# LANGUAGE CPP #-}
4744N/A{- |
446N/AModule : ./Adl/adl.hs
446N/ADescription : ADL syntax parser
446N/ACopyright : (c) Stef Joosten, Christian Maeder DFKI GmbH 2010
446N/ALicense : GPLv2 or higher, see LICENSE.txt
446N/A
446N/AMaintainer : Christian.Maeder@dfki.de
446N/AStability : provisional
446N/APortability : portable
446N/A-}
446N/A
446N/Amodule Main (main) where
446N/A
446N/Aimport Common.DocUtils (pretty)
446N/Aimport Common.Parsec ((<<))
446N/Aimport Common.Result
446N/Aimport Common.Lib.State
446N/Aimport Text.ParserCombinators.Parsec (parse, eof)
446N/A
873N/Aimport Adl.As
446N/Aimport Adl.Parse (skip, pArchitecture)
446N/Aimport Adl.Sign
446N/Aimport Adl.StatAna
446N/A
5073N/Aimport Adl.Print
5508N/A#ifdef LATEX
446N/A (adlGA)
446N/Aimport Common.PrintLaTeX
446N/Aimport Common.Doc
4744N/A#else
4744N/A ()
4744N/A#endif
4744N/A
4744N/Aimport System.Environment (getArgs)
4744N/Aimport System.Exit (exitFailure)
4744N/A
4744N/Amain :: IO ()
4744N/Amain = getArgs >>= mapM_ process
4744N/A
4744N/Aprocess :: String -> IO ()
4744N/Aprocess f = do
4744N/A s <- readFile f
4744N/A case parse (skip >> pArchitecture << eof) f s of
4744N/A Right (Context m ps) ->
4744N/A let (nps, env) = runState (mapM anaPatElem ps) (toEnv emptySign)
4744N/A es = Context m nps
4744N/A ds = reverse $ msgs env
4744N/A in if null ds then
4744N/A#ifdef LATEX
4744N/A putStrLn
4744N/A . renderLatex Nothing
5073N/A . toLatex adlGA
4744N/A#else
5073N/A print
4744N/A#endif
4744N/A $ pretty es
4744N/A else printDiags 5 ds >> exitFailure
4744N/A Left err -> fail $ show err
4744N/A