void conditonInterpreter(String arg1, String arg2, ConditionOperator operator1, WhileForm whileObj)
    {
        Expression whileNormalExpression = new Expression();

        arg1 = Clean(arg1);
        arg2 = Clean(arg2);

        int argInt1 = Int32.Parse(arg1);
        int argInt2 = Int32.Parse(arg2);

        //Debug.Log("condition tested: " +argInt1 +" " +operator1 +" " +argInt2);
        switch (operator1)
        {
        case ConditionOperator.LessThan:
            whileNormalExpression.condition = Expression.ConditionOperator.LessThan;
            break;

        case ConditionOperator.LessThanEquals:
            whileNormalExpression.condition = Expression.ConditionOperator.LessThanEquals;
            break;

        case ConditionOperator.MoreThan:
            whileNormalExpression.condition = Expression.ConditionOperator.LessThan;
            break;

        case ConditionOperator.MoreThanEquals:
            whileNormalExpression.condition = Expression.ConditionOperator.LessThan;
            break;
        }
        whileObj.mainExpression = whileNormalExpression;
        corpusInterpreter(whileObj.Corpus, whileObj);
    }
    void whileInterpreter(String condition, String corpus)
    {
        WhileForm whileObj = new WhileForm();

        whileObj.initiate();

        whileObj.Corpus = corpus;
        //Debug.Log ("Condição: " + condition);
        whileObj.mainExpression = expressionInterpreter(condition);
        corpusInterpreter(whileObj);
    }
    void corpusInterpreter(string corpus, WhileForm whileObj)
    {
        if (corpus.StartsWith("move"))
        {
            int stringIndexInitParam1 = 0;
            int stringIndexEndParam1  = 0;
            int stringIndexEndParam2  = 0;


            bool find1Param = true;
            bool find2Param = false;

            for (int i = 0; i < corpus.Length; i++)
            {
                if (find1Param)
                {
                    if (corpus [i].Equals('('))
                    {
                        stringIndexInitParam1 = i + 1;
                        //find1Param = false;
                        //find2Param = true;
                        continue;
                    }
                    if (corpus [i].Equals(','))
                    {
                        stringIndexEndParam1 = i;
                        find1Param           = false;
                        find2Param           = true;
                        continue;
                    }
                }
                else if (find2Param)
                {
                    if (corpus [i].Equals(')'))
                    {
                        stringIndexEndParam2 = i - 1;
                        find1Param           = true;
                        find2Param           = false;
                        break;
                    }
                }
            }
            String firstParam  = corpus.Substring(stringIndexInitParam1, stringIndexEndParam1 - stringIndexInitParam1);
            String secondParam = corpus.Substring(stringIndexEndParam1 + 1, stringIndexEndParam2 - stringIndexEndParam1);
            // Debug.Log ("1param: " + corpus.Substring (stringIndexInitParam1, stringIndexEndParam1 - stringIndexInitParam1));
            // Debug.Log ("2param: " + corpus.Substring (stringIndexEndParam1+1, stringIndexEndParam2 - stringIndexEndParam1));
            Command moveCommand = new Command();
            moveCommand.name = "MOVE";
            moveCommand.commandParams.Enqueue(firstParam);
            moveCommand.commandParams.Enqueue(secondParam);
            whileObj.commands.Enqueue(moveCommand);
        }
        pipeline.Enqueue(whileObj);
    }
    void Update()
    {
        Debug.Log(pipeline.Count);
        Queue executedPipeline = new Queue();

        while (pipeline.Count > 0)
        {
            System.Object task = pipeline.Dequeue();
            executedPipeline.Enqueue(task);
            //Need reform
            WhileForm whileCommand = (task as WhileForm);
            whileAct(whileCommand);
        }
        pipeline = executedPipeline;
    }
 void whileAct(WhileForm whileCommand)
 {
     if (expressionCheck(whileCommand.mainExpression))
     {
         Queue <Command> Executed = new Queue <Command> ();
         while (whileCommand.commands.Count > 0)
         {
             Command next = whileCommand.commands.Dequeue();
             Executed.Enqueue(next);
             switch (next.name)
             {
             case "MOVE":
                 object firstParam  = next.commandParams.Dequeue();
                 object secondParam = next.commandParams.Dequeue();
                 command_move((firstParam as string), float.Parse((secondParam as string)));
                 next.commandParams.Enqueue(firstParam);
                 next.commandParams.Enqueue(secondParam);
                 break;
             }
         }
         whileCommand.commands = Executed;
     }
 }
    void corpusInterpreter(WhileForm whileObj)
    {
        string corpus = whileObj.Corpus;

        ArrayList commands = new ArrayList(corpus.Split(';'));

        //Debug.Log ("corpus :" + corpus);

        foreach (string item in commands)
        {
            //Debug.Log ("corpus parted :" + item);
            if (item.StartsWith("move"))
            {
                int stringIndexInitParam1 = 0;
                int stringIndexEndParam1  = 0;
                int stringIndexEndParam2  = 0;


                bool find1Param = true;
                bool find2Param = false;

                for (int i = 0; i < item.Length; i++)
                {
                    if (find1Param)
                    {
                        if (item [i].Equals('('))
                        {
                            stringIndexInitParam1 = i + 1;
                            //find1Param = false;
                            //find2Param = true;
                            continue;
                        }
                        if (item [i].Equals(','))
                        {
                            stringIndexEndParam1 = i;
                            find1Param           = false;
                            find2Param           = true;
                            continue;
                        }
                    }
                    else if (find2Param)
                    {
                        if (item [i].Equals(')'))
                        {
                            stringIndexEndParam2 = i - 1;
                            find1Param           = true;
                            find2Param           = false;
                            break;
                        }
                    }
                }
                String firstParam  = item.Substring(stringIndexInitParam1, stringIndexEndParam1 - stringIndexInitParam1);
                String secondParam = item.Substring(stringIndexEndParam1 + 1, stringIndexEndParam2 - stringIndexEndParam1);
                // Debug.Log ("1param: " + corpus.Substring (stringIndexInitParam1, stringIndexEndParam1 - stringIndexInitParam1));
                // Debug.Log ("2param: " + corpus.Substring (stringIndexEndParam1+1, stringIndexEndParam2 - stringIndexEndParam1));
                Command moveCommand = new Command();
                moveCommand.initiate();

                moveCommand.name = "MOVE";
                moveCommand.commandParams.Enqueue(firstParam);
                moveCommand.commandParams.Enqueue(secondParam);
                whileObj.commands.Enqueue(moveCommand);
            }
            else if (item.StartsWith("bool") || item.StartsWith("int") || item.StartsWith("float"))
            {
                int     initIndex       = 0;
                Command variableCommand = new Command();
                variableCommand.initiate();
                variableCommand.name = "DECLARATION";
                //assignment params, [type, variable, operator 1, operation, operator 2]

                //need name
                //type command
                //value
                //bool isBool = false;
                if (item.StartsWith("bool"))
                {
                    //isBool = true;
                    initIndex = 3;
                    variableCommand.commandParams.Enqueue("bool");
                }
                else if (item.StartsWith("int"))
                {
                    initIndex = 2;
                    variableCommand.commandParams.Enqueue("int");
                }
                else
                {
                    initIndex = 4;
                    variableCommand.commandParams.Enqueue("float");
                }

                int nameVariableIndex = item.Length;
                //int operator1 = initIndex;
                //int operation = initIndex;
                //bool findName = true;
                //bool findOp1 = false;


                //else if (!isBool && findOp1)
                //{
                //	if (item [index].Equals ('+') || item [index].Equals ('-') || item [index].Equals ('*') || item [index].Equals ('/'))
                //	{
                //		operator1 = index;
                //		findOp1 = false;
                //		operation = index;
                //	}
                //}


                //Debug.Log ("VARIABLE 1 ASSIGNMET NAME: " + item.Substring ((initIndex + 1), (nameVariableIndex - (initIndex + 1))));
                //Debug.Log ("OPERATOR 1 ASSIGNMET NAME: " + item.Substring((
                //	nameVariableIndex+1), item.Length-(nameVariableIndex+1)));
                //Debug.Log ("VARIABLE ASSIGNMET OPERATION: " + item[operation]);
                //Debug.Log ("OPERATOR 2 ASSIGNMET NAME: " + item.Substring((operation+1), item.Length - (operation+1)));


                variableCommand.commandParams.Enqueue(item.Substring((initIndex + 1), (nameVariableIndex - (initIndex + 1))));
                //variableCommand.commandParams.Enqueue (item.Substring((nameVariableIndex+1), item.Length-(nameVariableIndex+1)));
                //variableCommand.commandParams.Enqueue (item[operation]);
                //variableCommand.commandParams.Enqueue (item.Substring((operation+1), item.Length - (operation+1)));


                whileObj.commands.Enqueue(variableCommand);
            }
            else
            {
                Command variableCommand = new Command();
                variableCommand.initiate();
                variableCommand.name = "ASSIGNMENT";

                int equalIndex = 0;
                for (int index = 0; index < item.Length; index++)
                {
                    if (item[index].Equals('='))
                    {
                        equalIndex = index;
                    }
                }
                string variable = item.Substring(0, equalIndex);
                string operationOverVariable = item.Substring(equalIndex + 1, item.Length - (equalIndex + 1));
                foreach (Variable elem in VariableScope)
                {
                    if (elem.name.Equals(variable))
                    {
                        variableCommand.commandParams.Enqueue(variable);
                        Debug.Log("VARIAVEL ENCONTRADA");
                        if (operationOverVariable.Contains('+') || operationOverVariable.Contains('-') || operationOverVariable.Contains('*') || operationOverVariable.Contains('/'))
                        {
                            char[] keys    = { '*', '/', '+', '-' };
                            int    opIndex = operationOverVariable.IndexOfAny(keys);

                            variableCommand.commandParams.Enqueue(operationOverVariable.Substring(0, opIndex));
                            variableCommand.commandParams.Enqueue(operationOverVariable [opIndex]);
                            variableCommand.commandParams.Enqueue(operationOverVariable.Substring(opIndex + 1, operationOverVariable.Length - (opIndex + 1)));

                            Debug.Log("command: " + operationOverVariable.Substring(0, opIndex) + "  " + operationOverVariable [opIndex] + "  " + operationOverVariable.Substring(opIndex + 1, operationOverVariable.Length - (opIndex + 1)));
                        }
                        else
                        {
                            variableCommand.commandParams.Enqueue(operationOverVariable);
                            Debug.Log("command: " + operationOverVariable);
                        }
                        break;
                    }
                }
                whileObj.commands.Enqueue(variableCommand);
            }
        }

        pipeline.Enqueue(whileObj);
    }
    void whileAct(WhileForm whileCommand)
    {
        //Debug.Log ("enter in act");
        //Debug.Log (whileCommand.mainExpression.firstArgument.numberValue + "  " + whileCommand.mainExpression.condition + "  " + whileCommand.mainExpression.secondArgument.numberValue);
        if (expressionCheck(whileCommand.mainExpression))
        {
            Debug.Log("enter in exp");
            Queue <Command> Executed = new Queue <Command> ();
            while (whileCommand.commands.Count > 0)
            {
                //Debug.Log ("enter in commands " +whileCommand.commands.Count);
                Command next = whileCommand.commands.Dequeue();
                //Debug.Log ("enter in commands " +whileCommand.commands.Count);
                Executed.Enqueue(next);
                //	Debug.Log ("named " +next.name);
                switch (next.name)
                {
                case "MOVE":
                    //Debug.Log ("enter here case");
                    object firstParam  = next.commandParams.Dequeue();
                    object secondParam = next.commandParams.Dequeue();
                    //Debug.Log ("commands  :" +firstParam + "  "  +secondParam);
                    command_move((firstParam as string), float.Parse((secondParam as string)));
                    next.commandParams.Enqueue(firstParam);
                    next.commandParams.Enqueue(secondParam);
                    break;

                case "DECLARATION":
                    object typeParam    = next.commandParams.Dequeue();
                    object varNameParam = next.commandParams.Dequeue();

                    switch (typeParam as string)
                    {
                    case "bool":
                        command_declaration(varNameParam as string, Variable.types.BOOL);
                        break;

                    case "float":
                        command_declaration(varNameParam as string, Variable.types.FLOAT);
                        break;

                    case "int":
                        command_declaration(varNameParam as string, Variable.types.INT);
                        break;
                    }
                    next.commandParams.Enqueue(typeParam);
                    next.commandParams.Enqueue(varNameParam);
                    break;

                case "ASSIGNMENT":
                    object nameVarA = next.commandParams.Dequeue();
                    Debug.Log("var: " + nameVarA as string);
                    if (next.commandParams.Count == 3)
                    {
                        Debug.Log("operation");
                        object receive1 = next.commandParams.Dequeue();
                        object opA      = next.commandParams.Dequeue();
                        object receive2 = next.commandParams.Dequeue();

                        Debug.Log("rec 1: " + receive1 as string);
                        Debug.Log("op: " + opA as string);
                        Debug.Log("rec 2: " + receive2 as string);

                        float item1F = 0;
                        float item2F = 0;
                        int   item1I = 0;
                        int   item2I = 0;

                        if (float.TryParse(receive1 as string, out item1F))
                        {
                            item1F = float.Parse(receive1 as string);
                            item1I = (int)item1F;
                        }
                        else
                        {
                            foreach (Variable elem in VariableScope)
                            {
                                if (elem.name.Equals(receive1 as string))
                                {
                                    switch (elem.type)
                                    {
                                    case Variable.types.FLOAT:
                                        item1F = elem.floatValue;
                                        item1I = (int)item1F;
                                        break;

                                    case Variable.types.INT:
                                        item1F = elem.intValue;
                                        item1I = elem.intValue;
                                        break;
                                    }
                                }
                            }
                        }

                        if (float.TryParse(receive2 as string, out item2F))
                        {
                            item2F = float.Parse(receive2 as string);
                            item2I = (int)item2F;
                        }
                        else
                        {
                            foreach (Variable elem in VariableScope)
                            {
                                if (elem.name.Equals(receive2 as string))
                                {
                                    switch (elem.type)
                                    {
                                    case Variable.types.FLOAT:
                                        item2F = elem.floatValue;
                                        item2I = (int)item2F;
                                        break;

                                    case Variable.types.INT:
                                        item2F = elem.intValue;
                                        item2I = elem.intValue;
                                        break;
                                    }
                                }
                            }
                        }
                        Debug.Log("OPERARARARARA: " + opA as string);
                        char op = (opA.ToString())[0];
                        command_assignment_operation(nameVarA as string, item1I, item1F, item2I, item2F, op);
                        next.commandParams.Enqueue(nameVarA);
                        next.commandParams.Enqueue(receive1);
                        next.commandParams.Enqueue(opA);
                        next.commandParams.Enqueue(receive2);
                    }
                    else
                    {
                        object receive = next.commandParams.Dequeue();
                        float  number  = 0;
                        if (float.TryParse(receive as string, out number))
                        {
                            command_assignment(nameVarA as string, int.Parse(receive as string), float.Parse(receive as string), false);
                        }
                        else
                        {
                            foreach (Variable elem in VariableScope)
                            {
                                if (elem.name.Equals(receive as string))
                                {
                                    switch (elem.type)
                                    {
                                    case Variable.types.BOOL:
                                        command_assignment(nameVarA as string, 0, 0, elem.boolValue);
                                        break;

                                    case Variable.types.FLOAT:
                                        command_assignment(nameVarA as string, 0, elem.floatValue, false);
                                        break;

                                    case Variable.types.INT:
                                        command_assignment(nameVarA as string, elem.intValue, 0, false);
                                        break;
                                    }
                                    break;
                                }
                            }
                        }
                        next.commandParams.Enqueue(nameVarA);
                        next.commandParams.Enqueue(receive);
                    }

                    break;
                }
            }
            whileCommand.commands = Executed;
        }
    }
    void whileInterpreter(String condition, String corpus)
    {
        WhileForm whileObj = new WhileForm();

        whileObj.Corpus = corpus;
        //Debug.Log ("Condição: " + condition);
        if (condition.StartsWith("true"))
        {
            Expression whileTrueExpression = new Expression();
            whileTrueExpression.condition = Expression.ConditionOperator.TRUE;
            whileObj.mainExpression       = whileTrueExpression;
        }
        else
        {
            bool              conditionTest = false;
            string            arg1Send      = "";
            string            arg2Send      = "";
            ConditionOperator operatorSend  = ConditionOperator.LessThan;
            int indexOperator = -99;
            for (int iterator = 0; iterator < condition.Length; iterator++)
            {
                if (condition[iterator].Equals('>') || condition[iterator].Equals('<'))
                {
                    Debug.Log("Founded a contitional " + iterator);
                    indexOperator = iterator;
                    if (condition [iterator + 1].Equals('='))
                    {
                        //Debug.Log ("firs Substring: 0 - " +indexOperator);
                        //Debug.Log ("second Substring: " +(indexOperator+2) +" - " +(condition.Length - indexOperator+2));
                        //Debug.Log(condition.Length + " \\ " +indexOperator);
                        arg1Send = condition.Substring(0, indexOperator);
                        arg2Send = condition.Substring((indexOperator + 2), (condition.Length - (indexOperator + 2)));
                        if (condition [iterator].Equals('>'))
                        {
                            operatorSend = ConditionOperator.MoreThanEquals;
                        }
                        else
                        {
                            operatorSend = ConditionOperator.LessThanEquals;
                        }
                        break;
                    }
                    else
                    {
                        //Debug.Log ("firs Substring: 0 - " +indexOperator);
                        //Debug.Log ("second Substring: " +(indexOperator+1) +" - " +(condition.Length - indexOperator+1));
                        //Debug.Log(condition.Length + " \\ " +indexOperator);
                        arg1Send = condition.Substring(0, indexOperator);
                        arg2Send = condition.Substring((indexOperator + 1), (condition.Length - (indexOperator + 1)));
                        if (condition [iterator].Equals('>'))
                        {
                            operatorSend = ConditionOperator.MoreThan;
                        }
                        else
                        {
                            operatorSend = ConditionOperator.LessThan;
                        }
                        break;
                    }
                }
            }
            conditonInterpreter(arg1Send, arg2Send, operatorSend, whileObj);
            //conditionTest
            //Debug.Log("Condição: " +conditionTest);
            //Interp the condition
        }
    }