Support inlining of non-terminals, as Menhir does
- Dominant language
- Haskell
- Stars
- 322
- Forks
- 86
- PR merge metrics
- No merged PRs in 30d
Description
It has bothered me for a long time that we have so many conflicts in GHC's parser, and https://gitlab.haskell.org/ghc/ghc/issues/17232 is there to track it. Precedence declarations will probably go a long way to ameliorate this.
But as section 5.3 in http://gallium.inria.fr/~fpottier/menhir/manual.pdf points out, there still are conflicts which aren't easily resolved without compromising on software design by inlining all productions of a non-terminal into a call site.
I imagine something like Menhir's `%inline` keyword would help here. But I'd rather not have it at the declaration site of a non-terminal. Instead, we should have a mechanism that allows us to annotate *use-site* of the non-terminal, similar to the difference between `{-# INLINE #-}` and the [`GHC.Magic.inline`](https://hackage.haskell.org/package/base-4.12.0.0/docs/GHC-Exts.html#v:inline). Also it would help to resolve conflicts on a case-by-case basis rather than just blindly inline the non-terminal everywhere, which might come with exponential blow-up.
Contributor guide
Assessment
This issue has not been assessed yet.