ANTLR Visitors


What is the difference between a listener and a visitor? The difference between listener and visitor mechanisms is listener methods are called by the ANTLR-provided walker object, whereas visitor methods must walk their children with explicit visit calls. Forgetting to invoke visit() on a node’s children means those subtrees don’t get visited. In visitor we have the ability to tree walking while in listener you are only reacting to the tree walker.