Beispiel #1
0
 public NegationLogic(FunctionBoolean term) : base(term)
 {
 }
Beispiel #2
0
 /// <summary>
 /// Constructor de Funcion
 /// </summary>
 /// <param name="body">Cuerpo de la funcion</param>
 /// <param name="proposition">Proposicion a evaluar</param>
 /// <param name="ptrElse">Puntero a otra funcion condicional</param>
 public ConditionalFunction(FunctionArithmetic body, FunctionBoolean proposition, ConditionalFunction ptrElse)
 {
     this.body        = body;
     this.proposition = proposition;
     this.ptrElse     = ptrElse;
 }
Beispiel #3
0
 public Logic(FunctionBoolean left, FunctionBoolean right)
 {
     this.left = left; this.right = right;
 }
Beispiel #4
0
 public OrLogic(FunctionBoolean left, FunctionBoolean right) : base(left, right)
 {
 }
Beispiel #5
0
 public UnaryOperator(FunctionBoolean term)
 {
     this.term = term;
 }
Beispiel #6
0
        //Metodo que asigna a las listas miembros de la clase, las funciones aritmeticas y las
        //funciones booleanas(proposiciones) de la condicional
        private static bool Create_List(List <Expression> expression)
        {
            List <Function> function = new List <Function>();

            for (int i = 0; i < expression.Count; i++)
            {
                if (expression[i] is If)
                {
                    Function tempFunction1 = Converter_ShuntingYard.FetchFunction(function);

                    if (!(tempFunction1 is FunctionArithmetic))
                    {
                        MSharpErrors.OnError("Incorrecta expresion");
                        return(false);
                    }


                    FunctionArithmetic tempFunction = tempFunction1 as FunctionArithmetic;

                    _listBody.Add(tempFunction);
                    function.Clear();
                }

                else if (expression[i] is Else)
                {
                    Function tempFunction1 = Converter_ShuntingYard.FetchFunction(function);

                    if (!(tempFunction1 is FunctionBoolean))
                    {
                        MSharpErrors.OnError("Incorrecta expresion");
                        return(false);
                    }


                    FunctionBoolean tempFunction = tempFunction1 as FunctionBoolean;

                    _listCondition.Add(tempFunction);
                    function.Clear();
                }

                else
                {
                    if (!(expression[i] is Function))
                    {
                        MSharpErrors.OnError("Incorrecta expresion");
                        return(false);
                    }

                    function.Add(expression[i] as Function);
                }
            }

            //Formar funcion que quedó
            Function lastFunction = Converter_ShuntingYard.FetchFunction(function);

            if (!(lastFunction is FunctionArithmetic) && !(lastFunction is FunctionBoolean))
            {
                MSharpErrors.OnError("Incorrecta expresion");
                return(false);
            }


            if (lastFunction is FunctionArithmetic)
            {
                _listBody.Add(lastFunction as FunctionArithmetic);
            }
            else
            {
                _listCondition.Add(lastFunction as FunctionBoolean);
            }

            if (_listBody.Count < _listCondition.Count == true)
            {
                MSharpErrors.OnError("Incorrecta funcion");
                return(false);
            }


            //Significa que termina en else -> ultima condicion true si no ocurre ninguna otra
            if (_listBody.Count - _listCondition.Count == 1)
            {
                _listCondition.Add(new ConstantBoolean(true));
            }


            return(true);
        }