-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lookAhead and error propagation #6
Comments
Just to make sure I'm not being dense - the parser |
Correct. I guess the example is a bit contrived, but my point is that Here's another example: variable :: Parser String
variable = do
x <- lookAhead (many1 letter)
if x == "return"
then fail "'return' is a reserved keyword"
else string x Then
With my patch it gives the following error:
The problem is that |
Oh, yes, I agree with you that your patch makes sense. I just wanted to make sure I understood your example. If at all possible |
Fixed in f7faa2a. |
Add Eq and Ord instances to Completion.
lookAhead p
is a parser that callsp
and if it succeeds thenlookAhead p
succeeds too, but it also rewinds the input stream back to where it was beforep
was tried. This was implemented in 3839639 by @feuerbach. I claim that this is not enough,lookAhead p
should also discard any error messages generated byp
. This is best illustrated with an example. Suppose that we have the following:Then
parse p "" "a"
should fail with the following error message:but currently it fails with the following:
In other words, if
p
succeeds, thenlookAhead p
should behave as ifp
never occurred, both in terms of the parser state and in terms of the errors generated.The text was updated successfully, but these errors were encountered: