tools/PascalPreprocessor.hs
branchwebgl
changeset 7957 497ec84e0c21
parent 7762 d2fd8040534f
child 7961 620331af6b9a
equal deleted inserted replaced
7953:97f41bdf0770 7957:497ec84e0c21
    20     , ("PAS2C", "")
    20     , ("PAS2C", "")
    21     , ("ENDIAN_LITTLE", "")
    21     , ("ENDIAN_LITTLE", "")
    22     , ("S3D_DISABLED", "")
    22     , ("S3D_DISABLED", "")
    23     ]
    23     ]
    24 
    24 
    25 preprocess :: String -> IO String
    25 preprocess :: String -> String -> IO String
    26 preprocess fn = do
    26 preprocess inputPath fn = do
    27     r <- runParserT (preprocessFile fn) (initDefines, [True]) "" ""
    27     r <- runParserT (preprocessFile (inputPath ++ fn)) (initDefines, [True]) "" ""
    28     case r of
    28     case r of
    29          (Left a) -> do
    29          (Left a) -> do
    30              hPutStrLn stderr (show a)
    30              hPutStrLn stderr (show a)
    31              return ""
    31              return ""
    32          (Right a) -> return a
    32          (Right a) -> return a
    77         (char '"')
    77         (char '"')
    78         fn <- many1 $ noneOf "\"\n"
    78         fn <- many1 $ noneOf "\"\n"
    79         char '"'
    79         char '"'
    80         spaces
    80         spaces
    81         char '}'
    81         char '}'
    82         f <- liftIO (readFile fn `catch` error ("File not found: " ++ fn))
    82         f <- liftIO (readFile (inputPath ++ fn) `catch` error ("File not found: " ++ fn))
    83         c <- getInput
    83         c <- getInput
    84         setInput $ f ++ c
    84         setInput $ f ++ c
    85         return ""
    85         return ""
    86 
    86 
    87     ifdef = do
    87     ifdef = do