private bool syntaxAalysis(LexicalAnalysis la)
        {
            int tokennum = la.tokens.Count;

            if (tokennum != 0)
            {
                ArrayList list1   = new ArrayList();
                string[]  string1 = new string[tokennum + 1];
                string1[tokennum] = "";
                for (int a = 0; a < tokennum; a++)
                {
                    list1      = (ArrayList)la.tokens[a];
                    string1[a] = list1[0].ToString();
                }
                analysis.token = string1;

                ArrayList list2   = new ArrayList();
                string[]  string2 = new string[tokennum + 1];
                string2[tokennum] = "";
                for (int a = 0; a < tokennum; a++)
                {
                    list2      = (ArrayList)la.tokens[a];
                    string2[a] = list2[1].ToString();
                }
                analysis.format = string2;

                ArrayList list3   = new ArrayList();
                string[]  string3 = new string[tokennum + 1];
                string3[tokennum] = "";
                for (int a = 0; a < tokennum; a++)
                {
                    list3      = (ArrayList)la.tokens[a];
                    string3[a] = list3[2].ToString();
                }
                analysis.line = string3;

                if (!analysis.Scan())//出现错误再输出框进行报错
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            return(false);
        }
        //解释翻译
        private async void Button_Click_3(object sender, RoutedEventArgs e)
        {
            analysis.clear();
            //启动多线程
            MenuItem b = e.Source as MenuItem;

            b.IsEnabled       = false;
            stopBtn.IsEnabled = true;

            string myText = textEditor.Document.Text;

            if (myText == "")
            {
                /*会出现提示信息*/
                b.IsEnabled       = true;
                stopBtn.IsEnabled = false;
                MessageBox.Show("请输入内容");
            }
            else
            {
                LexicalAnalysis la = new LexicalAnalysis();

                la.LexAnalyze(myText);
                if (la.errInfo.Count != 0)
                {
                    OutputView.Document.Blocks.Add(new Paragraph(new Run(DateTime.Now.ToString("yyyy/MM/dd/HH:mm:ss"))));
                    foreach (Error s in la.errInfo)
                    {
                        OutputView.Document.Blocks.Add(new Paragraph(new Run("第" + s.line.ToString() + "行:" + s.info)));
                    }
                    ErrorRedInLine(lineNumber, la.errInfo);
                    b.IsEnabled       = true;
                    stopBtn.IsEnabled = false;
                }
                else
                {
                    int tokennum = la.tokens.Count;
                    if (tokennum != 0)
                    {
                        bool status = syntaxAalysis(la);
                        //ErrorRedInLine(line);
                        if (status == true)
                        {
                            TaskCompletionSource <object> tc = new TaskCompletionSource <object>();
                            // 新线程
                            Thread t = new Thread(() =>
                            {
                                RunWindow win = new RunWindow(analysis);
                                win.Closed   += (d, k) =>
                                {
                                    // 当窗口关闭后马上结束消息循环
                                    System.Windows.Threading.Dispatcher.ExitAllFrames();
                                };
                                win.Show();
                                // Run 方法必须调用,否则窗口一打开就会关闭
                                // 因为没有启动消息循环
                                System.Windows.Threading.Dispatcher.Run();
                                // 这句话是必须的,设置Task的运算结果
                                // 但由于此处不需要结果,故用null
                                tc.SetResult(null);
                            });
                            t.SetApartmentState(ApartmentState.STA);
                            t.Start();
                            thread = t;
                            // 新线程启动后,将Task实例返回
                            // 以便支持 await 操作符

                            await tc.Task;//可异步等待
                            b.IsEnabled       = true;
                            stopBtn.IsEnabled = false;
                            //MessageBox.Show("结束了");
                        }
                        else//如果没有通过语法和语义分析将会报错
                        {
                            //发现错误弹窗
                            MessageBox.Show("发现错误,请查看下方错误提示窗口!", "错误!", MessageBoxButton.OK, MessageBoxImage.Error);
                            //this.OutputView.Document.Blocks.Clear();
                            this.OutputView.Document.Blocks.Add(new Paragraph(new Run(DateTime.Now.ToString("yyyy/MM/dd/HH:mm:ss"))));
                            foreach (Error s in analysis.errInfo)
                            {
                                this.OutputView.Document.Blocks.Add(new Paragraph(new Run(s.info + "\t行号:" + s.line)));
                            }
                            ErrorRedInLine(lineNumber, analysis.errInfo);
                            b.IsEnabled       = true;
                            stopBtn.IsEnabled = false;
                        }
                    }
                }
            }
            analysis.clear();
            analysis.errInfo.Clear();
        }