cpphs-1.11: A liberalised re-implementation of cpp, the C pre-processor.Source codeContentsIndex
Language.Preprocessor.Cpphs
PortabilityAll
Stabilityexperimental
MaintainerMalcolm Wallace <Malcolm.Wallace@cs.york.ac.uk>
Description
Include the interface that is exported
Synopsis
runCpphs :: CpphsOptions -> FilePath -> String -> IO String
cppIfdef :: FilePath -> [(String, String)] -> [String] -> BoolOptions -> String -> IO [(Posn, String)]
macroPass :: [(String, String)] -> BoolOptions -> [(Posn, String)] -> IO String
data CpphsOptions = CpphsOptions {
infiles :: [FilePath]
outfiles :: [FilePath]
defines :: [(String, String)]
includes :: [String]
preInclude :: [FilePath]
boolopts :: BoolOptions
}
data BoolOptions = BoolOptions {
macros :: Bool
locations :: Bool
hashline :: Bool
pragma :: Bool
stripEol :: Bool
stripC89 :: Bool
lang :: Bool
ansi :: Bool
layout :: Bool
literate :: Bool
warnings :: Bool
}
parseOptions :: [String] -> Either String CpphsOptions
defaultCpphsOptions :: CpphsOptions
defaultBoolOptions :: BoolOptions
data Posn = Pn String !Int !Int (Maybe Posn)
newfile :: String -> Posn
addcol :: Int -> Posn -> Posn
newline :: Posn -> Posn
tab :: Posn -> Posn
newlines :: Int -> Posn -> Posn
newpos :: Int -> Maybe String -> Posn -> Posn
cppline :: Posn -> String
haskline :: Posn -> String
cpp2hask :: String -> String
filename :: Posn -> String
lineno :: Posn -> Int
directory :: Posn -> FilePath
Documentation
runCpphs :: CpphsOptions -> FilePath -> String -> IO StringSource
cppIfdefSource
:: FilePathFile for error reports
-> [(String, String)]Pre-defined symbols and their values
-> [String]Search path for #includes
-> BoolOptionsOptions controlling output style
-> StringThe input file content
-> IO [(Posn, String)]The file after processing (in lines)
Run a first pass of cpp, evaluating #ifdef's and processing #include's, whilst taking account of #define's and #undef's as we encounter them.
macroPassSource
:: [(String, String)]Pre-defined symbols and their values
-> BoolOptionsOptions that alter processing style
-> [(Posn, String)]The input file content
-> IO StringThe file after processing
Walk through the document, replacing calls of macros with the expanded RHS.
data CpphsOptions Source
Cpphs options structure.
Constructors
CpphsOptions
infiles :: [FilePath]
outfiles :: [FilePath]
defines :: [(String, String)]
includes :: [String]
preInclude :: [FilePath]Files to #include before anything else
boolopts :: BoolOptions
data BoolOptions Source
Options representable as Booleans.
Constructors
BoolOptions
macros :: BoolLeave #define and #undef in output of ifdef?
locations :: BoolPlace #line droppings in output?
hashline :: BoolWrite -} ?
pragma :: BoolKeep #pragma in final output?
stripEol :: BoolRemove C eol (//) comments everywhere?
stripC89 :: BoolRemove C inline (/**/) comments everywhere?
lang :: BoolLex input as Haskell code?
ansi :: BoolPermit stringise # and catenate ## operators?
layout :: BoolRetain newlines in macro expansions?
literate :: BoolRemove literate markup?
warnings :: BoolIssue warnings?
parseOptions :: [String] -> Either String CpphsOptionsSource
Parse all command-line options.
defaultCpphsOptions :: CpphsOptionsSource
Default options.
defaultBoolOptions :: BoolOptionsSource
Default settings of boolean options.
data Posn Source
Source positions contain a filename, line, column, and an inclusion point, which is itself another source position, recursively.
Constructors
Pn String !Int !Int (Maybe Posn)
newfile :: String -> PosnSource
Constructor. Argument is filename.
addcol :: Int -> Posn -> PosnSource
Increment column number by given quantity.
newline :: Posn -> PosnSource
Increment row number, reset column to 1.
tab :: Posn -> PosnSource
Increment column number, tab stops are every 8 chars.
newlines :: Int -> Posn -> PosnSource
Increment row number by given quantity.
newpos :: Int -> Maybe String -> Posn -> PosnSource
Update position with a new row, and possible filename.
cppline :: Posn -> StringSource
cpp-style printing of file position
haskline :: Posn -> StringSource
haskell-style printing of file position
cpp2hask :: String -> StringSource
Conversion from a cpp-style to haskell-style pragma.
filename :: Posn -> StringSource
Project the filename.
lineno :: Posn -> IntSource
Project the line number.
directory :: Posn -> FilePathSource
Project the directory of the filename.
Produced by Haddock version 2.6.0