Support OR operator in $IFDEF. Fixes pas2c builds.
authorunc0rr
Fri, 09 May 2014 22:36:15 +0400
changeset 10240 bfae7354d42f
parent 10239 ed8bab6e92ba
child 10241 2dc9ff47c5b9
Support OR operator in $IFDEF. Fixes pas2c builds.
tools/pas2c/Pas2C.hs
tools/pas2c/PascalPreprocessor.hs
--- a/tools/pas2c/Pas2C.hs	Wed May 07 22:47:54 2014 +0200
+++ b/tools/pas2c/Pas2C.hs	Fri May 09 22:36:15 2014 +0400
@@ -121,7 +121,7 @@
                     let ptree = parse pascalUnit fileName fc
                     case ptree of
                          (Left a) -> do
-                            liftIO $ writeFile (outputPath ++ "preprocess.out") fc
+                            liftIO $ writeFile (outputPath ++ fileName ++ "preprocess.out") fc
                             printLn $ show a ++ "\nsee preprocess.out for preprocessed source"
                             fail "stop"
                          (Right a) -> do
--- a/tools/pas2c/PascalPreprocessor.hs	Wed May 07 22:47:54 2014 +0200
+++ b/tools/pas2c/PascalPreprocessor.hs	Fri May 09 22:36:15 2014 +0400
@@ -92,13 +92,12 @@
         s <- try (string "IFDEF") <|> try (string "IFNDEF")
         let f = if s == "IFNDEF" then not else id
 
-        spaces
-        d <- identifier
+        ds <- (spaces >> identifier) `sepBy` (spaces >> string "OR")
         spaces
         char' '}'
 
         updateState $ \(m, b) ->
-            (m, (f $ d `Map.member` m) : b)
+            (m, (f $ any (flip Map.member m) ds) : b)
 
         return ""