-
-
Save dminuoso/a73383874e06061c3526049997472f79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
topStanza :: Filename -> Bool -> FileTable -> Get [StanzaWithSpan] | |
topStanza fn i ft = do | |
$(switch' [| case _ of | |
"ATTRIBUTE" -> f (attrDef i <?> Msg "attribute definition") <* eofl | |
"$INCLUDE" -> (includeDef ft <?> Msg "include macro") <* eofl | |
"MEMBER" -> f (memberDef i <?> Msg "member definition") <* eofl | |
"VALUE" -> f (valueDef <?> Msg "value definition") <* eofl | |
"BEGIN-VENDOR" -> f (beginVendor <?> Msg "begin vendor block") <* eofl | |
"END-VENDOR" -> f (endVendor <?> Msg "end vendor block") <* eofl | |
"VENDOR" -> f (vendorDef i <?> Msg "vendor definition") <* eofl | |
"FLAGS" -> literal "internal" *> eofl *> topStanza fn True ft | |
"END-PROTOCOL" -> FP.empty | |
_ -> FP.branch FP.eof FP.empty | |
(FP.empty `cut` [ Msg "ATTRIBUTE" | |
, Msg "$INCLUDE" | |
, Msg "MEMBER" | |
, Msg "VALUE" | |
, Msg "BEGIN-VENDOR" | |
, Msg "VENDOR" | |
, Msg "FLAGS" | |
]) | |
|]) | |
where | |
f p = do | |
FP.withSpan p (\r span -> pure [StanzaWithSpan r fn span]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment