@@ -77,15 +77,15 @@ eof = ParserT
77
77
78
78
-- | Match the entire rest of the input stream. Always succeeds.
79
79
rest :: forall m . ParserT String m String
80
- rest = splitMap \before ->
81
- Right { value: before, before, after : " " }
80
+ rest = splitMap \consumed ->
81
+ Right { value: consumed, consumed, remainder : " " }
82
82
83
83
-- | Match the specified string.
84
84
string :: forall m . String -> ParserT String m String
85
85
string str = splitMap \input ->
86
86
case stripPrefix (Pattern str) input of
87
- Just after ->
88
- Right { value: str, before : str, after }
87
+ Just remainder ->
88
+ Right { value: str, consumed : str, remainder }
89
89
_ ->
90
90
Left $ " Expected " <> show str
91
91
@@ -144,7 +144,7 @@ takeN :: forall m. Int -> ParserT String m String
144
144
takeN n = splitMap \input -> do
145
145
let { before, after } = splitAt n input
146
146
if length before == n then
147
- Right { value: before, before, after }
147
+ Right { value: before, consumed: before, remainder: after }
148
148
else
149
149
Left $ " Could not take " <> show n <> " characters"
150
150
@@ -156,9 +156,9 @@ whiteSpace = fst <$> match skipSpaces
156
156
-- | Skip whitespace characters and throw them away. Always succeeds.
157
157
skipSpaces :: forall m . ParserT String m Unit
158
158
skipSpaces = splitMap \input -> do
159
- let before = takeWhile isSpace input
160
- let after = SCU .drop (SCU .length before ) input
161
- Right { value: unit, before, after }
159
+ let consumed = takeWhile isSpace input
160
+ let remainder = SCU .drop (SCU .length consumed ) input
161
+ Right { value: unit, consumed, remainder }
162
162
163
163
-- | Match one of the BMP `Char`s in the array.
164
164
oneOf :: forall m . Array Char -> ParserT String m Char
@@ -293,9 +293,9 @@ regex flags pattern =
293
293
Right regexobj ->
294
294
splitMap \input -> do
295
295
case NonEmptyArray .head <$> Regex .match regexobj input of
296
- Just (Just before ) -> do
297
- let after = SCU .drop (SCU .length before ) input
298
- Right { value: before, before, after }
296
+ Just (Just consumed ) -> do
297
+ let remainder = SCU .drop (SCU .length consumed ) input
298
+ Right { value: consumed, consumed, remainder }
299
299
_ ->
300
300
Left " No Regex pattern match"
301
301
where
@@ -322,17 +322,17 @@ type RegexFlagsRow =
322
322
323
323
-- | Splits the input string while yielding a value.
324
324
-- | * `value` is the value to return.
325
- -- | * `before ` is the input that was consumed and is used to update the parser position.
326
- -- | * `after ` is the new input state.
325
+ -- | * `consumed ` is the input that was consumed and is used to update the parser position.
326
+ -- | * `remainder ` is the new input state.
327
327
splitMap
328
328
:: forall m a
329
- . (String -> Either String { value :: a , before :: String , after :: String } )
329
+ . (String -> Either String { value :: a , consumed :: String , remainder :: String } )
330
330
-> ParserT String m a
331
331
splitMap f = ParserT
332
332
( mkFn5 \state1@(ParseState input pos _) _ _ throw done ->
333
333
case f input of
334
334
Left err ->
335
335
runFn2 throw state1 (ParseError err pos)
336
- Right { value, before, after } ->
337
- runFn2 done (ParseState after (updatePosString pos before after ) true ) value
336
+ Right { value, consumed, remainder } ->
337
+ runFn2 done (ParseState remainder (updatePosString pos consumed remainder ) true ) value
338
338
)
0 commit comments