/// <summary>
 /// Construct with an equal term
 /// </summary>
 /// <param name="e">equal term</param>
 public Verify(Equal e) : this(e, false)
 {
 }
 /// <summary>
 /// Construct with an equal term
 /// given a specific mode
 /// </summary>
 /// <param name="e">equal term</param>
 /// <param name="mode">mode</param>
 public Verify(Equal e, bool mode)
 {
     this.equalOp = e;
     this.texMode = mode;
 }
示例#3
0
        private Arithmetic calculate()
        {
            Arithmetic a = null, b = null;
            Arithmetic res = new NumericValue(0.0d);

            switch (this.stock[this.index])
            {
            case '=':
                ++this.index;
                a   = this.calculate();
                b   = this.calculate();
                res = new Equal(a, b);
                break;

            case '+':
                ++this.index;
                a   = this.calculate();
                b   = this.calculate();
                res = new Addition(a, b);
                break;

            case '-':
                ++this.index;
                a   = this.calculate();
                b   = this.calculate();
                res = new Soustraction(a, b);
                break;

            case '*':
                ++this.index;
                a   = this.calculate();
                b   = this.calculate();
                res = new Multiplication(a, b);
                break;

            case '/':
                ++this.index;
                a   = this.calculate();
                b   = this.calculate();
                res = new Division(a, b);
                break;

            case '^':
                ++this.index;
                a   = this.calculate();
                b   = this.calculate();
                res = new Power(a, b);
                break;

            case 'v':
                ++this.index;
                a   = this.calculate();
                b   = this.calculate();
                res = new Root(a, b);
                break;

            case 'p':
                ++this.index;
                string funp = this.words[(int)this.stock[this.index]];
                res = new Parenthese(Expression.Convert(funp));
                ++this.index;
                break;

            case 'g':
                ++this.index;
                string fung = this.words[(int)this.stock[this.index]];
                res = new Crochet(Expression.Convert(fung));
                ++this.index;
                break;

            case '@':
                ++this.index;
                res = new NumericValue((double)this.stock[this.index]);
                ++this.index;
                break;

            case 'ù':
                ++this.index;
                if (this.isNotLower(this.words[(int)this.stock[this.index]]))
                {
                    res = new UnknownTerm(this.words[(int)this.stock[this.index]]);
                }
                else
                {
                    res = new Coefficient(this.words[(int)this.stock[this.index]]);
                }
                ++this.index;
                break;

            case 'µ':
                ++this.index;
                string fun = this.words[(int)this.stock[this.index]];
                ++this.index;
                res = new Function(fun, this.calculate());
                break;

            case ',':
                string paramLeft = string.Empty, paramRight = string.Empty;
                if (this.stock[index] == ',')
                {
                    ++this.index;
                    a = this.calculate();
                }
                else
                {
                    b = this.calculate();
                }
                if (this.stock[index] == ',')
                {
                    ++this.index;
                    b = this.calculate();
                }
                else
                {
                    b = calculate();
                }
                List <IArithmetic> list = new List <IArithmetic>();
                if (a is Sequence)
                {
                    list.AddRange((a as Sequence).Items);
                }
                else
                {
                    list.Add(a);
                }
                if (b is Sequence)
                {
                    list.AddRange((b as Sequence).Items);
                }
                else
                {
                    list.Add(b);
                }
                res = new Sequence(list);
                break;
            }
            return(res);
        }