diff options
-rw-r--r-- | monkeypatch.hs | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/monkeypatch.hs b/monkeypatch.hs index d6ff1c2..7da9c7d 100644 --- a/monkeypatch.hs +++ b/monkeypatch.hs | |||
@@ -1867,13 +1867,47 @@ includeStack bs = foldr go (const emptyIncludes) incs [] | |||
1867 | | "2" `elem` B.words inc = xs (drop 1 stack) | 1867 | | "2" `elem` B.words inc = xs (drop 1 stack) |
1868 | | otherwise = xs stack | 1868 | | otherwise = xs stack |
1869 | 1869 | ||
1870 | usageString self = unlines | ||
1871 | [ self ++ " [--cpp | -p | -t | --comments | --tohs ] [--nodo] [-v] [-f <sym>] -- [gcc options] [modules] <cfile>" | ||
1872 | , "" | ||
1873 | , "MODES" | ||
1874 | , "" | ||
1875 | , " default Generate a monkey-patchable Haskell interface to given C module." | ||
1876 | , "" | ||
1877 | , " --cpp Show Preprocessor include stack (debugging output)." | ||
1878 | , "" | ||
1879 | , " -p Preprocess. Output C with expanded macros (includes are NOT expanded)." | ||
1880 | , "" | ||
1881 | , " -t Tree. Output language-c parse tree (verbose!)." | ||
1882 | , "" | ||
1883 | , " --comments Output information about comment tokens occuring in file." | ||
1884 | , "" | ||
1885 | , " --tohs Attempt to translate C into Haskell (works on simple things)." | ||
1886 | , "" | ||
1887 | , "OPTIONS" | ||
1888 | , "" | ||
1889 | , " -v Verbose output." | ||
1890 | , "" | ||
1891 | , " -f <sym> Select a single function from the C file rather than the whole of it." | ||
1892 | , " This affects the default and --tohs modes." | ||
1893 | , "" | ||
1894 | , " --nodo In --tohs mode, avoid outputting do-syntax sugar." | ||
1895 | , "" | ||
1896 | , "ARGUMENTS" | ||
1897 | , "" | ||
1898 | , " [gcc options] Options passed to gcc during preprocessing or linking." | ||
1899 | , "" | ||
1900 | , " [modules] Extra modules (.c or .o). When generating stubs, these symbols are excluded." | ||
1901 | , "" | ||
1902 | , " <cfile> The .c module being interfaced or preprocessed." | ||
1903 | ] | ||
1904 | |||
1870 | main :: IO () | 1905 | main :: IO () |
1871 | main = do | 1906 | main = do |
1872 | self <- getProgName | 1907 | self <- getProgName |
1873 | args <- getArgs | 1908 | args <- getArgs |
1874 | let usageString = self ++ " [--cpp | -p | -t ] [-v] [-f <sym>] -- [gcc options] [modules] <cfile>" | ||
1875 | let m = usage args | 1909 | let m = usage args |
1876 | fromMaybe (putStrLn usageString) $ m <&> \(hopts,cargs,fname:fs) -> do | 1910 | fromMaybe (putStrLn $ usageString self) $ m <&> \(hopts,cargs,fname:fs) -> do |
1877 | prer <- runPreprocessor (newGCC "gcc") (rawCppArgs cargs fname) | 1911 | prer <- runPreprocessor (newGCC "gcc") (rawCppArgs cargs fname) |
1878 | let r :: Either (Either ExitCode ParseError) (IncludeStack, CTranslUnit) | 1912 | let r :: Either (Either ExitCode ParseError) (IncludeStack, CTranslUnit) |
1879 | r = do | 1913 | r = do |
@@ -1884,7 +1918,7 @@ main = do | |||
1884 | -- putStrLn $ "includes = " ++ ppShow (fmap fst r) | 1918 | -- putStrLn $ "includes = " ++ ppShow (fmap fst r) |
1885 | -- cs <- readComments fname | 1919 | -- cs <- readComments fname |
1886 | case () of | 1920 | case () of |
1887 | _ | oCommentsOnly hopts | 1921 | _ | oCommentsOnly hopts -- --comments |
1888 | -> do cs <- readComments fname | 1922 | -> do cs <- readComments fname |
1889 | forM_ cs $ \c -> do | 1923 | forM_ cs $ \c -> do |
1890 | putStrLn $ show c | 1924 | putStrLn $ show c |