Ejemplo n.º 1
0
        private void RunButton_Click(object sender, RoutedEventArgs e)
        {
            txtOutput.Text = "";            //reset output text
            Input          = txtInput.Text; //reset input text to new text
            ListOfTokens.Clear();           //reset table

            getTokens(Input);

            if (Flag) //check if there is an error
            {
                foreach (TokenReg token in ListOfTokens)
                {
                    txtOutput.Text += token.ToString();
                }

                //Parser program
                try
                {
                    removeCommentTokens(); //remove comment tokens from list as we dont need them in the parsing process
                    Parser     p = new Parser(ListOfTokens);
                    SyntaxTree s = p.program();

                    TreeViewItem treeViewItem = makeTreeView(s);
                    Window1      secondWindow = new Window1();
                    secondWindow.mainTreeView.Items.Add(treeViewItem);
                    secondWindow.Show();
                }
                catch (ParsingErrorException ex)
                {
                    MessageBox.Show(ex.Message, ex.Source,
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }