mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-17 16:38:14 +03:00
header parser: add multiline macros
This commit is contained in:
parent
d0057d3338
commit
c44e018b73
@ -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"
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user