tools/pas2c/PascalPreprocessor.hs
branchwebgl
changeset 9982 24ea101fdc7f
parent 9966 01e198990211
child 10015 4feced261c68
equal deleted inserted replaced
9980:a666e4eefd27 9982:24ea101fdc7f
    15         char '{' >> notFollowedBy (char '$') >> manyTill anyChar (try $ char '}') >> return ""
    15         char '{' >> notFollowedBy (char '$') >> manyTill anyChar (try $ char '}') >> return ""
    16         , (try $ string "(*") >> manyTill anyChar (try $ string "*)") >> return ""
    16         , (try $ string "(*") >> manyTill anyChar (try $ string "*)") >> return ""
    17         , (try $ string "//") >> manyTill anyChar (try newline) >> return "\n"
    17         , (try $ string "//") >> manyTill anyChar (try newline) >> return "\n"
    18         ]
    18         ]
    19 
    19 
    20 
    20 preprocess :: String -> String -> String -> [String] -> IO String
    21 initDefines = Map.fromList [
    21 preprocess inputPath alternateInputPath fn symbols = do
    22     ("FPC", "")
    22     r <- runParserT (preprocessFile (inputPath ++ fn)) (Map.fromList $ map (\s -> (s, "")) symbols, [True]) "" ""
    23     , ("PAS2C", "")
       
    24     , ("DEBUGFILE", "")
       
    25 --    , ("WEBGL", "")
       
    26 --    , ("AI_MAINTHREAD", "")
       
    27     , ("ENDIAN_LITTLE", "")
       
    28     ]
       
    29 
       
    30 preprocess :: String -> String -> String -> IO String
       
    31 preprocess inputPath alternateInputPath fn = do
       
    32     r <- runParserT (preprocessFile (inputPath ++ fn)) (initDefines, [True]) "" ""
       
    33     case r of
    23     case r of
    34          (Left a) -> do
    24          (Left a) -> do
    35              hPutStrLn stderr (show a)
    25              hPutStrLn stderr (show a)
    36              return ""
    26              return ""
    37          (Right a) -> return a
    27          (Right a) -> return a