You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For Gherkin-style tests ANTLR4 gives us two choices for the listener: an abstract class with empty implementations for everything or an interface.
The problem with the abstract class is it is too easy for the grammar to change and other clients will not realize they need to provide an implementation. This can lead to false positives.
The interface requires implementing a lot of methods that have no value (such as the exit methods).
It would be great to have a third option that provided an empty implementation for all exit methods as well as any rules that follow some convention (such as a '_' character at the end of the rule name. In this manner the user will only need to provide implementations for the enter methods of consequence and changes will allow other clients to see they need to add new functionality.
The text was updated successfully, but these errors were encountered:
I think another useful way to do this would be to have ANTLRs tool generate another java interface that has a default implementation that does nothing for all exit methods and ParseTreeListener methods. This would only force the user to implement the enter methods.
So I made a pull request and issue for the antlr team at antlr/antlr4#3986
However there seems to be mixed feelings.
I have adjusted this framework to support generated visitors which can act as a work around, but I'll keep this issue open until Parr has made a decision on the pull request.
For Gherkin-style tests ANTLR4 gives us two choices for the listener: an abstract class with empty implementations for everything or an interface.
The problem with the abstract class is it is too easy for the grammar to change and other clients will not realize they need to provide an implementation. This can lead to false positives.
The interface requires implementing a lot of methods that have no value (such as the exit methods).
It would be great to have a third option that provided an empty implementation for all exit methods as well as any rules that follow some convention (such as a '_' character at the end of the rule name. In this manner the user will only need to provide implementations for the enter methods of consequence and changes will allow other clients to see they need to add new functionality.
The text was updated successfully, but these errors were encountered: