tools/pas2c/PascalPreprocessor.hs
changeset 10119 7e05a397602f
parent 10113 b26c2772e754
child 10120 b7f632c12784
equal deleted inserted replaced
10118:788703011d20 10119:7e05a397602f
     4 import Text.Parsec
     4 import Text.Parsec
     5 import Control.Monad.IO.Class
     5 import Control.Monad.IO.Class
     6 import Control.Monad
     6 import Control.Monad
     7 import System.IO
     7 import System.IO
     8 import qualified Data.Map as Map
     8 import qualified Data.Map as Map
     9 import Control.Exception(catch, IOException)
     9 import qualified Control.Exception as E
    10 import Prelude
       
    11 
    10 
    12 char' :: Char -> ParsecT String u IO ()
    11 char' :: Char -> ParsecT String u IO ()
    13 char' = void . char
    12 char' = void . char
    14 
    13 
    15 string' :: String -> ParsecT String u IO ()
    14 string' :: String -> ParsecT String u IO ()
    78         (char' '"')
    77         (char' '"')
    79         ifn <- many1 $ noneOf "\"\n"
    78         ifn <- many1 $ noneOf "\"\n"
    80         char' '"'
    79         char' '"'
    81         spaces
    80         spaces
    82         char' '}'
    81         char' '}'
    83         f <- liftIO (readFile (inputPath ++ ifn) `catch` (\(_ :: IOException) -> readFile (alternateInputPath ++ ifn) `catch` (\(_ :: IOException) -> error ("File not found: " ++ fn))))
    82         f <- liftIO (readFile (inputPath ++ ifn) 
       
    83             `E.catch` (\(_ :: E.IOException) -> readFile (alternateInputPath ++ ifn) 
       
    84             `E.catch` (\(_ :: E.IOException) -> error ("File not found: " ++ fn))))
    84         c <- getInput
    85         c <- getInput
    85         setInput $ f ++ c
    86         setInput $ f ++ c
    86         return ""
    87         return ""
    87 
    88 
    88     ifdef = do
    89     ifdef = do