typelevel / typelevel/cats-parse

Backtracking with context

Open
#330 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
245
Forks
51
Avg merge
3h 20m
Merged PRs (30d)
1

Description

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))
  )
)))

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the parser1/parser2/parser3 chain, including withContext, backtrack, and the recursive parser described in the issue. Check how the resulting Left(Error(...)) is assembled and compare it with the requested nested WithContext output. Done means establishing whether the requested context is supported and, if so, adding a focused regression test for that behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.