Exemple #1
0
        public ParseTree(string expression)
        {
            if (string.IsNullOrWhiteSpace(expression))
            {
                _root = new Operand(0);
                return;
            }

            _table = new TableOfOperations();

            var tokens = expression.Split(' ');
            var iter   = GetSequence(tokens);

            BuildTree(ref _root, iter);
        }
Exemple #2
0
 public override int Evaluate() => _table[_operator](_leftNode.Evaluate(), _rightNode.Evaluate());
Exemple #3
0
 public Operator(string op, TableOfOperations table)
 {
     _operator = op;
     _table    = table;
 }