public static void Interpret(NonTerninalExp head,
                                     out List <String> operatorList,
                                     out List <String> consoleList)
        {
            var context = new Context();
            var c       = head;

            while (true)
            {
                if (c is EmptyEndCommand)
                {
                    break;
                }
                c.Execute(context);
                c = c.GetNext();
            }
            operatorList = context.OperatorsList;
            consoleList  = context.ConsoleOutput;
        }
Beispiel #2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            try
            {
                var lexicalAnalyzer = new LexicalAnalyzer();
                var lexems          = lexicalAnalyzer.Analyze(InputBox.Text);
                SyntaxBox.Text = lexicalAnalyzer.ToStr(lexems);


                NonTerninalExp com = SyntaxAnalyser.Analyse(lexems);
                List <String>  operatorsList;
                List <String>  consoleList;
                Interpreter.Interpret(com, out operatorsList, out consoleList);
                OperatorsBox.Lines = operatorsList.ToArray();
                ConsoleBox.Lines   = consoleList.ToArray();
            }
            catch (Exception msg)
            {
                MessageBox.Show(msg.ToString(), "Exception", MessageBoxButtons.OK);
            }
        }