Skip to content

Instantly share code, notes, and snippets.

@dminuoso

dminuoso/f.hs Secret

Created October 19, 2022 13:44
Show Gist options
  • Save dminuoso/84fc29d4b3c44c056e267b6457938b2c to your computer and use it in GitHub Desktop.
Save dminuoso/84fc29d4b3c44c056e267b6457938b2c to your computer and use it in GitHub Desktop.
topStanza :: Bool -> FileTable -> Get [Stanza]
topStanza i ft = $(switch' [| case _ of
"ATTRIBUTE" -> singleton <$> (attrDef i <?> Msg "attribute definition") <* eofl
"$INCLUDE" -> (includeDef ft <?> Msg "include macro") <* eofl
"MEMBER" -> singleton <$> (memberDef i <?> Msg "member definition") <* eofl
"VALUE" -> singleton <$> (valueDef <?> Msg "value definition") <* eofl
"BEGIN-VENDOR" -> singleton <$> (beginVendor <?> Msg "vendor block")
"VENDOR" -> singleton <$> (vendorDef i <?> Msg "vendor definition") <* eofl
"FLAGS" -> literal "internal" *> eofl *> topStanza 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"
])
|])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment