Example #1
0
        private void editadoDeTexto()
        {
            String texto = CampoDeTexto.Text;
            List <LOCATION_token> recuperacion = new List <LOCATION_token>();

            recuperacion = clasificadorTexto.abstraccionTexto(texto);
            TOKEN_sorter identificaion = new TOKEN_sorter();

            identificaion.clsificarTokens(recuperacion);
            List <ID_token> recuperacion2 = new List <ID_token>();

            recuperacion2 = identificaion.GetID_Tokens();
            resaltarPalabras.colorearTexto(CampoDeTexto, recuperacion2);
            textoCompiLog(recuperacion2);
        }
Example #2
0
        private void compilarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CurrentFileSource.Length != 0)
            {
                buttonExportar.Enabled = true;
                logText.Lines          = null;
                String texto = CampoDeTexto.Text;

                List <LOCATION_token> recuperacion = new List <LOCATION_token>();
                recuperacion = clasificadorTexto.abstraccionTexto(texto);
                TOKEN_sorter identificaion = new TOKEN_sorter();
                identificaion.clsificarTokens(recuperacion);
                List <ID_token> recuperacion2 = new List <ID_token>();
                recuperacion2 = identificaion.GetID_Tokens();

                Boolean banderaSintactico = true;

                String resultadoCompi = "";
                foreach (ID_token token in recuperacion2)
                {
                    if (token.ID.Equals("unknown_TOKEN"))
                    {
                        resultadoCompi    = resultadoCompi + "-----------------------------------------------------------------------------------------------------------------------------\n";
                        resultadoCompi    = resultadoCompi + "Token type: " + token.ID + " Lexema: " + token.lexema + " Linea ubicacion: " + token.lineaUbicacion + "  Contenido: " + token.contenido + "\n";
                        resultadoCompi    = resultadoCompi + "-----------------------------------------------------------------------------------------------------------------------------\n";
                        banderaSintactico = false;
                    }
                }
                if (banderaSintactico)
                {
                    resultadoCompi = resultadoCompi + "---------------RESULTADO DE ANALISIS SINTACTICO---------------" + "\n";
                    AnalicisSintactico an = new AnalicisSintactico();
                    an.ejecutar(recuperacion2);

                    Arbol arbolSintactico = an.retornarArbol;

                    if (an.errores.Count == 0)
                    {
                        resultadoCompi = resultadoCompi + "---------------NINGUN FALLO DE GRAMATICA---------------" + "\n";
                        resultadoCompi = resultadoCompi + "-----------GENERANDO DOT DE ARBOL SINTACTICO-----------" + "\n";
                        resultadoCompi = resultadoCompi + arbolSintactico.recuperarDOT();

                        manejadorArchivos.EscrituraArchivo("C:\\temp\\grafo.dot", arbolSintactico.recuperarDOT());
                        generarGrafico.generarGrafico();

                        MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                        DialogResult      result;
                        result = MessageBox.Show("Desea visualizar el arbol generado por su analicis?", "Visualizar Arbol", buttons);
                        if (result == System.Windows.Forms.DialogResult.Yes)
                        {
                            VisualizarArbol verArbol = new VisualizarArbol();
                            verArbol.ShowDialog();
                        }
                    }
                    else
                    {
                        foreach (String res in an.errores)
                        {
                            resultadoCompi = resultadoCompi + res + "\n";
                        }
                    }
                }
                else
                {
                    resultadoCompi = resultadoCompi + "---------------EXISTEN ERRORES DE ESCRITURA---------------" + "\n";
                }

                logText.Text = resultadoCompi;
            }
            else
            {
                MessageBox.Show("No esta trabajando bajo ningun archivo", "Error al iniciar analicis");
            }
        }