public List <C3D> compilar(String texto, RichTextBox consola, int lenguaje, String clase)
        {
            // *************** FASE 1 Analisis Lexico y Sintactico **************//
            if (lenguaje == (int)Pagina.Lenguaje.OLC)
            {
                // OLC++
                InterpreteOLC interprete = new InterpreteOLC();
                clases = interprete.analizarOLC(texto);
                clase  = clase.Replace(".olc", "");
            }
            else
            {
                // Tree
                InterpreteTree interprete = new InterpreteTree();
                clases = interprete.analizarTree(texto);
                clase  = clase.Replace(".tree", "");
            }
            // **************** FASE 2 Llenar Tabla de Simbolos *****************//
            llenarTablaSimbolos();

            // **************** FASE 3 Analisis Semantico y Codigo Intermedio ***//
            if (clases.Count > 0)
            {
                Clase main = buscarMain(clases[0]);
                if (main == null)
                {
                    // Error! No hay procedimiento main en la clase de inicio!
                    return(null);
                }
                GeneradorC3D.clases = clases;
                return(GeneradorC3D.generarC3D(main));
            }
            return(null);
        }
Example #2
0
        private void btnConvertirCodigo_Click(object sender, EventArgs e)
        {
            // Convertir codigo a imagen

            if (tipoArchivo.SelectedIndex == 0)
            {
                // OLC
                InterpreteOLC interprete = new InterpreteOLC();
                clases = interprete.analizarOLC(txtCodigo.Text);
            }
            else if (tipoArchivo.SelectedIndex == 1)
            {
                // Tree
                InterpreteTree interprete = new InterpreteTree();
                clases = interprete.analizarTree(txtCodigo.Text);
            }
            else
            {
                MessageBox.Show("Seleccione un lenguaje!");
                return;
            }
            relaciones = new List <Relacion>();
            // Recorrer clases para buscar relaciones necesarias
            generarRelacionesUML();
            repintar();
            ejecutarGraphviz();
            Thread.Sleep(1000);
            File.Delete(@"C:\Graphviz\Imagenes\imagen" + contadorImgs + ".txt");
            this.imgDiagrama.Image = new System.Drawing.Bitmap(@"C:\Graphviz\Imagenes\nueva" + contadorImgs + ".png");
            contadorImgs++;
        }
 public void guardarImportacionTree(string cadena)
 {
     // ver si es del tipo tree
     if (cadena.Contains(".tree"))
     {
         string texto = null;
         // Es del tipo tree
         if (cadena.Contains("http"))
         {
             // Es web
         }
         else
         {
             if (!cadena.Contains("\\"))
             {
                 cadena = Compilador.rutaEjecutada + cadena;
             }
             // Esta en un path
             try
             {
                 texto = File.ReadAllText(cadena);
             }
             catch (IOException ex)
             {
                 MessageBox.Show("No se puede leer el archivo: " + cadena);
             }
         }
         if (texto != null)
         {
             // Analizar texto
             InterpreteTree interprete = new InterpreteTree();
             List <Clase>   otras      = interprete.analizarTree(texto);
             foreach (Clase clase in otras)
             {
                 if (!existeClase(clase))
                 {
                     clases.Add(clase);
                 }
             }
         }
     }
     else
     {
         // Error Semantico!
     }
 }
Example #4
0
 public List <Clase> guardarImportaciones(ParseTreeNode nodo)
 {
     // IMPORTACIONES -> LISTA_ARCHIVOS
     // LISTA_ARCHIVOS -> archivo | url | ruta
     foreach (ParseTreeNode archivo in nodo.ChildNodes.ElementAt(0).ChildNodes.ElementAt(0).ChildNodes)
     {
         String texto = "";
         if (archivo.Term.Name.Equals("archivo"))
         {
             // El archivo se encuentra en la carpeta actual
         }
         else if (archivo.Term.Name.Equals("ruta"))
         {
             // El archivo se encuentra en otra carpeta
         }
         else
         {
             // El archivo se encuentra en el repositorio
         }
         InterpreteTree ntree = new InterpreteTree();
         return(ntree.analizarTree(texto));
     }
     return(null);
 }