3 ms·
Thanks! I'll take a look at these projects. By recovery I mean something like "f(x,y,z;" triggering an error message "did you miss ')' here?", with parser reco
by sklogic 11y ago
Thanks! I'll take a look at these projects.
By recovery I mean something like "f(x,y,z;" triggering an error message "did you miss ')' here?", with parser recovering and proceeding further, in a hope to report more errors in a single run - see how Clang handles this, with a handcrafted recursive descent parser.
Backtracking does not help here, it must be done with custom heuristics at each node. I am doing this kind of things declaratively on top of an elaborate PEG-based generator (using an idea of signals attached to both successful and failed branches, and then choosing which signals to execute based on the exact points of failure), but would be very interested to see a lightweight combinator-based solution.
- Gabriel439 11y ago`trifecta` is basically produces `clang`-style error messages (i.e. they have the pretty colors, underlined text spans, cursor pointers into the text, and really good error messages indicating the real problem and not some unrelated problem). That's why most people recommend `trifecta` when error reporting quality is paramount. The author of the `trifecta` library is extremely knowledgeable about parsing/backtracking/recovery/error-reporting and has put a lot of thought into how to improve error message relevance as much as possible.
- sklogic 11y agoOk, I think I understand now how it works (played with Idris parser a bit). Sort of a simple trick, I'll borrow it for the lower tier combinator-based parsing layer. I was even more interested in handcrafted, custom error messages rather than constructed. Still cannot figure out how to stuff custom recovery heuristics into a combinator-based code.