Longest match parser combinator or `<|>` variant
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
We currently use the longest match parser combinator only when processing syntax categories. During the ICERM after-party hackton, users created fake "syntax category" to get the longest match behavior. BTW, they were also confused by the following example:
syntax case1 := ident " : " term
syntax case2 := ident " ∈ " term
syntax "foo " (case1 <|> case2) : term
#check foo x ∈ /- parser error at ∈ -/ Fin 10
The problem is that <|> only backtracks if no token has been consumed. One has to use atomic here or hoist out the ident, but this is not natural to new users.
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 case1 <|> case2 example from the issue and compare its behavior with atomic and the existing longest-match parser combinator. Then locate the parser-combinator entry points and determine the intended semantics for a longest-match variant; done should include a documented resolution of the example and matching tests.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100