--- a/tools/PascalPreprocessor.hs Fri Nov 25 05:15:38 2011 +0100
+++ b/tools/PascalPreprocessor.hs Fri Nov 25 18:36:12 2011 +0300
@@ -15,9 +15,11 @@
, (try $ string "//") >> manyTill anyChar (try newline) >> return "\n"
]
+initDefines = Map.fromList [("FPC", "")]
+
preprocess :: String -> IO String
preprocess fn = do
- r <- runParserT (preprocessFile fn) (Map.empty, [True]) "" ""
+ r <- runParserT (preprocessFile fn) (initDefines, [True]) "" ""
case r of
(Left a) -> do
hPutStrLn stderr (show a)
@@ -81,7 +83,7 @@
let f = if s == "IFNDEF" then not else id
spaces
- d <- many1 alphaNum
+ d <- identifier
spaces
char '}'
@@ -103,7 +105,7 @@
try $ string "DEFINE"
spaces
i <- identifier
- d <- option "" (string ":=" >> many (noneOf "}"))
+ d <- ((string ":=" >> return ())<|> spaces) >> many (noneOf "}")
char '}'
updateState $ \(m, b) -> (if and b then Map.insert i d m else m, b)
return ""