kjosib / booze-tools

Booze Tools will become the complete programming-language development workbench, all written in Python 3.9 (for now).
MIT License
14 stars 1 forks source link

Comprehensive Error Reporting Overhaul #25

Closed kjosib closed 4 years ago

kjosib commented 4 years ago

"Any fool can write a compiler for correct source programs" (J.S. Rohl 1972)

Right now the interfaces.py module contains a few exception classes which get used in various ways to report errors. It's been rather ad-hoc up to now. In particular, the ParseError class goes to some effort to provide information about the situation in which an error happened. Then there's the ErrorHelper class in grammar.py, which is just about exactly an admission of guilt. This got the job done in the demos, but it does not really seem like the right architecture.

From first principles:

kjosib commented 4 years ago

Maybe don't raise exceptions in the parser engine itself. Instead, delegate to an error-strategy object for whatever sort of reporting (or aborting) seems appropriate to the client application. Parse errors turn into a stream of events. The same idea can be used in the scan engine, and by extension for semantics.