tools/pas2c/Pas2C.hs
branchwebgl
changeset 9982 24ea101fdc7f
parent 9964 12b0ed9910cd
child 10015 4feced261c68
equal deleted inserted replaced
9980:a666e4eefd27 9982:24ea101fdc7f
    94     $ gets stringConsts
    94     $ gets stringConsts
    95 
    95 
    96 docToLower :: Doc -> Doc
    96 docToLower :: Doc -> Doc
    97 docToLower = text . map toLower . render
    97 docToLower = text . map toLower . render
    98 
    98 
    99 pas2C :: String -> String -> String -> String -> IO ()
    99 pas2C :: String -> String -> String -> String -> [String] -> IO ()
   100 pas2C fn inputPath outputPath alternateInputPath = do
   100 pas2C fn inputPath outputPath alternateInputPath symbols = do
   101     s <- flip execStateT initState $ f fn
   101     s <- flip execStateT initState $ f fn
   102     renderCFiles s outputPath
   102     renderCFiles s outputPath
   103     where
   103     where
   104     printLn = liftIO . hPutStrLn stdout
   104     printLn = liftIO . hPutStrLn stdout
   105     print = liftIO . hPutStr stdout
   105     print = liftIO . hPutStr stdout
   109         processed <- gets $ Map.member fileName
   109         processed <- gets $ Map.member fileName
   110         unless processed $ do
   110         unless processed $ do
   111             print ("Preprocessing '" ++ fileName ++ ".pas'... ")
   111             print ("Preprocessing '" ++ fileName ++ ".pas'... ")
   112             fc' <- liftIO
   112             fc' <- liftIO
   113                 $ tryJust (guard . isDoesNotExistError)
   113                 $ tryJust (guard . isDoesNotExistError)
   114                 $ preprocess inputPath alternateInputPath (fileName ++ ".pas")
   114                 $ preprocess inputPath alternateInputPath (fileName ++ ".pas") symbols
   115             case fc' of
   115             case fc' of
   116                 (Left a) -> do
   116                 (Left a) -> do
   117                     modify (Map.insert fileName (System []))
   117                     modify (Map.insert fileName (System []))
   118                     printLn "doesn't exist"
   118                     printLn "doesn't exist"
   119                 (Right fc) -> do
   119                 (Right fc) -> do