Fix position when an error occurs in sat
.
This commit is contained in:
parent
bbb5c1c415
commit
d4cbcb8b99
1 changed files with 4 additions and 2 deletions
|
@ -121,8 +121,10 @@ try p = Parser p'
|
|||
_ -> failureError position error
|
||||
|
||||
sat :: forall e. (Char -> Boolean) -> Parser e Char
|
||||
sat p = do x <- item
|
||||
if p x then pure x else empty
|
||||
sat p = do
|
||||
pos <- current_position
|
||||
x <- item
|
||||
if p x then pure x else Parser \input -> failure pos
|
||||
|
||||
digit :: forall e. Parser e Char
|
||||
digit = sat isDigit
|
||||
|
|
Loading…
Add table
Reference in a new issue