Beispiel #1
0
 public Operator ReplaceOperator(Operator oldOp, Operator op)
 {
     for (int i = 0; i < this._numOps; i++)
     {
         if (this.ops[i] == oldOp)
         {
             this.ops[i] = op;
             op.SetPrecedence(oldOp.GetPrecedence());
         }
     }
     return(op);
 }
Beispiel #2
0
        public Operator InsertOperator(int key, Operator op, Operator existingOp)
        {
            this.AddOperator(key, op);
            int precedence = existingOp.GetPrecedence();

            for (int i = 0; i < this.ops.Length; i++)
            {
                if ((this.ops[i] != null) && (this.ops[i].GetPrecedence() >= precedence))
                {
                    this.ops[i].SetPrecedence(this.ops[i].GetPrecedence() + 1);
                }
            }
            op.SetPrecedence(precedence);
            return(op);
        }
Beispiel #3
0
        public Operator AppendOperator(int key, Operator op, Operator existingOp)
        {
            this.AddOperator(key, op);
            int i = existingOp.GetPrecedence() + 1;

            for (int j = 0; j < this.ops.Length; j++)
            {
                if ((this.ops[j] != null) && (this.ops[j].GetPrecedence() >= i))
                {
                    this.ops[j].SetPrecedence(this.ops[j].GetPrecedence() + 1);
                }
            }
            op.SetPrecedence(i);
            return(op);
        }
Beispiel #4
0
        public bool SetPrecedenceTable(int[][] precArray)
        {
            bool flag = true;

            for (int i = 0; i < precArray.Length; i++)
            {
                for (int j = 0; j < precArray[i].Length; j++)
                {
                    Operator @operator = this.GetOperator(precArray[i][j]);
                    if (@operator != null)
                    {
                        @operator.SetPrecedence(i);
                    }
                    else
                    {
                        flag = false;
                    }
                }
            }
            return(flag);
        }
Beispiel #5
0
 public Operator AddOperator(Operator op, Operator existingOp)
 {
     this.AddOperator(this.NumOps, op);
     op.SetPrecedence(existingOp.GetPrecedence());
     return(op);
 }
Beispiel #6
0
 public Operator AddOperator(int key, Operator op, Operator existingOp)
 {
     this.AddOperator(key, op);
     op.SetPrecedence(existingOp.GetPrecedence());
     return(op);
 }