Skip to content
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

Backtracking with context #330

Open
DenisNovac opened this issue Dec 21, 2021 · 1 comment
Open

Backtracking with context #330

DenisNovac opened this issue Dec 21, 2021 · 1 comment

Comments

@DenisNovac
Copy link
Contributor

DenisNovac commented Dec 21, 2021

Hi everyone. So i am having this list of parsers in my parser for each case it could possibly have (there is also a recursive parser above which uses this list of parsers for each next node and a lot of simple parsers inside each):

parser1.withContext("parser 1").backtrack | 
  parser2.withContext("parser 2").backtrack |
  parser3.withContext("parser 3")

The problem is - i never getting any context except of "parser 3". I wonder if there is some trick to get output like:

Left(Error(4,NonEmptyList(
  WithContext(parser 2, 
    WithContext(parser 3,EndOfString(4,27))
  )
)))
@johnynek
Copy link
Collaborator

Can you make a PR with a test with a minimal example that you expect to pass so we can look at something concrete?

I think you should get contexts from all 3 if you fail to parse. Glancing at the code again, that should be what happens.

Can you show a more complete failure (with code, input, and error message)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants