private Value Function(FunctionNode exp) { List <FunctionDefinition> funcList; try { funcList = functionTable[exp.FunctionName]; } catch (Exception) { throw new ModelInterpreterException($"Неизвестная функция \"{exp.FunctionName}\"") { Line = exp.Line, Position = exp.Position }; } List <Constant> args = new List <Constant>(); foreach (ExpressionNode expNode in exp.Arguments) { Constant obj = Eval(expNode).GetRValue(); args.Add(obj); } Exception lastExc = null; foreach (FunctionDefinition fd in funcList) { try { return(FunctionDefinition.Compute(fd, args)); } catch (Exception exc) { lastExc = exc; } } if (lastExc != null) { throw new ModelInterpreterException(lastExc.Message) { Line = exp.Line, Position = exp.Position }; } string exceptionMessage = $"Не существует подходящего определения для функции {exp.FunctionName} ( "; int i = 0; foreach (var arg in args) { if (i != 0) { exceptionMessage += ", "; } exceptionMessage += arg.ConstantType.ToString(); } exceptionMessage += ")"; throw new ModelInterpreterException(exceptionMessage) { Line = exp.Line, Position = exp.Position }; }