Пример #1
0
 public void setEntornoFunc(string prop, SimboloFunction actualFunc, string ret)
 {
     this.size       = 1; //1 porque la posicion 0 es para el return
     this.prop       = prop;
     this.yreturn    = ret;
     this.actualFunc = actualFunc;
 }
Пример #2
0
        public LinkedList <IteFor> fors; //PARA ALMACENAR LAS ACTUALIZACIONES DE VARIABLES DE LOS CICLOS FOR QUE NOS SERVIRA EN LOS CONTINUES

        public Entorno(Entorno anterior, string ambito, string nombre)
        {
            functions     = new Hashtable();
            structs       = new Hashtable();
            vars          = new Hashtable();
            this.anterior = anterior;
            size          = anterior != null ? anterior.size : 0;
            ybreak        = new LinkedList <string>();
            ycontinue     = new LinkedList <string>();
            yreturn       = anterior != null ? anterior.yreturn : null;
            this.prop     = "main";
            actualFunc    = anterior != null ? anterior.actualFunc : null;
            this.ambito   = ambito;
            this.nombre   = nombre;
            fors          = new LinkedList <IteFor>();
        }
Пример #3
0
        private string escribirTablaSimbolos(Entorno ent)
        {
            string html = "<!Doctype html>\n<html lang=\"es-Es\">\n<head>\n";

            html += "<link rel=\"stylesheet\" href=\"estiloTabla.css\">\n";
            html += "<title>Tabla de Simbolos</title>\n</head>\n<body>\n<h1><center>Tabla de Simbolos en Compilación</center></h1>\n<table style=\"margin: 0 auto;\">\n";
            html += "<caption>Variables globales declaradas</caption>\n";
            html += "<thead>\n<tr>\n<th>Nombre</th>\n<th>Tipo</th>\n<th>Posicion</th>\n<th>Es Constante</th>\n<th>Linea</th>\n<th>Columna</th>\n</tr>\n</thead>\n<tbody>\n";
            //RECORRERMOS LAS VARIABLES DEL ENTORNO GLOBAL
            foreach (DictionaryEntry variable in ent.vars)
            {
                Simbolo simbolo = (Simbolo)variable.Value;
                html += "<tr>\n";
                html += "<td>" + simbolo.identificador + "</td>\n";
                if (simbolo.type.tipo == Tipos.STRUCT)
                {
                    html += "<td>" + simbolo.type.tipoToString() + ":" + simbolo.type.tipoId + "</td>\n";
                }
                else
                {
                    html += "<td>" + simbolo.type.tipoToString() + "</td>\n";
                }
                html += "<td>" + simbolo.position + "</td>\n";
                if (simbolo.isConst)
                {
                    html += "<td>Si</td>\n";
                }
                else
                {
                    html += "<td>No</td>\n";
                }
                html += "<td>" + (simbolo.linea + 1) + "</td>\n";
                html += "<td>" + (simbolo.columna + 1) + "</td>\n";
                html += "</tr>\n";
            }
            html += "</tbody>\n</table>\n";
            html += "</br></br>\n";

            html += "<table style=\"margin: 0 auto;\">\n<caption>Procedimientos/Funciones declaradas</caption>\n";
            html += "<thead>\n<tr>\n<th>Nombre</th>\n<th>Tipo de Retorno</th>\n<th>PRO o FUN Padre</th>\n<th># Parametros</th>\n<th>Linea</th>\n<th>Columna</th>\n</tr>\n</thead>\n<tbody>\n";
            //RECORREMOS LAS FUNCIONES
            foreach (DictionaryEntry funcion in ent.functions)
            {
                SimboloFunction simbolo = (SimboloFunction)funcion.Value;
                html += "<tr>\n";
                html += "<td>" + simbolo.id + "</td>\n";
                if (simbolo.type.tipo == Tipos.STRUCT)
                {
                    html += "<td>" + simbolo.type.tipoToString() + ":" + simbolo.type.tipoId + "</td>\n";
                }
                else
                {
                    html += "<td>" + simbolo.type.tipoToString() + "</td>\n";
                }
                html += "<td>--</td>\n";
                html += "<td>" + simbolo.size + "</td>\n";
                html += "<td>" + (simbolo.linea + 1) + "</td>\n";
                html += "<td>" + (simbolo.columna + 1) + "</td>\n";
                html += "</tr>\n";
            }
            html += "</tbody>\n</table>\n</body>\n</html>";
            return(html);
        }