diff options
Diffstat (limited to 'Parsers.hs')
| -rw-r--r-- | Parsers.hs | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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 [] + |
