Exemplo n.º 1
0
        public static void Main()
        {
            bool flag = true;

            BuilderApp.FatalLoadError = false;
            Setup();
            Notify.OutputProgress = m_Verbose;
            BuilderApp.Setup();
            if (BuilderApp.FatalLoadError)
            {
                BuilderApp.Log.Add(SysLogSection.System, SysLogAlert.Critical, "There was a fatal internal error.");
                flag = false;
            }
            if (m_GrammarFile == "")
            {
                BuilderApp.Log.Add(SysLogSection.CommandLine, SysLogAlert.Critical, "You must specify a grammar file.");
                flag = false;
            }
            else if (!LoadGrammar())
            {
                BuilderApp.Log.Add(SysLogSection.CommandLine, SysLogAlert.Critical, "The grammar file could not be loaded.");
                flag = false;
            }
            if (flag)
            {
                TextReader metaGrammar = new StringReader(m_Grammar);
                BuilderApp.EnterGrammar(metaGrammar);
                if (BuilderApp.LoggedCriticalError())
                {
                    flag = false;
                }
            }
            if (flag)
            {
                BuilderApp.ComputeLALR();
                if (BuilderApp.LoggedCriticalError())
                {
                    flag = false;
                }
            }
            if (flag)
            {
                BuilderApp.ComputeDFA();
                if (BuilderApp.LoggedCriticalError())
                {
                    flag = false;
                }
            }
            if (flag)
            {
                BuilderApp.ComputeComplete();
            }
            if (flag)
            {
                BuilderApp.Log.Add(SysLogSection.System, SysLogAlert.Success, "The grammar was successfully analyzed and the table file was created.");
                string str = FileUtility.GetExtension(m_TableFile).ToLower();
                if (str == "xml")
                {
                    if (m_Version == 1)
                    {
                        BuilderApp.BuildTables.SaveXML1(m_TableFile);
                    }
                    else
                    {
                        BuilderApp.BuildTables.SaveXML5(m_TableFile);
                    }
                }
                else if (str == "cgt")
                {
                    BuilderApp.BuildTables.SaveVer1(m_TableFile);
                }
                else
                {
                    BuilderApp.BuildTables.SaveVer5(m_TableFile);
                }
            }
            BuilderApp.SaveLog(m_LogFile);
            if (m_Verbose)
            {
                int num2 = BuilderApp.Log.Count() - 1;
                for (int i = 0; i <= num2; i++)
                {
                    SysLogItem item = BuilderApp.Log[i];
                    if ((item.Alert == SysLogAlert.Critical) | (item.Alert == SysLogAlert.Warning))
                    {
                        Console.WriteLine(item.AlertName().ToUpper() + " : " + item.SectionName() + " : " + item.Title + " : " + item.Description);
                    }
                    item = null;
                }
                Console.WriteLine("Done");
            }
        }