Пример #1
0
        /// <summary>
        /// Attempts to either look up the symbol or convert it to one
        /// </summary>
        /// <param name="symbol"></param>
        /// <returns></returns>
        private Symbol ToSymbol(string symbol)
        {
            if (SYMBOLS.ContainsKey(symbol))
            {
                return(SYMBOLS[symbol]);
            }
            else if (OPERATORS.ContainsKey(symbol))
            {
                return(OPERATORS[symbol]);
            }
            else if (FUNCTIONS.ContainsKey(symbol))
            {
                return(FUNCTIONS[symbol]);
            }
            else if (IsNumeric(symbol))
            {
                return(new Symbol(double.Parse(symbol)));
            }
            else if (IsVariable(symbol))
            {
                return(new Symbol(symbol));
            }

            throw new Exception("ToSymbol : " + symbol + " cannot be converted to a Symbol");
        }
Пример #2
0
 /// <summary>
 /// Tests if a given input is contained in any of the Symbol Dictionaries
 /// </summary>
 /// <param name="symbol"></param>
 /// <returns></returns>
 private bool IsDefined(string symbol)
 {
     return(SYMBOLS.ContainsKey(symbol) ||
            OPERATORS.ContainsKey(symbol) ||
            FUNCTIONS.ContainsKey(symbol));
 }
Пример #3
0
 //Test if is an operator
 private bool IsOperator(string token)
 {
     return(OPERATORS.ContainsKey(token) || FUNCTIONS.ContainsKey(token));
 }