Antlr4.StringTemplate.TemplateGroup.LoadGroupFile C# (CSharp) Method

LoadGroupFile() public method

public LoadGroupFile ( string prefix, string fileName ) : void
prefix string
fileName string
return void
        public virtual void LoadGroupFile(string prefix, string fileName)
        {
            if (Verbose)
            {
                Console.Out.WriteLine("{0}.LoadGroupFile(prefix={1}, fileName={2})",
                    GetType().FullName, prefix, fileName);
            }

            GroupParser parser = null;
            try
            {
                Uri f = new Uri(fileName);
                ANTLRReaderStream fs = new ANTLRReaderStream(new System.IO.StreamReader(File.OpenRead(f.LocalPath), Encoding));

                var timer = System.Diagnostics.Stopwatch.StartNew();

                string cachePath = Path.Combine(Path.GetTempPath(), "ST4TemplateCache");
                if (EnableCache && TryLoadGroupFromCache(cachePath, prefix, fileName))
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("Successfully loaded the group from cache {0} in {1}ms.", Name, timer.ElapsedMilliseconds));
                }
                else
                {
                    GroupLexer lexer = new GroupLexer(fs);
                    fs.name = fileName;
                    CommonTokenStream tokens = new CommonTokenStream(lexer);
                    parser = new GroupParser(tokens);
                    parser.group(this, prefix);

                    System.Diagnostics.Debug.WriteLine(string.Format("Successfully loaded the group {0} in {1}ms.", Name, timer.ElapsedMilliseconds));

                    if (EnableCache)
                        CacheCompiledGroup(cachePath, prefix, fileName, File.GetLastWriteTimeUtc(f.LocalPath));
                }

            }
            catch (Exception e) when (!e.IsCritical())
            {
                ErrorManager.IOError(null, ErrorType.CANT_LOAD_GROUP_FILE, e, fileName);
            }
        }