|
| 1 | +--- |
| 2 | +title: Parse error recovery and incrementality for GHC |
| 3 | +--- |
| 4 | + |
| 5 | +GHC is able to report multiple type errors at once, yet a single parser |
| 6 | +error brings the whole compilation pipeline to a halt; see [this tech |
| 7 | +proposal](https://github.com/haskellfoundation/tech-proposals/pull/63). |
| 8 | + |
| 9 | +One significant obstacle is the parser generator |
| 10 | +[`happy`](https://github.com/simonmar/happy/) that GHC relies on for versatile |
| 11 | +and fast parsing: |
| 12 | +The current error handling architecture exposed by `happy` will abort on the |
| 13 | +first parse error without producing a partial syntax tree at all. |
| 14 | + |
| 15 | +This [draft PR](https://github.com/haskell/happy/pull/272) |
| 16 | +improves happy to resume parsing after reporting a parse error, but it lacks |
| 17 | +documentation, introduces a number of breaking changes and is in bad need of |
| 18 | +cleanup. |
| 19 | +Nevertheless, it is technically complete, passes the testsuite and has already |
| 20 | +been [tried on GHC as a proof of concept](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/11990). |
| 21 | + |
| 22 | +The goal of this project is to take over the pull request to `happy` so that it |
| 23 | +can be merged, and then use the improved `happy` to generate multiple and better |
| 24 | +parse error messages in GHC. |
| 25 | + |
| 26 | +There are a couple of stretch goals: |
| 27 | + |
| 28 | + * `happy` could further be improved to pass a closure of its |
| 29 | + parse state to reduction actions, so as to enable incremental parsing. |
| 30 | + * Improve `happy` so that it provides a convenient and encapsulated way to |
| 31 | + introspect the LALR item stack, for example to identify bracketing |
| 32 | + productions such as `'(' expr . ')'` in order to report mismatched brackets. |
| 33 | + There is a [hacky GHC Merge Request](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4711) |
| 34 | + that tries to achieve as much without buy in from happy. |
| 35 | + * Improve `happy`s code base, which by now is over 25 years old. |
| 36 | + |
| 37 | +**Potential Mentors**: |
| 38 | +Sebastian Graf |
| 39 | + |
| 40 | +**Difficulty**: |
| 41 | +Medium, given that the technical bits have been drafted out. |
| 42 | +Still, the student would be required to familiarise themselves with the basics |
| 43 | +of LALR parsing theory in order to contribute documentation. |
| 44 | + |
| 45 | +**Size**: |
| 46 | +175 hours for merging the PR and beginning to improve GHC, but 350 hours can |
| 47 | +easily be spent on working on stretch goals as well for significant improvement |
| 48 | +of GHC. |
0 commit comments