Skip to content

Instantly share code, notes, and snippets.

@dadrian
Created November 30, 2014 20:01
Show Gist options
  • Save dadrian/795584da6710fced40cd to your computer and use it in GitHub Desktop.
Save dadrian/795584da6710fced40cd to your computer and use it in GitHub Desktop.
module Main where
import Language.C
import Language.C.System.GCC -- preprocessor used
import Language.C.Syntax.AST
main = parseMyFile "header.h" >>= printMyAST
parseMyFile :: FilePath -> IO CTranslUnit
parseMyFile input_file =
do parse_result <- parseCFile (newGCC "gcc") Nothing ["-U__BLOCKS__"] input_file
case parse_result of
Left parse_err -> error (show parse_err)
Right ast -> return ast
printMyAST :: CTranslUnit -> IO ()
printMyAST ctu = (print . pretty) ctu
build-depends: language=c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment