google / polymorphicDSL

Apache License 2.0
11 stars 7 forks source link

Listeners should have visitErrorNode throw an exception by default #46

Open incident-recipient opened 2 years ago

incident-recipient commented 2 years ago

It is possible to get a false positive if errorNodes are encountered. The default implementation is to do nothing. The user can implement an exception to be thrown manually, but I'm concerned that it will be easy to forget and lead to difficult to diagnose bugs.

I'm going to see if this can be built into the generated code ANTLR produces with its "tool" code.

incident-recipient commented 2 years ago

I was having difficulty getting tests in ANTLR to pass with my modifications, although I didn't have a dedicated amount of time to devote to the problem.

A stopgap solution might be to have PDSL log a severe error if it notices any nodes are error nodes.