private Ambito soobreEscribeParams(Constructor c, Ambito m, List <Object> valores)
 {
     try
     {
         if (valores.Count == c.parametros.Count)
         {
             for (int x = 0; x < valores.Count; x++)
             {
                 String   tipo = c.parametros.ElementAt(x).tipo.ToLower();
                 String   id   = c.parametros.ElementAt(x).idparam.ToLower();
                 Variable v    = new Variable(id, tipo, Estatico.Vibililidad.LOCAL, valores.ElementAt(x));
                 if (m.existeVariable(id.ToLower()))
                 {
                     Simbolo  s   = m.getSimbolo(id.ToLower());
                     Variable aux = (Variable)s;
                     aux.valor = v.valor;
                 }
             }
         }
     }
     catch
     {
         TError error = new TError("Ejecucion", "Error al ejecutar los parametros en clase: " + this.clase, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(m);
 }
Example #2
0
 public object Ejecutar(Ambito ambito)
 {
     try
     {
         Clave clave = new Clave(this.idfuncion.ToLower(), this.parametros, "");
         if (!ambito.existeFuncion(clave))
         {
             Funcion f = new Funcion(this.instrucciones, this.parametros, this.idfuncion.ToLower(), this.tipo, this.visibilidad, this.linea, this.columna, this.clase);
             ambito.agregarFuncionAlAmbito(clave, f);
         }
         else
         {
             TError error = new TError("Semantico", "Ya existe una definicion de Funcion: " + this.idfuncion + " con la misma cantidad de parametros y tipo | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
             Estatico.errores.Add(error);
             Estatico.ColocaError(error);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error en la ejecucion de Declaracion de Funcion: " + this.idfuncion + " | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Error: " + e.Message, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(null);
 }
Example #3
0
 public object getValor(Ambito ambito)
 {
     try
     {
         //ESTA FUNCION AUN HAY QYE MEJORARLA
         object valorReal = this.exp.getValor(ambito);
         String tam       = valorReal.ToString();
         if (valorReal is Nulo)
         {
             return(0);
         }
         else
         {
             val = "entero";
             return(tam.Length);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al ejecutar la funcion: Tam() | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(0);
 }
 public object Ejecutar(Ambito ambito)
 {
     try
     {
         ClaveFuncion clave = new ClaveFuncion(this.clase.ToLower(), "vacio", this.parametros);
         if (!ambito.existeConstructor(clave))
         {
             Constructor c = new Constructor(this.parametros, instrucciones, this.linea, this.columna, this.clase);
             ambito.agregarConstructor(clave, c);
         }
         else
         {
             TError error = new TError("Semantico", "Ya existe una definicion de Constructor: " + this.clase + " con la misma cantidad de parametros y tipo | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
             Estatico.errores.Add(error);
             Estatico.ColocaError(error);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error en la ejecucion de Declaracion de Constructor: " + this.clase + " | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Error: " + e.Message, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(null);
 }
Example #5
0
 public object getValor(Ambito ambito)
 {
     try
     {
         if (retornaVacio)
         {
             this.ValorAux = new Vacio();
             NodoReturn n = new NodoReturn(this.ValorAux, "vacio");
             return(n);
         }
         else
         {
             this.ValorAux = this.expresion.getValor(ambito);
             NodoReturn n = new NodoReturn(this.ValorAux, getTipo(ambito).ToLower());
             return(n);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "No se ejecuto de buena forma el retorno: Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | " + e.Message, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(new Vacio());
 }
Example #6
0
 public object Ejecutar(Ambito ambito)
 {
     try
     {
         List <Object> valores = getValoresParam(ambito);
         ClaveFuncion  clave   = new ClaveFuncion("padre", "vacio", getNodoParametros(ambito));
         Ambito        aux     = buscaElGlobal(ambito);
         Constructor   c       = aux.getConstructor(clave);
         if (c != null)
         {
             Ambito local = new Ambito(ambito, "padre", ambito.archivo);
             local = c.seteaParametrosLocales(local, valores);
             c.Ejecutar(local);
             return(new Nulo());
         }
         else if (c == null && this.expresiones.Count == 0)
         {
             return(new Nulo());
         }
         else
         {
             TError error = new TError("Ejecucion", "No existe un construcotr de la clase padre que contenga los parametros indicados en Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
             Estatico.errores.Add(error);
             Estatico.ColocaError(error);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al intentar ejecutar Super en Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Error: " + e.Message, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(new Nulo());
 }
 public object Ejecutar(Ambito ambito)
 {
     try
     {
         Object objeto = ObjetoAsignar.getValor(ambito);
         if (objeto is Objeto)
         {
             Objeto aux   = (Objeto)objeto;
             Ambito ambOb = aux.ambito;
             asignacionValor.Ejecutar(ambOb);
         }
         else //EN CASO DE QUE NO FUERA OBJETO
         {
             TError error = new TError("Semantico", "Se esta intentando asignar a un Tipo de dato que no es Objeto! | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
             Estatico.errores.Add(error);
             Estatico.ColocaError(error);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error de Ejecucion al intentar asignar posicion de un Arreglo | " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(null);
 }
 public object Ejecutar(Ambito ambito)
 {
     try
     {
         foreach (Object ob in this.instrucciones)
         {
             if (ob is Instruccion)
             {
                 Instruccion aux = (Instruccion)ob;
                 Object      res = aux.Ejecutar(ambito);
                 if (res is NodoReturn)
                 {
                     return(res);
                 }
             }
             else if (ob is Expresion)
             {
                 Expresion exp = (Expresion)ob;
                 Object    res = exp.getValor(ambito);
                 if (res is NodoReturn)
                 {
                     return(res);
                 }
             }
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al Ejecutar la funcion: " + idFuncion + " | Error: " + e.Message, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(new NodoReturn(new Vacio(), "vacio"));
 }
 public object getValor(Ambito ambito)
 {
     try
     {
         Object valor = exp.getValor(ambito);
         if (valor is int)
         {
             int v = (int)valor;
             this.valor = Math.Tan(v);
             return(this.valor);
         }
         else if (valor is double)
         {
             double v = (double)valor;
             this.valor = Math.Tan(v);
             return(this.valor);
         }
         else
         {
             TError error = new TError("Semantico", "El parametro que reciba la Funcion Tan() puede ser Entero o Decimal | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
             Estatico.errores.Add(error);
             Estatico.ColocaError(error);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al ejecutar la funcion Tan() | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     this.valor = 0.0;
     return(0.0);
 }
        public object Ejecutar(Ambito ambito)
        {
            try
            {
                DamePregunta dame = new DamePregunta(identificador, parametros, clase, linea, columna, estilo.tipo, "", this.numero);
                Pregunta     p    = dame.getPregunta(ambito);
                if (p != null)
                {
                    Objeto ob       = dame.ob;
                    Ambito auxiliar = dame.ambPregu;

                    llamadaACalcular(auxiliar, null);

                    llamadaACalcular(auxiliar, null);

                    ob.ambito = dame.ambPregu;
                }
            }
            catch (Exception e)
            {
                TError error = new TError("Ejecucion", "Error al ejecutar el metodo Calcular: " + this.identificador + " | Clase: " + clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
                Estatico.ColocaError(error);
                Estatico.errores.Add(error);
            }
            return(new Nulo());
        }
Example #11
0
 public object getValor(Ambito ambito)
 {
     try
     {
         Simbolo s = (Simbolo)ambito.getSimbolo(this.id.ToLower());
         if (s != null)
         {
             if (s is Arreglo)
             {
                 Arreglo    aux        = (Arreglo)s;
                 List <int> coordenada = getDimensiones(ambito);
                 if (coordenada != null)
                 {
                     if (aux.esCoordenadaValida(coordenada))
                     {
                         int    realIndex = aux.calcularPosicion(coordenada);
                         Object valor     = aux.getElementFromArray(realIndex);
                         this.ValorAux = valor;
                         return(valor);
                     }
                     else
                     {
                         TError error = new TError("Semantico", "Para el arreglo: \"" + this.id + "\" La Dimension no se encuentra dentro de los limites! | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
                         Estatico.errores.Add(error);
                         Estatico.ColocaError(error);
                     }
                 }
                 else
                 {
                     TError error = new TError("Semantico", "Para el arreglo: \"" + this.id + "\" No se ha proporcionado un Entero como Dimension del Mismo | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
                     Estatico.errores.Add(error);
                     Estatico.ColocaError(error);
                 }
             }
             else
             {
                 TError error = new TError("Semantico", "El simbolo: \"" + this.id + "\" No es un arreglo por lo que no se puede acceder al valor indicado | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
                 Estatico.errores.Add(error);
                 Estatico.ColocaError(error);
             }
         }
         else
         {
             TError error = new TError("Semantico", "No existe el Arreglo: \"" + this.id + "\" en este Ambito | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
             Estatico.errores.Add(error);
             Estatico.ColocaError(error);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al acceder al valor de arreglo: \"" + id + "\" | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     this.ValorAux = new Nulo();
     return(ValorAux);
 }
Example #12
0
        private void declaracionApartirExp(Ambito ambito)
        {
            if (!ambito.existeVariable(this.idArr.ToLower()))
            {
                //TENGO QUE VER SI LO QUE ME RETORNA LA EXPRESION ES UN ARREGLO Y SI HACE MATCH CON LOS DATOS QUE TENGO
                Object arr     = this.exp.getValor(ambito);
                String tipoaux = this.exp.getTipo(ambito);
                if (arr is Arreglo)
                {
                    Arreglo arreglo = (Arreglo)arr;

                    if (this.NumDim == arreglo.numDimensiones)
                    {
                        if (arreglo.Tipo.Equals("nuevo"))
                        {
                            arreglo.setID(this.idArr);
                            arreglo.setTipo(this.tipo.ToLower());
                            arreglo.setVisibilidad(this.visibilidad);

                            ambito.agregarVariableAlAmbito(this.idArr.ToLower(), arreglo);
                        }
                        else if (arreglo.Tipo.ToLower().Equals(this.tipo.ToLower()))
                        {
                            ambito.agregarVariableAlAmbito(this.idArr.ToLower(), arreglo);
                        }
                        else
                        {
                            TError error = new TError("Semantico", "Los tipos del arreglo no concuerdan, se esperaba: \"" + this.tipo + "\" y se econtro: \"" + arreglo.Tipo.ToLower() + "\"" + "  | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
                            Estatico.errores.Add(error);
                            Estatico.ColocaError(error);
                        }
                    }
                    else
                    {
                        TError error = new TError("Semantico", "Para \"" + this.idArr.ToLower() + "\", Las dimensiones no concuerdan se esperaba: " + this.NumDim + ", dimensiones y se encontraron: " + arreglo.numDimensiones + "  | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
                        Estatico.errores.Add(error);
                        Estatico.ColocaError(error);
                    }
                }
                else if (arr is Nulo)
                {
                    ambito.agregarVariableAlAmbito(this.idArr.ToLower(), new Arreglo(new List <object>(), new List <int>(), this.NumDim, this.idArr.ToLower(), true, this.visibilidad, this.tipo));
                }
                else
                {
                    TError error = new TError("Semantico", "Se esperaba un arreglo como valor para: \"" + this.idArr + "\", se encontro: \"" + tipoaux + "\"  | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
                    Estatico.errores.Add(error);
                    Estatico.ColocaError(error);
                }
            }
            else
            {
                TError error = new TError("Semantico", "Ya existe una declaracion de: \"" + this.idArr + "\" en este Ambito | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
                Estatico.errores.Add(error);
                Estatico.ColocaError(error);
            }
        }
Example #13
0
        public object getValor(Ambito ambito)
        {
            try
            {
                Object cad     = cadena.getValor(ambito);
                String tipocad = cadena.getTipo(ambito);

                Object inf     = num1.getValor(ambito);
                String tipoInf = num1.getTipo(ambito);

                Object sup     = num2.getValor(ambito);
                String tipoSup = num2.getTipo(ambito);

                if (cad is String && inf is int && sup is int)
                {
                    String cadena   = (String)cad;
                    int    inferior = (int)inf;
                    int    superior = (int)sup;

                    if (inferior >= 0 && superior >= 0)
                    {
                        if (superior < cadena.Length)
                        {
                            tipo = cadena.Substring(inferior, superior);
                            return(tipo);
                        }
                        else
                        {
                            TError error = new TError("Semantico", "El limite superior no debe ser menor al largo de la cadena! | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                            Estatico.errores.Add(error);
                            Estatico.ColocaError(error);
                        }
                    }
                    else
                    {
                        TError error = new TError("Semantico", "Parametros de Funcion SubCadena deben ser mayores a 0 | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                        Estatico.errores.Add(error);
                        Estatico.ColocaError(error);
                    }
                }
                else
                {
                    TError error = new TError("Semantico", "Funcion SubCade requiere parametros: (cadena, entero, entero) y se encontro: (" + tipocad + "," + tipoInf + "," + tipoSup + ") | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                    Estatico.errores.Add(error);
                    Estatico.ColocaError(error);
                }
            }
            catch (Exception e)
            {
                TError error = new TError("Ejecucion", "Error al ejecutar la funcion SubCadena | Clase: " + clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
                Estatico.errores.Add(error);
                Estatico.ColocaError(error);
            }
            return(new Nulo());
        }
Example #14
0
        public object Ejecutar(Ambito ambito)
        {
            /// YA QUE LO VOY A TRATAR COMO UN OBJETO:
            /// 1) DEBO DE COLOCARLE UN CONSTRUCTOR AL CUAL ME VA A SERVIR PARA PODER MANDARLE LOS PARAMETROS CUANDO ESTA SE LLAME
            /// 2) AL MOMENTO DE LLAMAR LA PREGUNTA DEBO DE MANDARLE LOS MISMOS PARAMETROS PARA INSTANCIAR LA PREGUNTA QUE EN TEORIA DEBERIAN SER LOS MISMOS
            /// 3) LA PREGUNTA LA VOY A GUARDAR COMO UN OBJETO DENTRO DEL AMBITO DE LA CLASE LA CUAL VA A GUARDAR COMO UNA VARIABLE QUE A GUARDAR COMO VALOR OBJETO DE TIPO
            /// PREGUNTA
            try
            {
                if (!ambito.existeVariable(this.identificador.ToLower()))
                {
                    Ambito amPregunta = new Ambito(ambito, this.identificador.ToLower(), ambito.archivo);

                    /*CREO EL CONSTRUCTOR DE LA PREGUNTA QUE ME VA A SERVIR PARA PODER DECLARAR EN EL AMBITO LAS VARIABLES*/
                    Constructor c = new Constructor(this.parametros, new List <Instruccion>(), linea, columna, clase);

                    /*AGREGO EL CONSTRUCTOR DE LA PREGUNTA AL AMBITO*/
                    amPregunta.agregarConstructor(new ClaveFuncion(this.identificador.ToLower(), "vacio", parametros), c);

                    /*VOY A A GREGAR UNA VARIABLE TEMPORAL PARA QUE ENTONCES PUEDA GUARDAR LAS INSTRUCCIONES :) */
                    Variable v = new Variable("instr", "vale", Estatico.Vibililidad.PRIVADO, this.declaraciones);

                    /*LA AGREGO AL AMBITO DE ESTA PREGUNTA :)*/
                    amPregunta.agregarVariableAlAmbito("instr", v);

                    /*CREO EL OBJETO DE TIPO PREGUNTA*/
                    Objeto pregunta = new Objeto("pregunta", amPregunta);

                    /*AGREGO LA VARIABLE AL AMBITO ACTUAL PARA PODER ACCERDER A LA PREGUNTA EN UN LLAMADO A LA MISMA*/
                    Variable p = new Variable(this.identificador.ToLower(), "pregunta", Estatico.Vibililidad.PRIVADO, pregunta);

                    /*AGREGO LA VARIABLE EN EL AMBITO Y TERMINA*/
                    ambito.agregarVariableAlAmbito(this.identificador.ToLower(), p);

                    return(new Nulo());
                }
                else
                {
                    TError error = new TError("Semantico", "Ya existe una definicion de un simbolo: \"" + identificador + "\", las preguntas se tratan como objetos por lo que no pueden haber multiples definiciones de un objeto con el mismo nombre | Clase"
                                              + clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                    Estatico.ColocaError(error);
                    Estatico.errores.Add(error);
                }
            }
            catch (Exception e)
            {
                TError erro = new TError("Ejecucion", "Error al intentar ejecutar la declaracion de una pregunta | Clase: " + clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
                Estatico.errores.Add(erro);
                Estatico.ColocaError(erro);
            }
            return(new Nulo());
        }
Example #15
0
 private void declaracionVacia(Ambito ambito)
 {
     if (!ambito.existeVariable(this.idArr.ToLower()))
     {
         Arreglo arr = new Arreglo(new List <object>(), new List <object>(), new List <int>(), this.NumDim, this.idArr.ToLower(), true, this.visibilidad, this.tipo);
         ambito.agregarVariableAlAmbito(this.idArr.ToLower(), arr);
     }
     else
     {
         TError error = new TError("Semantico", "Ya existe una declaracion de: \"" + this.idArr + "\" en este Ambito | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
 }
Example #16
0
 public object getValor(Ambito ambito)
 {
     try
     {
         return(Math.Round(Math.PI, 5));
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al ejecutar la funcion Pi() | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(0.0);
 }
        public object getValor(Ambito ambito)
        {
            try
            {
                object basse = expresion.getValor(ambito);
                object pot   = potencia.getValor(ambito);

                if (basse is int && pot is int)
                {
                    int b = (int)basse;
                    int p = (int)pot;
                    this.valor = Math.Pow(b, p);
                    return(this.valor);
                }
                else if (basse is int && pot is double)
                {
                    int    b = (int)basse;
                    double p = (double)pot;
                    this.valor = Math.Pow(b, p);
                    return(this.valor);
                }
                else if (basse is double && pot is int)
                {
                    double b = (double)basse;
                    int    p = (int)pot;
                    this.valor = Math.Pow(b, p);
                    return(this.valor);
                }
                else if (basse is double && pot is double)
                {
                    double b = (double)basse;
                    double p = (double)pot;
                    this.valor = Math.Pow(b, p);
                    return(this.valor);
                }
                else
                {
                    TError error = new TError("Semantico", "La funcion Pow() no se encontro parametros validos, se esperan: Pow(entero/decimal, entero/decimal) | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                    Estatico.errores.Add(error);
                    Estatico.ColocaError(error);
                }
            }
            catch (Exception e)
            {
                TError error = new TError("Ejecucion", "Error al ejecutar la funcion Pow | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
                Estatico.errores.Add(error);
                Estatico.ColocaError(error);
            }
            return(0.0);
        }
 public object Ejecutar(Ambito ambito)
 {
     try
     {
         Simbolo s = (Simbolo)ambito.getSimbolo(this.id.ToLower());
         if (s != null)
         {
             if (s is Variable && (s.Tipo.ToLower().Equals("entero") || s.Tipo.ToLower().Equals("decimal")))
             {
                 Variable v = (Variable)s;
                 if (v.valor is int)
                 {
                     int aux = (int)v.valor;
                     v.valor = aux - 1;
                 }
                 else if (v.valor is Double)
                 {
                     double aux = (double)v.valor;
                     v.valor = aux - 1;
                 }
                 else
                 {
                     TError error = new TError("Semantico", "El Simbolo: \"" + this.id.ToLower() + "\" Posiblemente no ha sido inicializada! | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                     Estatico.errores.Add(error);
                     Estatico.ColocaError(error);
                 }
             }
             else
             {
                 TError error = new TError("Semantico", "El Simbolo: \"" + this.id.ToLower() + "\" No hace referencia a una variable que se pueda aplicar el decremento: \"" + s.Tipo + "\"| Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                 Estatico.errores.Add(error);
                 Estatico.ColocaError(error);
             }
         }
         else
         {
             TError error = new TError("Semantico", "El Simbolo: \"" + this.id.ToLower() + "\" al cual se hace referencia no existe en este contexto | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
             Estatico.errores.Add(error);
             Estatico.ColocaError(error);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al intentar ejecutar un decremento | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(new Nulo());
 }
Example #19
0
 public object getValor(Ambito ambito)
 {
     try
     {
         DateTime ahora = DateTime.Now;
         return(ahora);
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al ejecutar la funcion ahora() | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(new Nulo());
 }
Example #20
0
 object Instruccion.Ejecutar(Ambito ambito)
 {
     try
     {
         Object valor = expresion.getValor(ambito);
         Estatico.imprimeConsola(valor.ToString());
     }
     catch (Exception ex)
     {
         TError error = new TError("Ejecucion", "Error al Imprimir en Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | " + ex.Message, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(null);
 }
Example #21
0
 public object Ejecutar(Ambito ambito)
 {
     try
     {
         Object valor = this.valor.getValor(ambito);
         MessageBox.Show(valor.ToString(), "Mensajes");
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al ejecutar Mensajes: | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(new Nulo());
 }
        public object Ejecutar(Ambito ambito)
        {
            try
            {
                object path      = ruta.getValor(ambito);
                object condicion = condicional.getValor(ambito);
                if (path is String && condicion is Boolean)
                {
                    //String currentDir = System.IO.Directory.GetCurrentDirectory() + "\\";

                    String currentDir = Estatico.PROYECT_PATH + "\\";

                    String  cad  = (String)path;
                    Boolean cond = (Boolean)condicion;

                    if (System.IO.File.Exists(cad))
                    {
                        XForms.GUI.Funciones.DisplayImage im = new GUI.Funciones.DisplayImage(cad);
                        im.ShowDialog();
                    }
                    else if (System.IO.File.Exists(currentDir + cad))
                    {
                        XForms.GUI.Funciones.DisplayImage im = new GUI.Funciones.DisplayImage(currentDir + cad);
                        im.ShowDialog();
                    }
                    else
                    {
                        TError error = new TError("Semantico", "La ruta de la Imagen a desplegar no existe, Ruta: \"" + cad + "\" | Tampoco se encontro en el directorio raiz: \"" + currentDir + "\" | Clase: " + clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                        Estatico.ColocaError(error);
                        Estatico.errores.Add(error);
                    }
                    return(new Nulo());
                }
                else
                {
                    TError error = new TError("Semantico", "La funcion Imagen() recibe como parametros unicamente: (Cadena, Booleano) | Clase: " + clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                    Estatico.ColocaError(error);
                    Estatico.errores.Add(error);
                }
            }
            catch (Exception e)
            {
                TError error = new TError("Ejecucion", "Error al ejecutar la funcion Imagen() | Clase: " + clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
                Estatico.ColocaError(error);
                Estatico.errores.Add(error);
            }
            return(new Nulo());
        }
Example #23
0
 public object getValor(Ambito ambito)
 {
     try
     {
         Object val = this.valor.getValor(ambito);
         this.val = val.ToString();
         return(this.val);
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al intentar comventir en cadena: Funcion: Cadena() | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(new Nulo());
 }
        public object Ejecutar(Ambito ambito)
        {
            try
            {
                call.getValor(ambito);

                return(new Nulo());
            }
            catch
            {
                TError error = new TError("", "Error en la ejecucion de la llamada a funcion | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                Estatico.errores.Add(error);
                Estatico.ColocaError(error);
            }
            return(new Nulo());
        }
 public object Ejecutar(Ambito ambito)
 {
     try
     {
         foreach (Instruccion i in this.instrucciones)
         {
             i.Ejecutar(ambito);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Ejecutando Constructor: " + this.clase + " | Archivo: " + ambito.archivo + " | Error: " + e.Message, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(null);
 }
Example #26
0
 private void declaracionApartirDeArbol(Ambito ambito)
 {
     if (!ambito.existeVariable(this.idArr.ToLower()))
     {
         GeneradorArreglo gen = new GeneradorArreglo(this.arbolArreglo);
         if (!gen.huboError)
         {
             int numaux = gen.numDimensiones;
             if (NumDim == gen.numDimensiones)
             {
                 ///FALTA COMPROBAR SI TODOS LOS ELEMENTOS DEL ARREGLO SON DEL MISMO TIPO
                 ///
                 List <Object> valores = linealizadaValores(gen.linealizacion, ambito);
                 if (valores != null)
                 {
                     Arreglo arr = new Arreglo(this.arbolArreglo, valores, gen.dimensiones, this.NumDim, this.idArr.ToLower(), true, this.visibilidad, this.tipo);
                     ambito.agregarVariableAlAmbito(this.idArr.ToLower(), arr);
                 }
                 else
                 {
                     TError error = new TError("Semantico", "El Arreglo: \"" + this.idArr + "\" no concuerda con el tipo esperado: " + this.tipo + " | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
                     Estatico.errores.Add(error);
                     Estatico.ColocaError(error);
                 }
             }
             else
             {
                 TError error = new TError("Semantico", "Las dimensiones declaradas para: \"" + this.idArr + "\" No concuerdan, Se esperaban: " + this.NumDim + " y se encontro: " + gen.numDimensiones + " | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
                 Estatico.errores.Add(error);
                 Estatico.ColocaError(error);
             }
         }
         else
         {
             TError error = new TError("Semantico", "Declaracion erreonea de Arreglo: \"" + this.idArr + "\" en este Ambito | Error: " + gen.mensajesError + " | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
             Estatico.errores.Add(error);
             Estatico.ColocaError(error);
         }
     }
     else
     {
         TError error = new TError("Semantico", "Ya existe una declaracion de: \"" + this.idArr + "\" en este Ambito | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
 }
        public object getValor(Ambito ambito)
        {
            try
            {
                Object cad     = cadena.getValor(ambito);
                String tipoCad = cadena.getTipo(ambito);

                Object pos     = posicion.getValor(ambito);
                String tipoPos = posicion.getTipo(ambito);

                if (cad is String && pos is int)
                {
                    String cadenaAux = (String)cad;
                    int    posi      = (int)pos;
                    if (posi > 0 && posi < cadenaAux.Length)
                    {
                        char aux = cadenaAux[posi];

                        tipo = aux.ToString();

                        return(tipo);
                    }
                    else
                    {
                        TError error = new TError("Semantico", "La funcion PosCad, el parametro entero debe estar dentro de los limites: 0 y " + cadenaAux.Length + " | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                        Estatico.errores.Add(error);
                        Estatico.ColocaError(error);
                    }
                }
                else
                {
                    TError error = new TError("Semantico", "Funcion PosCad requiere parametros: (cadena, entero) y se encontro: (" + tipoCad + "," + tipoPos + ") | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                    Estatico.errores.Add(error);
                    Estatico.ColocaError(error);
                }
            }
            catch (Exception e)
            {
                TError error = new TError("Ejecucion", "Error al ejecutar la funcion Poscade | Clase: " + clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
                Estatico.errores.Add(error);
                Estatico.ColocaError(error);
            }
            return(new Nulo());
        }
Example #28
0
        public object getValor(Ambito ambito)
        {
            try
            {
                Object valor = this.exp.getValor(ambito);
                if (valor is String)
                {
                    String real = (String)valor;

                    try
                    {
                        DateTime aux   = DateTime.ParseExact(real + " 00:00:00", "dd/MM/yyyy hh:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
                        Date     fecha = new Date(aux);
                        this.val = fecha.ToString();
                        return(fecha);
                    }
                    catch
                    {
                        TError error = new TError("Semantico", "No se encontro una cadena que cumpla con el formato: dd/mm/yyyy para la funcion Fecha() / o se ingreso valor invalido | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                        Estatico.errores.Add(error);
                        Estatico.ColocaError(error);
                    }
                }
                else if (valor is Date)
                {
                    this.val = valor.ToString();
                    return(valor);
                }
                else
                {
                    TError error = new TError("Semantico", "La funcion Fecha() recibe como parametros solo una cadena | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                    Estatico.errores.Add(error);
                    Estatico.ColocaError(error);
                }
            }
            catch (Exception e)
            {
                TError error = new TError("Ejecucion", "Error al intentar convertir cadena a Fecha: Funcion: Fecha() | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
                Estatico.errores.Add(error);
                Estatico.ColocaError(error);
            }
            return(new Nulo());
        }
 public object getValor(Ambito ambito)
 {
     try
     {
         Object valor = this.exp.getValor(ambito);
         if (valor is String)
         {
             try
             {
                 String   aux  = (String)valor;
                 DateTime real = DateTime.ParseExact("12/10/1996 " + aux, "dd/MM/yyyy hh:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
                 Hour     hora = new Hour(real);
                 this.val = hora.ToString();
                 return(hora);
             }
             catch
             {
                 TError error = new TError("Semantico", "El formato de la cadena para la funcion Hora() no cumple el formato: hh:mm:ss / o se ingreso valor invalido | Clase: " + clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                 Estatico.ColocaError(error);
                 Estatico.errores.Add(error);
             }
         }
         else if (valor is Hour)
         {
             this.val = valor.ToString();
             return(valor);
         }
         else
         {
             TError error = new TError("Semantico", "La funcion Hora() unicamente puede recibir una cadena como parametro una cadena | Clase: " + clase + " | Archivo: " + ambito.archivo, linea, columna, false);
             Estatico.ColocaError(error);
             Estatico.errores.Add(error);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al intentar convertir cedena a hora, en funcion Hora() | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(new Nulo());
 }
 public object getValor(Ambito ambito)
 {
     try
     {
         Estatico.temporal = ambito;      //AQUI SETEO EL TEMPORAL
         if (this.expresiones.Count == 1) //SI SOLO SE HACE REFERENCIA A UN ID O UNA LLAMADA A UNA FUNCION
         {
             this.valorAux = expresiones.ElementAt(0).getValor(ambito);
             if (valorAux is Este)
             {
                 //return new Nulo();
                 return(new Este());
             }
             return(valorAux);
         }
         else if (this.expresiones.Count > 1)//AQUI ES DONDE YA SE VA A HACER REFERENCIA A OBJETOS
         {
             Ambito ambitoAux = null;
             Object auxiliar  = this.expresiones.ElementAt(0).getValor(ambito);
             if (auxiliar is Este)
             {
                 ambitoAux = (Ambito)buscaAtributoDeClase(ambito);
                 return(recorreExpresiones(ambitoAux, auxiliar));
             }
             else if (auxiliar is Objeto)
             {
                 Objeto ob = (Objeto)auxiliar;
                 ambitoAux = ob.ambito;
                 return(recorreExpresiones(ambitoAux, ob));
             }
             return(new Nulo());
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Ocurrio un Error al acceder a Objeto en Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Error: " + e.Message, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(new Nulo());
 }