typelevel / typelevel/cats-parse
Why is Parser0#repSep not possible?
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 245
- Forks
- 51
- Avg merge
- 3h 20m
- Merged PRs (30d)
- 1
Description
Hi all,
I'm trying to port scala-uri to cats-parse.
One difficulty I'm facing is with parsing path parts including empty ones:
a/b/c
/a/b/c
a//c
/a//c
What I would like to do is something like this (simplified)
def _path_segment: Parser0[String] = Parser.until0(charIn("/?#"))
def _path: Parser[String] = (Parser.char('/').? ~ _path_segment.repSep0(char('/')).string
but this doesn't work, as Parser0 doesn't have repSep or repSep0 defined.
I understand that Parser0#rep is problematic, as one could easily run the empty parser infinitely, but in my naive thinking this problem shouldn't exist with repSep, right?
Or is there a nicer way to do this in cats-parse?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the simplified Parser0 path example from the issue and inspect the existing Parser0 repetition APIs. The work is complete when paths such as a/b/c, /a//b/c, and a//c can be parsed while preserving empty path parts, with behavior covered by relevant parser tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100