Exemple #1
0
 public void Append(Token t) {
     if (t.type == Token.Type.Operator && t.lexema == "{") {
         flag = true;
         newblock = new Opcodes();
     }
     if (flag) {
         if (t.type == Token.Type.Operator && t.lexema == "}") {
             flag = false;
             this.ops.AddLast(newblock);
         }
         else 
             newblock.Append(t);   
     }
     else 
         ops.AddLast(t);
 }
Exemple #2
0
        private void ProcessOperator(string op) {
            try {
                switch (op) {
                    case "<-":
                        exptFuCallFlag = true;
                        break;
                    case "+":
                        CallFunction(new Id("Add"));
                        break;
                    case "-":
                        pStack.Push(-(double)pStack.Pop() + (double)pStack.Pop());
                        break;

                    case "*":
                        pStack.Push((double)pStack.Pop() * (double)pStack.Pop());
                        break;
                    case ";":
                        pStack = new Stack<object>();
                        break;
                    case "=":
                        CallFunction(new Id("Be"));
                        break;
                    case "{":
                        opBlockFlag = true;
                        newblock = new Opcodes();
                        break;
                    

                    default: 
                        throw new Exception("invalid Operator");
                        break;
                }
            }
            catch (InvalidOperationException e) {
                throw new Exception("Noth enoth openders to continue the operation");
            }
        }