-
-
Save dminuoso/3f8272c66fed64349f28c171deafdefa 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
sepBy1 :: Parser a -> Parser b -> Parser [a] | |
sepBy1 p s = liftA2 (:) p (FP.many (s >> p)) | |
crate :: Parser MCrate | |
crate = do | |
b <- FP.lookahead FP.anyWord8 | |
case BS.w2c b of | |
' ' -> Nothing <$ $(FP.string " ") | |
'[' -> FP.skip 1 >> (Just <$> FP.anyCharASCII) <* $(FP.char ']') | |
'\n' -> FP.empty | |
_ -> FP.err "bad input" | |
eol :: Parser () | |
eol = $(FP.char '\n') | |
hstack :: Parser [MCrate] | |
hstack = sepBy1 crate $(FP.char ' ') <* eol |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment