Пример #1
0
 private void TaskFlowManager_TaskResultCleared(TaskFlowManager Sender, Type TaskType)
 {
     if (TaskType == typeof(Production_Lexer))
     {
         TextBox_Info.Text         = Sender.GetTask <Production_Lexer>().ErrorMsg;
         CodeEditor_Converted.Text = "";
     }
     else if (TaskType == typeof(Production_Parser))
     {
         TextBox_Info.Text        += Sender.GetTask <Production_Parser>().ErrorMsg;
         CodeEditor_Converted.Text = "";
     }
     else if (TaskType == typeof(NFAGenerator_Lexer))
     {
         TextBox_Info.Text += Sender.GetTask <NFAGenerator_Lexer>().ErrorMsg;
     }
     else if (TaskType == typeof(NFAGenerator_Parser))
     {
         TextBox_Info.Text += Sender.GetTask <NFAGenerator_Parser>().ErrorMsg;
         ComboBox_NFA_RegularExpress.Items.Clear();
         Image_NFA_Diagram.Source = null;
     }
     else if (TaskType == typeof(DFAPriorityGenerator))
     {
         TextBox_Info.Text += Sender.GetTask <DFAPriorityGenerator>().ErrorMsg;
         DataGrid_DFAPriorityTableData.Clear();
     }
     else if (TaskType == typeof(GrammarCompiler))
     {
         TextBox_Info.Text += Sender.GetTask <GrammarCompiler>().ErrorText;
     }
 }
Пример #2
0
        private void TaskFlowManager_TaskResultUpdated(TaskFlowManager Sender, Type TaskType)
        {
            if (TaskType == typeof(Production_Lexer))
            {
                TextBox_Info.Text = "[Production_Lexer]:Execute OK!\n";
            }
            else if (TaskType == typeof(Production_Parser))
            {
                TextBox_Info.Text        += "[Production_Parser]:Execute OK!\n";
                CodeEditor_Converted.Text = Sender.GetTask <Production_Parser>().ProductionCode;
            }
            else if (TaskType == typeof(NFAGenerator_Lexer))
            {
                TextBox_Info.Text += "[NFAGenerator_Lexer]:Execute OK!\n";
            }
            else if (TaskType == typeof(NFAGenerator_Parser))
            {
                ComboBox_NFA_RegularExpress.Items.Clear();
                Image_NFA_Diagram.Source = null;
                var nfaparser   = Sender.GetTask <NFAGenerator_Parser>();
                var resultimage = nfaparser.ResultImage;
                var resultdata  = nfaparser.Result;

                foreach (var item in resultdata.Production_ParserResult.tplist)
                {
                    ComboBox_NFA_RegularExpress.Items.Add("<" + item.Name + "> -> \"" + item.RegularExpression + "\"");
                }

                NFAImage = resultimage;

                if (ComboBox_NFA_RegularExpress.Items.Count > 0)
                {
                    ComboBox_NFA_RegularExpress.SelectedIndex = 0;
                }

                TextBox_Info.Text += "[NFAGenerator_Parser]:Execute OK!\n";
            }
            else if (TaskType == typeof(DFAGenerator))
            {
                ComboBox_DFA_RegularExpress.Items.Clear();
                Image_DFA_Diagram.Source = null;
                var dfagenerator = Sender.GetTask <DFAGenerator>();
                var resultimage  = dfagenerator.ResultImage;
                var resultdata   = dfagenerator.Result;

                foreach (var item in resultdata.Production_ParserResult.tplist)
                {
                    ComboBox_DFA_RegularExpress.Items.Add("<" + item.Name + "> -> \"" + item.RegularExpression + "\"");
                }

                DFAImage = resultimage;

                if (ComboBox_DFA_RegularExpress.Items.Count > 0)
                {
                    ComboBox_DFA_RegularExpress.SelectedIndex = 0;
                }

                TextBox_Info.Text += "[DFAGenerator]:Execute OK!\n";
            }
            else if (TaskType == typeof(DFAOptimizer))
            {
                ComboBox_DFAOptimized_RegularExpress.Items.Clear();
                Image_DFAOptimized_Diagram.Source = null;
                var dfaoptimizer = Sender.GetTask <DFAOptimizer>();
                var resultimage  = dfaoptimizer.ResultImage;
                var resultdata   = dfaoptimizer.Result;

                foreach (var item in resultdata.Production_ParserResult.tplist)
                {
                    ComboBox_DFAOptimized_RegularExpress.Items.Add("<" + item.Name + "> -> \"" + item.RegularExpression + "\"");
                }

                DFAOptimizedImage = resultimage;

                if (ComboBox_DFAOptimized_RegularExpress.Items.Count > 0)
                {
                    ComboBox_DFAOptimized_RegularExpress.SelectedIndex = 0;
                }

                TextBox_Info.Text += "[DFAOptimizer]:Execute OK!\n";
            }
            else if (TaskType == typeof(DFAPriorityGenerator))
            {
                TextBox_Info.Text += "[DFAPriorityGenerator]:Execute OK!\n";
                var dfaprioritygenerator = Sender.GetTask <DFAPriorityGenerator>();
                DataGrid_DFAPriorityTableData.Clear();

                foreach (var dfa in dfaprioritygenerator.Result.Item.NoLoopDFAList)
                {
                    var tinfo = dfaprioritygenerator.Result.Production_ParserResult.tplist[dfa.TerminalID];
                    DataGrid_DFAPriorityTableData.Add(new DataGrid_DFAPriorityTable_Item {
                        Name = tinfo.Name, RegularExpression = tinfo.RegularExpression, IsLoop = "否", Priority = "高"
                    });
                }

                foreach (var dfa in dfaprioritygenerator.Result.Item.LoopDFAList)
                {
                    var tinfo = dfaprioritygenerator.Result.Production_ParserResult.tplist[dfa.TerminalID];
                    DataGrid_DFAPriorityTableData.Add(new DataGrid_DFAPriorityTable_Item {
                        Name = tinfo.Name, RegularExpression = tinfo.RegularExpression, IsLoop = "是", Priority = "低"
                    });
                }
            }
            else if (TaskType == typeof(GrammarCompiler))
            {
                TextBox_Info.Text += Sender.GetTask <GrammarCompiler>().ErrorText;
                WebBrowser_GrammarTest_Compile_Result.NavigateToString(Sender.GetTask <GrammarCompiler>().GrammarPreInfo.GrammarCompiler.GetCompileResult());
            }
        }
Пример #3
0
 public LexerAnalyzer(TaskFlowManager taskFlowManager)
 {
     this.taskFlowManager = taskFlowManager;
 }