public Calculator() { _scanner = new Scanner(); _scanner.AddOperators("+", "-", "*", "/", "%", "(", ")", "=", ","); _parser = new Parser(_scanner); _parser.AddFunction(GenericFunctions.TrigFunction("sin", Math.Sin)); _parser.AddFunction(GenericFunctions.TrigFunction("cos", Math.Cos)); _parser.AddFunction(GenericFunctions.TrigFunction("tan", Math.Tan)); _parser.AddFunction(GenericFunctions.StandardFunction("sqrt", Math.Sqrt)); _parser.AddFunction(GenericFunctions.StandardFunction("abs", Math.Abs)); _parser.AddFunction(GenericFunctions.StandardFunction("log", Math.Log10)); _parser.AddFunction(GenericFunctions.StandardFunction("ln", (Func<double, double>)Math.Log)); _parser.AddFunction(GenericFunctions.StandardFunction("exp", Math.Exp)); _parser.AddFunction(GenericFunctions.InverseTrigFunction("asin", Math.Asin)); _parser.AddFunction(GenericFunctions.InverseTrigFunction("acos", Math.Acos)); _parser.AddFunction(GenericFunctions.InverseTrigFunction("atan", Math.Atan)); _parser.AddFunction(GenericFunctions.StandardFunction("pow", Math.Pow)); _parser.AddFunction(GenericFunctions.StandardFunction("max", Math.Max)); _parser.AddFunction(GenericFunctions.StandardFunction("min", Math.Min)); _parser.AddVariable(new Variable("pi", Math.PI) { IsConstant = true }); _parser.AddVariable(new Variable("e", Math.E) { IsConstant = true }); _parser.AddVariable(new Variable("ans")); }
public Parser(Scanner scanner) { _scanner = scanner; }
public Parser(Scanner scanner) { this.scanner = scanner; }