3 ms·
Yeah I am currently writing a compiler, turns out for useful error messages my parser should accept a superset of my language, then validate it afterwards.
by red2awn 6y ago
Yeah I am currently writing a compiler, turns out for useful error messages my parser should accept a superset of my language, then validate it afterwards.
- nsajko 6y agoMaybe you should check out the Menhir parser generator instead. Some links: http://gallium.inria.fr/~fpottier/menhir/manual.pdf http://gallium.inria.fr/~fpottier/menhir/manual.pdf https://semantic-domain.blogspot.com/2015/11/error-handling-in-menhir.html https://semantic-domain.blogspot.com/2015/11/error-handling-... https://baturin.org/blog/declarative-parse-error-reporting-with-menhir/ https://baturin.org/blog/declarative-parse-error-reporting-w...
- mhh__ 6y agoThe way the D compiler does it is by parsing until it finds an error, marking the node as "poisoned" then walking back up until it can keep going. It seems to work although I would include a "fail early" flag just to help with enormous error messages (if you apply the principle to sema as well)