Closed kjosib closed 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.
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, theParseError
class goes to some effort to provide information about the situation in which an error happened. Then there's theErrorHelper
class ingrammar.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: