kesterel2lustre

compile Kernel Esterel to Lustre
git clone https://a3nm.net/git/kesterel2lustre/
Log | Files | Refs | README

main.hs (882B)


      1 module Main where
      2 
      3 import Text.Parsec
      4 import System.Environment
      5 import Compile
      6 import Produce
      7 import Esterel
      8 import qualified Parse
      9 import qualified Scope
     10 import qualified Label
     11 import System.IO
     12 import System.Exit
     13 import Text.Show.Pretty
     14 
     15 main = do
     16   args <- getArgs
     17   case args of
     18     [filename] -> do
     19       file <- readFile filename
     20       let parsed = runP Parse.parseFile Esterel.Empty "" file
     21       either
     22           (\error -> do
     23               hPutStrLn stderr $ "Parse error " ++ ppShow error
     24               exitFailure)
     25           (\(Module name inputs outputs expr) -> putStr ((
     26             let nexpr = Label.label $ Scope.scope expr in 
     27             Produce.produceNodes $ Compile.compile $ Module name inputs outputs nexpr
     28             )
     29           ++ "\n")) parsed;
     30     _ -> do
     31       name <- getProgName
     32       hPutStrLn stderr $ "Usage: " ++ name ++ " FILE"
     33       exitFailure
     34