diff --git a/fco2/LANGUAGE b/fco2/LANGUAGE index 25c76e1..ce7a5cb 100644 --- a/fco2/LANGUAGE +++ b/fco2/LANGUAGE @@ -3,6 +3,7 @@ Language features supported by Tock Everything in occam2.1, minus: - inline VALOF +- PORTs, PLACE - ... KRoC's TLP interface. @@ -15,3 +16,5 @@ Intrinsics: - SQRT - DSQRT +Simple versions of #USE and #INCLUDE that only work in a process context (i.e. +you can't #INCLUDE the body of a nested block). diff --git a/fco2/Parse.hs b/fco2/Parse.hs index ea93407..fc663dd 100644 --- a/fco2/Parse.hs +++ b/fco2/Parse.hs @@ -1825,6 +1825,7 @@ preprocessorDirective :: OccParser A.Process preprocessorDirective = ppInclude <|> ppUse + <|> unknownPP "preprocessor directive" ppInclude :: OccParser A.Process @@ -1834,6 +1835,7 @@ ppInclude file <- manyTill character sQuote eol includeFile $ concat file + "#INCLUDE directive" ppUse :: OccParser A.Process ppUse @@ -1848,6 +1850,7 @@ ppUse if file `elem` psLoadedFiles ps then process else includeFile file + "#USE directive" -- | Invoke the parser recursively to handle an included file. includeFile :: String -> OccParser A.Process @@ -1857,6 +1860,14 @@ includeFile file setState ps' { psLocalNames = psMainLocals ps' } p <- process return $ f p + +unknownPP :: OccParser A.Process + = do m <- md + char '#' + rest <- manyTill anyChar (try eol) + addWarning m $ "unknown preprocessor directive ignored: " ++ rest + process + "unknown preprocessor directive" --}}} --{{{ main process mainProcess :: OccParser A.Process diff --git a/fco2/testcases/preproc.occ b/fco2/testcases/preproc.occ new file mode 100644 index 0000000..587e12f --- /dev/null +++ b/fco2/testcases/preproc.occ @@ -0,0 +1,6 @@ +#PRAGMA IMADETHISONEUP +PROC P () + #PRAGMA I made this one up too. + INT a: + SKIP +: