diff options
Diffstat (limited to 'Sil/Util/Parser.icl')
-rw-r--r-- | Sil/Util/Parser.icl | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Sil/Util/Parser.icl b/Sil/Util/Parser.icl index 154a989..eb90408 100644 --- a/Sil/Util/Parser.icl +++ b/Sil/Util/Parser.icl @@ -147,14 +147,15 @@ list :: [a] -> Parser a [a] | ==, name, toString a list as = mapM item as seplist :: a (Parser a b) -> Parser a [b] | ==, name, toString a -seplist sep p = liftM2 (\e es -> [e:es]) p (many (p <* item sep)) +seplist sep p = liftM2 (\es e-> es ++ [e]) (some (p <* item sep)) p + <|> liftM pure p <|> pure empty seplistUntil :: a a (Parser a b) -> Parser a [b] | ==, name, toString a seplistUntil end sep p = liftM2 (\e es -> [e:es]) p ((item sep *> p) until` (item end)) <|> liftM pure (p <* item end) - <|> (pure empty <* item end) + <|> (empty <$ item end) where (until`) infix 2 :: (Parser a b) (Parser a c) -> Parser a [b] (until`) p1 guard = (p1 until guard) >>= \xs -> case xs of |