Fix position when an error occurs in `sat`.
parent
bbb5c1c415
commit
d4cbcb8b99
|
@ -121,8 +121,10 @@ try p = Parser p'
|
||||||
_ -> failureError position error
|
_ -> failureError position error
|
||||||
|
|
||||||
sat :: forall e. (Char -> Boolean) -> Parser e Char
|
sat :: forall e. (Char -> Boolean) -> Parser e Char
|
||||||
sat p = do x <- item
|
sat p = do
|
||||||
if p x then pure x else empty
|
pos <- current_position
|
||||||
|
x <- item
|
||||||
|
if p x then pure x else Parser \input -> failure pos
|
||||||
|
|
||||||
digit :: forall e. Parser e Char
|
digit :: forall e. Parser e Char
|
||||||
digit = sat isDigit
|
digit = sat isDigit
|
||||||
|
|
Loading…
Reference in New Issue