core: ParseCharE
This commit is contained in:
parent
fa5eb61d59
commit
40dd87a4f3
1 changed files with 13 additions and 0 deletions
|
@ -216,6 +216,19 @@ parseChar : Has ParserState fs => (predicate : Char -> Bool) -> (err : Char -> e
|
||||||
-> Eff fs (ParseCharResult e)
|
-> Eff fs (ParseCharResult e)
|
||||||
parseChar predicate err = send $ ParseChar predicate err
|
parseChar predicate err = send $ ParseChar predicate err
|
||||||
|
|
||||||
|
||| Wrapper for parseChar that folds the error message into effect stack with the
|
||||||
|
||| provided callback
|
||||||
|
export
|
||||||
|
parseCharE : Has ParserState fs => Has (Except e) fs =>
|
||||||
|
(predicate : Char -> Bool) -> (err : Char -> e) -> (eof : Lazy e)
|
||||||
|
-> Eff fs Char
|
||||||
|
parseCharE predicate err eof = do
|
||||||
|
result <- parseChar predicate id
|
||||||
|
case result of
|
||||||
|
GotChar char => pure char
|
||||||
|
GotError x => throw $ err x
|
||||||
|
EndOfInput => throw eof
|
||||||
|
|
||||||
||| "Parse" the end of input, returning `True` if the parser state is currently
|
||| "Parse" the end of input, returning `True` if the parser state is currently
|
||||||
||| at the end of the input
|
||| at the end of the input
|
||||||
export
|
export
|
||||||
|
|
Loading…
Add table
Reference in a new issue