Esempio n. 1
0
        public void Execute(List <Expression> instruction)
        {
            //Eliminar keyword de tipo IExecutable. No lo necesito para compilar.
            instruction.RemoveAt(0);

            if (SyntacticAnalysis(instruction))
            {
                string nameVariable = instruction[0].ToString();

                //Solo trabajar con las expresiones de la derecha del =
                instruction.RemoveAt(0); instruction.RemoveAt(0);

                //Si es un tipo Text y del operador =, y no hay mas tokens
                if (instruction.Count == 1 && (instruction[0] is Text))
                {
                    Memory.ChangeText(nameVariable, (instruction[0] as Text).Value);
                }

                //Es un tipo number
                else
                {
                    FunctionArithmetic ecuation = ConvertToConditionalFunction.FetchFunction(instruction);
                    //Guardar variable en la memoria
                    if (ecuation != null)
                    {
                        Memory.ChangeVariable(nameVariable, ecuation.Evaluate(0));
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Constructor de funcion local
        /// </summary>
        /// <param name="name">Representa el nombre de la funcion</param>
        /// <param name="fparam">Representa la funcion en la que se desea evaluar dicha funcion</param>
        public LocalFunction(string name, FunctionArithmetic fparam)
        {
            _existFunction = true;
            _name          = name;
            _function      = fparam;

            if (!Memory.DataFunction.ContainsKey(name))
            {
                _existFunction = false;
                MSharpErrors.OnError(string.Format("La funcion {0} no ha sido declarada", _name));
            }
        }
Esempio n. 3
0
        internal static void SaveFunction(string name, FunctionArithmetic function)
        {
            if (AnalizeFunction(name, function) == false)
            {
                return;
            }

            if (ExistName(name))
            {
                MSharpErrors.OnError(string.Format("Existe ya otro tipo con el nombre {0}", name));
                return;
            }

            Memory.DataFunction.Add(name, function);
        }
Esempio n. 4
0
 private static bool AnalizeFunction(string name, FunctionArithmetic function)
 {
     if (name == null || function == null)
     {
         if (name == null)
         {
             MSharpErrors.OnError(string.Format("Compilation Error. Nombre de variable no puede ser null", name));
         }
         else
         {
             MSharpErrors.OnError(string.Format("Compilation Error. La funcion {0} no puede ser null", name));
         }
         return(false);
     }
     return(true);
 }
Esempio n. 5
0
        public void Execute(List <Expression> instruction)
        {
            //Eliminar keyword de tipo IExecutable. No lo necesito para compilar.
            instruction.RemoveAt(0);

            if (SyntacticAnalysis(instruction))
            {
                FunctionArithmetic tempFunction = ConvertToConditionalFunction.FetchFunction(instruction);

                if (tempFunction != null)
                {
                    //Guardar la funcion
                    Memory.SaveFunction(name, ConvertToConditionalFunction.FetchFunction(instruction));
                }
            }
        }
Esempio n. 6
0
        public void Execute(List <Expression> instruction)
        {
            //Eliminar keyword de tipo IExecutable. No lo necesito para compilar.
            instruction.RemoveAt(0);

            if (SyntacticAnalysis(instruction))
            {
                if (instruction.Count == 1 && (instruction[0] is Text))
                {
                    if ((instruction[0] as Text).isOnlyText)
                    {
                        Display._output.Text += string.Format("{0}\n", (instruction[0] as Text).Value);
                    }
                    else
                    {
                        Display._output.Text += string.Format("{0}\n", Memory.GetText((instruction[0] as Text).Name));
                    }
                }

                else
                {
                    FunctionArithmetic ecuation = ConvertToConditionalFunction.FetchFunction(instruction);

                    float toShow = 0;
                    if (ecuation != null)
                    {
                        toShow = ecuation.Evaluate(0);
                    }

                    if (!Compiler._haveError)
                    {
                        Display._output.Text += string.Format("{0}\n", toShow);
                    }
                }
            }
        }
Esempio n. 7
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;
 }
Esempio n. 8
0
 public Relational(FunctionArithmetic left, FunctionArithmetic right)
 {
     this.left  = left;
     this.right = right;
 }
Esempio n. 9
0
 public LessOrEqual(FunctionArithmetic left, FunctionArithmetic right) : base(left, right)
 {
 }
Esempio n. 10
0
 public Elemental(FunctionArithmetic term) : base(term)
 {
 }
Esempio n. 11
0
 public RelationalComposite(FunctionArithmetic left, FunctionArithmetic right) : base(left, right)
 {
 }
Esempio n. 12
0
 public Exp(FunctionArithmetic function) : base(function)
 {
 }
Esempio n. 13
0
 public Atan(FunctionArithmetic function) : base(function)
 {
 }
Esempio n. 14
0
 public Sum(FunctionArithmetic left, FunctionArithmetic rigth) : base(left, rigth)
 {
 }
Esempio n. 15
0
 public Power(FunctionArithmetic left, FunctionArithmetic rigth) : base(left, rigth)
 {
 }
Esempio n. 16
0
 /// <summary>
 /// Constructor de la funcion Promedio. Recibe tres tipos de funciones aritmeticas las cuales sera promediadas
 /// </summary>
 /// <param name="first">Primera FunctionAritmetic</param>
 /// <param name="second">Segunda FunctionAritmetic</param>
 /// <param name="third">Tercera FunctionAritmetic</param>
 public Average(FunctionArithmetic first, FunctionArithmetic second, FunctionArithmetic third)
 {
     this._first = first; this._second = second; this._third = third;
 }
Esempio n. 17
0
 public Arccos(FunctionArithmetic function) : base(function)
 {
 }
Esempio n. 18
0
 /// <summary>
 /// Representa una Funcion Binaria
 /// </summary>
 /// <param name="left">El primer operando de tipo FunctionArithmeti</param>
 /// <param name="right">El segundo operando de tipo FunctionArithmeti</param>
 public BinaryFunction(FunctionArithmetic left, FunctionArithmetic right)
 {
     this.left  = left;
     this.right = right;
 }
Esempio n. 19
0
 public Different(FunctionArithmetic left, FunctionArithmetic right) : base(left, right)
 {
 }
Esempio n. 20
0
 public LogNep(FunctionArithmetic function) : base(function)
 {
 }
Esempio n. 21
0
 public Arcsin(FunctionArithmetic function) : base(function)
 {
 }
Esempio n. 22
0
 public Cot(FunctionArithmetic function) : base(function)
 {
 }
Esempio n. 23
0
 public UnaryFunction(FunctionArithmetic function)
 {
     this._function = function;
 }
Esempio n. 24
0
 public Negative(FunctionArithmetic function) : base(function)
 {
 }
Esempio n. 25
0
 public Division(FunctionArithmetic left, FunctionArithmetic rigth) : base(left, rigth)
 {
 }
Esempio n. 26
0
 public Trigonometric(FunctionArithmetic term) : base(term)
 {
 }
Esempio n. 27
0
 public RelationalSimple(FunctionArithmetic left, FunctionArithmetic right) : base(left, right)
 {
 }
Esempio n. 28
0
 public Derivate(FunctionArithmetic function) : base(function)
 {
 }
Esempio n. 29
0
 public GreaterOrEqual(FunctionArithmetic left, FunctionArithmetic right) : base(left, right)
 {
 }
Esempio n. 30
0
 public Multiplication(FunctionArithmetic left, FunctionArithmetic rigth) : base(left, rigth)
 {
 }