summaryrefslogtreecommitdiff
path: root/Parsers.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Parsers.hs')
-rw-r--r--Parsers.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/Parsers.hs b/Parsers.hs
index 54d85a5..96c4a07 100644
--- a/Parsers.hs
+++ b/Parsers.hs
@@ -120,3 +120,15 @@ stopAfter p = (,) <$> stopAt p <*> p
stopIf :: Parser t a -> Parser t [t]
stopIf p = stopAt $ () <$ p <|> eof
+firstOf :: [Parser t a] -> Parser t a
+firstOf = foldr1 (<|>)
+
+sepBy1 :: Parser t a -> Parser t b -> Parser t [a]
+sepBy1 a b = do
+ x <- a
+ xs <- mult $ b >> a
+ return $ x:xs
+
+sepBy :: Parser t a -> Parser t b -> Parser t [a]
+sepBy a b = sepBy1 a b <|> pure []
+