private void ProcessFunction(Lexem lex) { var args = new List <Lexem>(); switch (lex.Content.ToString()) { case "print": while (Stack.Count > 0) { var arg = Stack.Pop(); args.Insert(0, arg); } Storage.AddToOutput(args, false); break; case "println": while (Stack.Count > 0) { var arg = Stack.Pop(); args.Insert(0, arg); } Storage.AddToOutput(args, true); break; case "scan": case "read": while (Stack.Count > 0) { var arg = Stack.Pop(); args.Insert(0, arg); } foreach (var lexem in args.Where(x => x.LexemType == LexemType.Variable)) { var window = new Editor.InputWindow(lexem); window.ShowDialog(); } break; case "rand": var rand = _rand.Next(Convert.ToInt32(Stack.Pop().ToDouble())); Stack.Push(new Lexem(rand, LexemType.Number, lex.Position)); break; } // Stack.Push(result) - если функция возвращает значение }
private void ProcessFunction(Lexem lex) { var args = new List<Lexem>(); switch (lex.Content.ToString()) { case "print": while (Stack.Count > 0) { var arg = Stack.Pop(); args.Insert(0, arg); } Storage.AddToOutput(args, false); break; case "println": while (Stack.Count > 0) { var arg = Stack.Pop(); args.Insert(0, arg); } Storage.AddToOutput(args, true); break; case "scan": case "read": while (Stack.Count > 0) { var arg = Stack.Pop(); args.Insert(0, arg); } foreach (var lexem in args.Where(x => x.LexemType == LexemType.Variable)) { var window = new Editor.InputWindow(lexem); window.ShowDialog(); } break; case "rand": var rand = _rand.Next(Convert.ToInt32(Stack.Pop().ToDouble())); Stack.Push(new Lexem(rand, LexemType.Number, lex.Position)); break; } // Stack.Push(result) - если функция возвращает значение }