Пример #1
0
        public void graficarSimbolos()
        {
            Entorno actual = this;

            string path = "C:\\compiladores2\\" + this.noReporte + "_" + this.nombre + "_graficar_Ts().html";

            string reporte = "<html><title>Errores Lexicos</title><body><center><h1>Reporte De Errores</h1></center><br><br><center>";

            reporte += "<table style=\"width: 100%\">";
            reporte += "<tr>";
            reporte += "<th style=\"border: 1px solid black; background-color:#DFC93F \">Nombre</th>";
            reporte += "<th style=\"border: 1px solid black; background-color:#DFC93F \">Tipo</th>";
            reporte += "<th style=\"border: 1px solid black; background-color:#DFC93F \">Ambito</th>";
            reporte += "<th style=\"border: 1px solid black; background-color:#DFC93F \">Fila</th>";
            reporte += "<th style=\"border: 1px solid black; background-color:#DFC93F \">Columna</th>";
            reporte += "</tr>";

            while (actual != null)
            {
                foreach (KeyValuePair <string, Simbolo> value in variables)
                {
                    reporte += "<tr>";
                    reporte += "<th style=\"border: 1px solid black; \">" + value.Key + "</th>";
                    reporte += "<th style=\"border: 1px solid black; \">" + value.Value.tipo.tipo.ToString() + "</th>";
                    reporte += "<th style=\"border: 1px solid black; \">" + actual.nombre + "</th>";
                    reporte += "<th style=\"border: 1px solid black; \">" + actual.linea[value.Key] + "</th>";
                    reporte += "<th style=\"border: 1px solid black; \">" + actual.columna[value.Key] + "</th>";
                    reporte += "</tr>";
                }

                foreach (KeyValuePair <string, Simbolo> value in constantes)
                {
                    reporte += "<tr>";
                    reporte += "<th style=\"border: 1px solid black; \">" + value.Key + "</th>";
                    reporte += "<th style=\"border: 1px solid black; \">" + value.Value.tipo.tipo.ToString() + "</th>";
                    reporte += "<th style=\"border: 1px solid black; \">" + actual.nombre + "</th>";
                    reporte += "<th style=\"border: 1px solid black; \">" + actual.linea[value.Key] + "</th>";
                    reporte += "<th style=\"border: 1px solid black; \">" + actual.columna[value.Key] + "</th>";
                    reporte += "</tr>";
                }

                foreach (KeyValuePair <string, Simbolo> value in types)
                {
                    reporte += "<tr>";
                    reporte += "<th style=\"border: 1px solid black; \">" + value.Key + "</th>";
                    reporte += "<th style=\"border: 1px solid black; \">" + value.Value.tipo.tipo.ToString() + "</th>";
                    reporte += "<th style=\"border: 1px solid black; \">" + actual.nombre + "</th>";
                    reporte += "<th style=\"border: 1px solid black; \">" + actual.linea[value.Key] + "</th>";
                    reporte += "<th style=\"border: 1px solid black; \">" + actual.columna[value.Key] + "</th>";
                    reporte += "</tr>";
                }

                foreach (KeyValuePair <string, Funcion> value in funciones)
                {
                    reporte += "<tr>";
                    reporte += "<th style=\"border: 1px solid black; \">" + value.Key + "</th>";
                    reporte += "<th style=\"border: 1px solid black; \"> Funcion </th>";
                    reporte += "<th style=\"border: 1px solid black; \">" + actual.nombre + "</th>";
                    reporte += "<th style=\"border: 1px solid black; \">" + actual.linea[value.Key] + "</th>";
                    reporte += "<th style=\"border: 1px solid black; \">" + actual.columna[value.Key] + "</th>";
                    reporte += "</tr>";
                }

                foreach (KeyValuePair <string, Procedimiento> value in procedimiento)
                {
                    reporte += "<tr>";
                    reporte += "<th style=\"border: 1px solid black; \">" + value.Key + "</th>";
                    reporte += "<th style=\"border: 1px solid black; \"> Procedimiento </th>";
                    reporte += "<th style=\"border: 1px solid black; \">" + actual.nombre + "</th>";
                    reporte += "<th style=\"border: 1px solid black; \">" + actual.linea[value.Key] + "</th>";
                    reporte += "<th style=\"border: 1px solid black; \">" + actual.columna[value.Key] + "</th>";
                    reporte += "</tr>";
                }

                actual = actual.padre;
            }

            reporte += "</table></center></body></html>";

            try
            {
                using (FileStream fs = File.Create(path))
                {
                    byte[] info = new UTF8Encoding(true).GetBytes(reporte);
                    fs.Write(info, 0, info.Length);
                }
            }
            catch (Exception ex)
            {
            }
        }