-
Notifications
You must be signed in to change notification settings - Fork 52
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
Location aware error context #409
Comments
I feel there is something missing in this idea because of the focus on other location types.
I'm also concerned this couples the ideas of Location tracking in errors and backtracking behavior. As one alternative, we could have an Error decorator that tracks a |
Sounds fair. Indeed it was not my intention to add location tracking (although that would might a nice addition as well). Still in presence of backtracking I find the current For example in a parser like this (SQL dialect):
With context error (without splicing in
I wonder how this will look like. Related to #410: Still, the goal is not position tracking. The goal is to choose and eventually merge 2 contextual errors. Back to the SQL example. I'm assuming that we add a
Let's assume an input string like In that case I want both error contexts to be merged, telling users that we did expect In this sense I'm "abusing" backtracking + error context handling to collect a list of all allowed literals right from the parsers. I'm new to winnow, so I might be missing something here. But I don't see how an Error decorator will solve the context-merge problem. |
For context (har har), This doesn't mean I'm against giving the option for it but its why the design favors the current approach.
Checkpoints require having an initial point to refer back to and atm you can't get offsets between two checkpoints without knowing which one is earlier. However, if we make them
While we can't do it with the existing infrastructure and a new wrapper type, we could extend |
Yeah. I'm not sure if requiring Checkpoints to implement
Yeah, I was thinking about renaming the type in #410 to For example in
But that would be a breaking change to |
I created #413 to demonstrate my idea. Up for finishing the rest? I feel like the |
Thank you, I gave it a shot: #415 I like the Unfortunately I think In case of I don't think we can use |
This was me being quick and forgetting what we put inside of What we need to do is call |
Please complete the following tasks
winnow version
0.5.31
Describe your use case
Using ContextError in combination with backtracking via
alt
can lead to confusing error reports. This is becauseContextError
basically discards the current context onor
.In presence of backtracking ideally I would wish for a context from the longest matching parser only. If 2 parsers did error at the same position the contexts should be merged.
Describe the solution you'd like
Provide a
LocationContextError
that I can use in case ofContextError
. TheLocationContextError
would track the longest parsed location. This requires that the input implementsLocation
.When merging contexts via
AddContext
or when adding some context to the error, theLocationContextError
should discard contexts at lower positions.Alternatives, if applicable
Encourage users to implement their own location aware context error. I have 2 implementations by now, but it would be nice to share the code in order to make it more generally available.
Additional Context
No response
The text was updated successfully, but these errors were encountered: