Example #1
0
        public nodo createVariableType(string variable, TipoNodo tipo, Tipo tipo1, TipoNodo tipoStatic)
        {
            nodo temp = new nodo(variable, tipo, tipo1, tipoStatic);

            match(variable);
            return(temp);
        }
Example #2
0
 public nodo(string nombre, TipoNodo tipoNodo, Tipo tipo, TipoNodo tipoNodoStatic, float valor)
 {
     this.nombre         = nombre;
     this.tipoNodo       = tipoNodo;
     this.tipo           = tipo;
     this.tipoNodoStatic = tipoNodoStatic;
     this.valor          = valor;
 }
Example #3
0
 public nodo(string nombre, TipoNodo tipoNodo, Tipo tipo, TipoNodo tipoNodoStatic)
 {
     this.nombre         = nombre;
     this.tipo           = tipo;
     this.tipoNodo       = tipoNodo;
     this.tipoNodoStatic = tipoNodoStatic;
     this.valor          = 0;
 }
Example #4
0
 public void initializeHashTable(nodo arbol, TipoNodo tipo)
 {
     for (int i = 0; i < arbol.hijos.Count; i++)
     {
         arbol.hijos[i].tipoNodo = tipo;
         pushIntoHashTable(arbol.hijos[i]);
     }
 }
Example #5
0
        public void fnUpdateHashTable(nodo arbol, TipoNodo tipo)
        {
            if (tablaHash.ContainsKey(arbol.nombre))
            {
                arbol.tipoNodo = tablaHash[arbol.nombre].tipo;
                tablaHash[arbol.nombre].lista.Add(arbol.linea);
                if (arbol.tipoNodo == tipo || (arbol.tipoNodo == TipoNodo.float_number && tipo == TipoNodo.integer))
                {
                    Console.WriteLine("Variable: " + arbol.nombre + " Valor: " + arbol.valor);
                    float valor = arbol.valor;
                    if (arbol.tipoNodo == TipoNodo.integer)
                    {
                        valor = (float)Math.Truncate(valor);
                    }
                    tablaHash[arbol.nombre].valor = valor;
                    return;
                }
                else
                {
                    string desde, hasta;
                    if (tipo == TipoNodo.integer)
                    {
                        hasta = "Int";
                    }
                    else if (tipo == TipoNodo.float_number)
                    {
                        hasta = "Float";
                    }
                    else
                    {
                        hasta = "Bool";
                    }

                    if (arbol.tipoNodo == TipoNodo.integer)
                    {
                        desde = "Int";
                    }
                    else if (arbol.tipoNodo == TipoNodo.float_number)
                    {
                        desde = "Float";
                    }
                    else
                    {
                        desde = "Bool";
                    }


                    erroresSemanticos += "Linea: " + arbol.linea + ". No se puede asignar un valor del tipo " + hasta + " a uno del tipo " + desde + "\n";
                    arbol.tipoNodo     = TipoNodo.error;
                    arbol.valor        = 0;
                }
            }
            else
            {
                arbol.tipoNodo     = TipoNodo.undefined;
                erroresSemanticos += "Linea: " + arbol.linea + " .La variable '" + arbol.nombre + "' no ha sido declarada\n";
            }
        }
Example #6
0
 public void setAFN(AFN arg1)
 {
     this.Automata = arg1;
     this.Tipo     = TipoNodo.AFN;
 }
Example #7
0
 public void setTipo(TipoNodo arg1)
 {
     Tipo = arg1;
 }
Example #8
0
 public Nodo(string Descripcion, TipoNodo Tipo)
 {
     this.Descripcion = Descripcion;
     this.TipoN       = Tipo;
 }