header parser: add multiline macros

This commit is contained in:
hellerve 2018-08-07 17:35:00 +02:00
parent d0057d3338
commit c44e018b73
2 changed files with 20 additions and 1 deletions

View File

@ -31,3 +31,11 @@ GLFWAPI void glfwPollEvents(void);
#define K_BLAH 12345
#define K_BLAX 0x123
#define K_GLAH 12345
// C function-like macros
#define X(a, b) a + b
#define Y(a, b) {\\
foo(a, b);\\
}
#define Z(a, b) "hi"

View File

@ -53,7 +53,7 @@ parseHeaderFile path src prefix kebab =
name <- Parsec.many1 identifierChar
argList <- Parsec.optionMaybe argList
Parsec.many spaceOrTab
number <- Parsec.many1 identifierChar
_ <- defineBody
Parsec.many spaceOrTab
-- OBS! Never kebab
case argList of
@ -76,6 +76,17 @@ parseHeaderFile path src prefix kebab =
genTypes 0 = []
genTypes n = (("a" ++ show n), 0) : genTypes (n - 1)
defineBody :: Parsec.Parsec String () ()
defineBody = do s <- Parsec.many (Parsec.noneOf "\\\n")
ending <- Parsec.optionMaybe (Parsec.string "\\\\\n")
case ending of
Nothing ->
do c <- Parsec.optionMaybe (Parsec.noneOf "\n")
case c of
Just _ -> defineBody
Nothing -> return ()
Just _ -> defineBody
prefixedFunctionPrototype :: Parsec.Parsec String () [XObj]
prefixedFunctionPrototype = do Parsec.many spaceOrTab
_ <- Parsec.many1 identifierChar