Пример #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);
        }
Пример #2
0
 public override int Evaluate() => _table[_operator](_leftNode.Evaluate(), _rightNode.Evaluate());
Пример #3
0
 public Operator(string op, TableOfOperations table)
 {
     _operator = op;
     _table    = table;
 }