예제 #1
0
파일: Calculator.cs 프로젝트: jyorin/yinghe
        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"));
        }
예제 #2
0
파일: Parser.cs 프로젝트: jyorin/yinghe
 public Parser(Scanner scanner)
 {
     _scanner = scanner;
 }
예제 #3
0
파일: Parser.cs 프로젝트: ATouhou/QuranCode
 public Parser(Scanner scanner)
 {
     this.scanner = scanner;
 }