diff options
| author | Matthew Hall <hallmatthew314@gmail.com> | 2023-02-13 23:53:27 +1300 |
|---|---|---|
| committer | Matthew Hall <hallmatthew314@gmail.com> | 2023-02-13 23:53:27 +1300 |
| commit | a17f9ba31d682f18c5e25d07bd94d2ccfb6de6d0 (patch) | |
| tree | 2781e71b78ab8ac27723a7cde82396d02e440130 /Parsers.hs | |
| parent | a1229c7403f83a525b1bdb0e9b140f032706128c (diff) | |
Able to parse simple operations
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 [] + |
