tools/pas2c/PascalPreprocessor.hs
branchwebgl
changeset 9164 d923ba9d1145
parent 8330 aaefa587e277
child 9199 9ed29795d2a3
equal deleted inserted replaced
9162:2c6ad606f4fb 9164:d923ba9d1145
       
     1 {-# LANGUAGE ScopedTypeVariables #-}
     1 module PascalPreprocessor where
     2 module PascalPreprocessor where
     2 
     3 
     3 import Text.Parsec
     4 import Text.Parsec
     4 import Control.Monad.IO.Class
     5 import Control.Monad.IO.Class
     5 import Control.Monad
     6 import Control.Monad
     6 import System.IO
     7 import System.IO
     7 import qualified Data.Map as Map
     8 import qualified Data.Map as Map
       
     9 import Control.Exception(catch, IOException)
     8 import Data.Char
    10 import Data.Char
     9 
    11 
    10 
    12 
    11 -- comments are removed
    13 -- comments are removed
    12 comment = choice [
    14 comment = choice [
    79         (char '"')
    81         (char '"')
    80         fn <- many1 $ noneOf "\"\n"
    82         fn <- many1 $ noneOf "\"\n"
    81         char '"'
    83         char '"'
    82         spaces
    84         spaces
    83         char '}'
    85         char '}'
    84         f <- liftIO (readFile (inputPath ++ fn) `catch` (\exc -> readFile (alternateInputPath ++ fn) `catch` error ("File not found: " ++ fn)))
    86         f <- liftIO (readFile (inputPath ++ fn) `catch` (\(exc :: IOException) -> readFile (alternateInputPath ++ fn) `catch` (\(_ :: IOException) -> error ("File not found: " ++ fn))))
    85         c <- getInput
    87         c <- getInput
    86         setInput $ f ++ c
    88         setInput $ f ++ c
    87         return ""
    89         return ""
    88 
    90 
    89     ifdef = do
    91     ifdef = do