@Override
		public void exitEveryRule(ParserRuleContext ctx) {
			if (ctx.children instanceof ArrayList) {
				((ArrayList<?>)ctx.children).trimToSize();
			}
		}
This is all the parsing support code essentially; most of it is error recovery stuff.
runtime/Java/src/org/antlr/v4/runtime/Parser.java