public OutputModelObject buildParserOutputModel(SourceType sourceType) {
		CodeGenerator gen = delegate.getGenerator();
		ParserFile file = parserFile(gen.getRecognizerFileName(sourceType));
		setRoot(file);
		file.parser = parser(file);
		// ST can't compare strings so need booleans
		file.genLean = sourceType == SourceType.SOURCE_LEAN;
		file.genContexts = sourceType == SourceType.SOURCE_CONTEXTS;
		file.genDFA = sourceType == SourceType.SOURCE_DFA;

		Grammar g = delegate.getGrammar();
		for (Rule r : g.rules.values()) {
			buildRuleFunction(file.parser, r);
		}

		return file;
	}
Build a file with a parser containing rule functions. Use the
 controller as factory in SourceGenTriggers so it triggers codegen
 extensions too, not just the factory functions in this factory.
tool/src/org/antlr/v4/codegen/OutputModelController.java