enterRule method
The discovery of a rule node, involves sending two events: the generic {@link ParseTreeListener#enterEveryRule} and a RuleContext-specific event. First we trigger the generic and then the rule specific. We to them in reverse order upon finishing the node.
Implementation
void enterRule(ParseTreeListener listener, RuleNode r) {
var ctx = r.ruleContext
as ParserRuleContext; // Todo: review this cast: we have a confusion between RuleNode and ParseTree on this class
listener.enterEveryRule(ctx);
ctx.enterRule(listener);
}