public virtual void LoadPrecRuleTemplates() { string templateGroupFile = Path.Combine("Tool", "Templates", "LeftRecursiveRules.stg"); recRuleTemplates = new TemplateGroupFile( Path.Combine( Path.GetDirectoryName(typeof(AntlrTool).GetTypeInfo().Assembly.Location), templateGroupFile), Encoding.UTF8); if (!recRuleTemplates.IsDefined("recRule")) { tool.errMgr.ToolError(ErrorType.MISSING_CODE_GEN_TEMPLATES, "LeftRecursiveRules"); } // use codegen to get correct language templates; that's it though CodeGenerator gen = new CodeGenerator(tool, null, language); TemplateGroup templates = gen.GetTemplates(); if (templates == null) { // this class will still operate using Java templates templates = new CodeGenerator(tool, null, "Java").GetTemplates(); Debug.Assert(templates != null); } codegenTemplates = templates; }