示例#1
0
        // Обработчик события нажатия кнопки "Выполнить"
        // Выводит список кодов лексем исходного кода на форму
        private void bExecute_Click(object sender, EventArgs e)
        {
            // Делаем кнопки "Выполнить" на всех вкладках доступными
            SetPerformButtonsEnable(true);

            List <string> sourceCode = new List <string>(); //Source code line by line

            //Read from rich textbox
            string[] sourceCodeArr = rtbSourceCode.Text.Split('\n');
            foreach (string line in sourceCodeArr)
            {
                sourceCode.Add(line);
            }

            //Proccess the source code with the scanner to get the lexemes list
            List <List <string> > lexemesList = scanner.Proccess(sourceCode);

            rtbLexemes.Clear();
            foreach (List <string> line in lexemesList)
            {
                foreach (string lexeme in line)
                {
                    rtbLexemes.Text += (lexeme + " ");
                }
                rtbLexemes.Text += "\n";
            }

            //Update identifiers table
            FillIdentifiersTable();
            //Update constants table
            FillConstantsTable();

            // Переносим исходный код во вкладку "Перевод в ОПЗ"
            rtbSourceCodeRPN.Text = rtbSourceCode.Text;

            // Если была обнаружена неизветная лексема - блокируем кнопки "Выполнить" на всех вкладках, кроме первой
            if (ContainsUnknownLexeme(lexemesList))
            {
                SetPerformButtonsEnable(false);
            }
        }