/// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="dictionaryInfo"></param>
        /// <param name="callerContext"></param>
        internal ExpressionDictionaryCalculatorContext(ExpressionDictionary dictionaryInfo, object callerContext)
        {
            dictionaryInfo.NullCheck("dictionaryInfo");

            this.DictionaryInfo = dictionaryInfo;
            this.CallerContext = callerContext;
        }
Exemple #2
0
    /// <summary>
    /// Default constructor, creates an ExpressionParser object
    /// </summary>
    public ExpressionParser()
    {
        // Cache for values and expressions
        Values      = new ValuesDictionary();
        Expressions = new ExpressionDictionary();

        // Add all valid operators.
        DefaultOperators operators = new();

        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)
        {
            ImplicitMultiplication = true,
            RequireParentheses     = true
        };

        Culture = CultureInfo.InvariantCulture;
    }
Exemple #3
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;
        }
Exemple #4
0
 public void Setup()
 {
     _dictionary = new ExpressionDictionary();
 }
 public DictionaryToObjectMappingBuilder()
 {
     _mappingDictionary = new ExpressionDictionary <object, object, TResult>();
 }
Exemple #6
0
 public void Setup()
 {
     _dictionary = new ExpressionDictionary();
 }
Exemple #7
0
 /// <summary>
 /// Construct a new Lexical Scanner with some input.
 /// </summary>
 /// <param name="input">Input string</param>
 public LexicalScanner(string input)
 {
     _input = input;
     _dictionary = new ExpressionDictionary();
 }
 public NumberToFlagMappingBuilder()
 {
     _mappingDictionary = new ExpressionDictionary <int, bool, TResult>();
 }
Exemple #9
0
 public Tokenizer(ExpressionDictionary dictionary, string input)
 {
     _dictionary = dictionary;
     _input = input;
 }