11## Module Text.Parsing.Parser.Combinators
22
3+ Combinators for creating parsers.
4+
35#### ` (<?>) `
46
57``` purescript
810
911_ left-associative / precedence -1_
1012
13+ Provide an error message in the case of failure.
14+
1115#### ` between `
1216
1317``` purescript
1418between :: forall m s a open close. (Monad m) => ParserT s m open -> ParserT s m close -> ParserT s m a -> ParserT s m a
1519```
1620
21+ Wrap a parser with opening and closing markers.
22+
23+ For example:
24+
25+ ``` purescript
26+ parens = between (string "(") (string ")")
27+ ```
28+
1729#### ` option `
1830
1931``` purescript
2032option :: forall m s a. (Monad m) => a -> ParserT s m a -> ParserT s m a
2133```
2234
35+ Provide a default result in the case where a parser fails without consuming input.
36+
2337#### ` optional `
2438
2539``` purescript
2640optional :: forall m s a. (Monad m) => ParserT s m a -> ParserT s m Unit
2741```
2842
43+ Optionally parse something, failing quietly.
44+
2945#### ` optionMaybe `
3046
3147``` purescript
32- optionMaybe :: forall m s a. (Functor m, Monad m) => ParserT s m a -> ParserT s m (Maybe a)
48+ optionMaybe :: forall m s a. (Monad m) => ParserT s m a -> ParserT s m (Maybe a)
3349```
3450
51+ Return ` Nothing ` in the case where a parser fails without consuming input.
52+
3553#### ` try `
3654
3755``` purescript
3856try :: forall m s a. (Functor m) => ParserT s m a -> ParserT s m a
3957```
4058
59+ In case of failure, reset the stream to the unconsumed state.
60+
4161#### ` sepBy `
4262
4363``` purescript
4464sepBy :: forall m s a sep. (Monad m) => ParserT s m a -> ParserT s m sep -> ParserT s m (List a)
4565```
4666
67+ Parse phrases delimited by a separator.
68+
69+ For example:
70+
71+ ``` purescript
72+ digit `sepBy` string ","
73+ ```
74+
4775#### ` sepBy1 `
4876
4977``` purescript
5078sepBy1 :: forall m s a sep. (Monad m) => ParserT s m a -> ParserT s m sep -> ParserT s m (List a)
5179```
5280
81+ Parse phrases delimited by a separator, requiring at least one match.
82+
5383#### ` sepEndBy `
5484
5585``` purescript
5686sepEndBy :: forall m s a sep. (Monad m) => ParserT s m a -> ParserT s m sep -> ParserT s m (List a)
5787```
5888
89+ Parse phrases delimited and optionally terminated by a separator.
90+
5991#### ` sepEndBy1 `
6092
6193``` purescript
6294sepEndBy1 :: forall m s a sep. (Monad m) => ParserT s m a -> ParserT s m sep -> ParserT s m (List a)
6395```
6496
97+ Parse phrases delimited and optionally terminated by a separator, requiring at least one match.
98+
6599#### ` endBy1 `
66100
67101``` purescript
68102endBy1 :: forall m s a sep. (Monad m) => ParserT s m a -> ParserT s m sep -> ParserT s m (List a)
69103```
70104
105+ Parse phrases delimited and terminated by a separator, requiring at least one match.
106+
71107#### ` endBy `
72108
73109``` purescript
74110endBy :: forall m s a sep. (Monad m) => ParserT s m a -> ParserT s m sep -> ParserT s m (List a)
75111```
76112
113+ Parse phrases delimited and terminated by a separator.
114+
77115#### ` chainr `
78116
79117``` purescript
80118chainr :: forall m s a. (Monad m) => ParserT s m a -> ParserT s m (a -> a -> a) -> a -> ParserT s m a
81119```
82120
121+ Parse phrases delimited by a right-associative operator.
122+
123+ For example:
124+
125+ ``` purescript
126+ chainr digit (string "+" *> add) 0
127+ ```
128+
83129#### ` chainl `
84130
85131``` purescript
86132chainl :: forall m s a. (Monad m) => ParserT s m a -> ParserT s m (a -> a -> a) -> a -> ParserT s m a
87133```
88134
135+ Parse phrases delimited by a left-associative operator.
136+
89137#### ` chainl1 `
90138
91139``` purescript
92140chainl1 :: forall m s a. (Monad m) => ParserT s m a -> ParserT s m (a -> a -> a) -> ParserT s m a
93141```
94142
143+ Parse phrases delimited by a left-associative operator, requiring at least one match.
144+
95145#### ` chainl1' `
96146
97147``` purescript
@@ -104,6 +154,8 @@ chainl1' :: forall m s a. (Monad m) => ParserT s m a -> ParserT s m (a -> a -> a
104154chainr1 :: forall m s a. (Monad m) => ParserT s m a -> ParserT s m (a -> a -> a) -> ParserT s m a
105155```
106156
157+ Parse phrases delimited by a right-associative operator, requiring at least one match.
158+
107159#### ` chainr1' `
108160
109161``` purescript
@@ -116,40 +168,54 @@ chainr1' :: forall m s a. (Monad m) => ParserT s m a -> ParserT s m (a -> a -> a
116168choice :: forall f m s a. (Foldable f, Monad m) => f (ParserT s m a) -> ParserT s m a
117169```
118170
171+ Parse one of a set of alternatives.
172+
119173#### ` skipMany `
120174
121175``` purescript
122176skipMany :: forall s a m. (Monad m) => ParserT s m a -> ParserT s m Unit
123177```
124178
179+ Skip many instances of a phrase.
180+
125181#### ` skipMany1 `
126182
127183``` purescript
128184skipMany1 :: forall s a m. (Monad m) => ParserT s m a -> ParserT s m Unit
129185```
130186
187+ Skip at least one instance of a phrase.
188+
131189#### ` lookAhead `
132190
133191``` purescript
134192lookAhead :: forall s a m. (Monad m) => ParserT s m a -> ParserT s m a
135193```
136194
195+ Parse a phrase, without modifying the consumed state or stream position.
196+
137197#### ` notFollowedBy `
138198
139199``` purescript
140200notFollowedBy :: forall s a m. (Monad m) => ParserT s m a -> ParserT s m Unit
141201```
142202
203+ Fail if the specified parser matches.
204+
143205#### ` manyTill `
144206
145207``` purescript
146208manyTill :: forall s a m e. (Monad m) => ParserT s m a -> ParserT s m e -> ParserT s m (List a)
147209```
148210
211+ Parse several phrases until the specified terminator matches.
212+
149213#### ` many1Till `
150214
151215``` purescript
152216many1Till :: forall s a m e. (Monad m) => ParserT s m a -> ParserT s m e -> ParserT s m (List a)
153217```
154218
219+ Parse several phrases until the specified terminator matches, requiring at least one match.
220+
155221
0 commit comments