Esempio n. 1
0
        /// <summary>
		/// Default constructor, creates an ExpressionParser object
		/// </summary>
		public ExpressionParser()
		{
            // Cache for values and expressions
            htbl = new ValuesDictionary();
            cachedExpressions = new ExpressionDictionary();

			// Add all valid operators.
            DefaultOperators operators = new DefaultOperators();
            ops = new Dictionary<string, Operator>();

            foreach (Operator op in operators.Operators)
            {
                string symbol = op.Symbol;
                if(symbol.Length > maxoplength)
                {
                    maxoplength = symbol.Length;
                }

                ops.Add(symbol, op);
            }

			// Constants
            spconst = new Dictionary<string, double>();
			spconst.Add( "euler",     Math.E  );
			spconst.Add( "pi" ,       Math.PI );
			spconst.Add( "nan" ,      double.NaN );
			spconst.Add( "infinity" , double.PositiveInfinity );
			spconst.Add( "true" ,    1D  );
			spconst.Add( "false",    0D );

            treeParser = new TreeParser(ops, spconst);
            treeParser.ImplicitMultiplication = true;
            treeParser.RequireParentheses = true;

            Culture = CultureInfo.InvariantCulture;
		}
Esempio n. 2
0
        /// <summary>
        /// Default constructor, creates an ExpressionParser object
        /// </summary>
        public ExpressionParser()
        {
            // Cache for values and expressions
            htbl = new ValuesDictionary();
            cachedExpressions = new ExpressionDictionary();

            // Add all valid operators.
            DefaultOperators operators = new DefaultOperators();
            ops = new Dictionary<string, Operator>();

            foreach (Operator op in operators.Operators)
            {
                string symbol = op.Symbol;
                if(symbol.Length > maxoplength)
                {
                    maxoplength = symbol.Length;
                }

                ops.Add(symbol, op);
            }

            // Constants
            spconst = new Dictionary<string, double>();
            spconst.Add( "euler",     Math.E  );
            spconst.Add( "pi" ,       Math.PI );
            spconst.Add( "nan" ,      double.NaN );
            spconst.Add( "infinity" , double.PositiveInfinity );
            spconst.Add( "true" ,    1D  );
            spconst.Add( "false",    0D );

            treeParser = new TreeParser(ops, spconst);
            treeParser.ImplicitMultiplication = true;
            treeParser.RequireParentheses = true;

            Culture = CultureInfo.InvariantCulture;
        }