adl.hs revision cfcf65bef8fe90abc7a7ca801539dd80dc71d72d
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht{-# LANGUAGE CPP #-}
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht{- |
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon UlbrichtModule : $Header$
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon UlbrichtDescription : ADL syntax parser
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon UlbrichtCopyright : (c) Stef Joosten, Christian Maeder DFKI GmbH 2010
da4b55f4795a4b585f513eaceb67cda10485febfChristian MaederLicense : GPLv2 or higher
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon UlbrichtMaintainer : Christian.Maeder@dfki.de
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon UlbrichtStability : provisional
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon UlbrichtPortability : portable
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht-}
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbrichtmodule Main (main) where
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht
4bf72807172000becf65e11bd225efc1dfd99713Simon Ulbrichtimport Common.DocUtils (pretty)
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbrichtimport Common.Parsec ((<<))
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbrichtimport System.Environment (getArgs)
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbrichtimport Text.ParserCombinators.Parsec (parse, eof)
e4d1479434761dc3eb8d17b6c75de4eb24866f0bSimon Ulbricht
e4d1479434761dc3eb8d17b6c75de4eb24866f0bSimon Ulbrichtimport Adl.Parse (skip, pArchitecture)
e4d1479434761dc3eb8d17b6c75de4eb24866f0bSimon Ulbrichtimport Adl.Print
4bf72807172000becf65e11bd225efc1dfd99713Simon Ulbrichtimport Adl.Sign
846ef0914b29a4806ca0444c116fd3cf267c4fb7Christian Maederimport Adl.StatAna
846ef0914b29a4806ca0444c116fd3cf267c4fb7Christian Maeder#ifdef LATEX
e4d1479434761dc3eb8d17b6c75de4eb24866f0bSimon Ulbricht (adlGA)
8600e22385bce13c5d1048f7b955f9394a5d94d6Simon Ulbrichtimport Common.PrintLaTeX
4d1df661384f74cd15d2ceba8a9a3c4760e9ddfbSimon Ulbrichtimport Common.Doc
8600e22385bce13c5d1048f7b955f9394a5d94d6Simon Ulbricht#else
79eb29c05606f195fe9c6fdca02bcaa458dde17dSimon Ulbricht ()
e4d1479434761dc3eb8d17b6c75de4eb24866f0bSimon Ulbricht#endif
8fa27254f463e2c958a10dc513450b992f80137bSimon Ulbricht
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbrichtmain :: IO ()
804459c3af78eeee3fd3c940c74594febd030dacSimon Ulbrichtmain = getArgs >>= mapM_ process
da4b55f4795a4b585f513eaceb67cda10485febfChristian Maeder
4d1df661384f74cd15d2ceba8a9a3c4760e9ddfbSimon Ulbrichtprocess :: String -> IO ()
4bf72807172000becf65e11bd225efc1dfd99713Simon Ulbrichtprocess f = do
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht s <- readFile f
e4d1479434761dc3eb8d17b6c75de4eb24866f0bSimon Ulbricht case parse (skip >> pArchitecture << eof) f s of
4bf72807172000becf65e11bd225efc1dfd99713Simon Ulbricht Right (Context m ps) ->
846ef0914b29a4806ca0444c116fd3cf267c4fb7Christian Maeder let (nps, env) = runState (mapM anaPatElem ps) (toEnv emptySign)
e4d1479434761dc3eb8d17b6c75de4eb24866f0bSimon Ulbricht es = Context m nps
e4d1479434761dc3eb8d17b6c75de4eb24866f0bSimon Ulbricht in
e4d1479434761dc3eb8d17b6c75de4eb24866f0bSimon Ulbricht#ifdef LATEX
e4d1479434761dc3eb8d17b6c75de4eb24866f0bSimon Ulbricht putStrLn
94968509d2764786208bd34b59a93c7cbe3aa6dbSimon Ulbricht . renderLatex Nothing
e4d1479434761dc3eb8d17b6c75de4eb24866f0bSimon Ulbricht . toLatex adlGA
024d83266148fc53f9d6f82bedd0b8cb4a6213a9Simon Ulbricht#else
4bf72807172000becf65e11bd225efc1dfd99713Simon Ulbricht print
024d83266148fc53f9d6f82bedd0b8cb4a6213a9Simon Ulbricht#endif
024d83266148fc53f9d6f82bedd0b8cb4a6213a9Simon Ulbricht $ pretty es
fe6a19b07759bc4190e88dda76a211d86bf32062Simon Ulbricht Left err -> fail $ show err
fe6a19b07759bc4190e88dda76a211d86bf32062Simon Ulbricht