File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
src/Text/Parsing/StringParser Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 11module Text.Parsing.StringParser.Combinators where
22
3+ import Control.Alt ((<|>))
4+ import Control.Apply ((*>))
35import Data.Maybe (Maybe (..))
4-
5- import Control.Alt
6-
76import Text.Parsing.StringParser
87
8+ lookAhead :: forall a . Parser a -> Parser a
9+ lookAhead p = Parser \ps fc sc -> unParser p ps fc (\s _ -> sc s ps)
10+
911many :: forall a . Parser a -> Parser [a ]
1012many p = many1 p <|> return []
1113
@@ -100,3 +102,10 @@ choice :: forall a. [Parser a] -> Parser a
100102choice [] = fail " Nothing to parse"
101103choice [x] = x
102104choice (x:xs) = x <|> choice xs
105+
106+ manyTill :: forall a end . Parser a -> Parser end -> Parser [a ]
107+ manyTill p end = scan
108+ where
109+ scan = (end *> return [] ) <|> do x <- p
110+ xs <- scan
111+ return (x:xs)
You can’t perform that action at this time.
0 commit comments