What does visitChildren() in antlr4 actually does ? (Java)

What does visitChildren() in antlr4 (for Java) actually does ? It’s the default function for everything in the base visitor and it seems to do a lot that I don’t know. For example, what does it do with these parser rules?


a: b | c | d;
e: F g H;
i: j k l+;
m: N O P?;

And do you have other examples to show what it does ?


visitChildren iterates over all child nodes of a given node and triggeres the accept method for each of them. Look in your generated parser to see what the accept method does. Normally it calls the visit function of the next child in the chain or simply visits over its own children by calling again visitChildren (which has basically the same effect, just in a more general way). See the class AbstractParseTreeVisitor for the default implementation of visitChildren and other methods you can override to customize the visitor behavior.