Esempio n. 1
0
        private TablaPrimeros ArmarTablaPrimeros()
        {
            TablaPrimeros tabla = new TablaPrimeros();

            List <Terminal> termsPrim = new List <Terminal>();

            foreach (NoTerminal nt in noTerminales)
            {
                //if (nt.Nombre == "CONSTANTES")
                //{
                //    Debugger.Break();
                //}

                foreach (Produccion prod in this.ObtenerListaProduccionesParaUnNoTerminal(nt))
                {
                    termsPrim = new List <Terminal>();


                    termsPrim.AddRange(this.Primeros(nt, prod));
                    tabla.AgregarNodo(nt, prod, termsPrim);
                }
            }
            return(tabla);
        }
Esempio n. 2
0
        public Gramatica(string pathArch)
        {
            try
            {
                this.noTerminales = new List <NoTerminal>();
                this.terminales   = new List <Terminal>();
                this.producciones = new List <Produccion>();

                try
                {
                    Debug.Assert(pathArch != null, "El archivo era null");
                    this.CargarDeArchivo(pathArch);
                }
                catch (Exception ex)
                {
                    Utils.Log.AddError(ex.Message);
                    throw new Exception("Error al cargar la gramatica desde el archivo: " + pathArch);
                }

                try
                {
                    this.tablaPrimeros = this.ArmarTablaPrimeros();
                    this.tablaPrimeros.CompletarTabla();
                }
                catch (Exception ex)
                {
                    Utils.Log.AddError(ex.Message);
                    throw new Exception("Error en la tablaPrimeros");
                }
            }
            catch (Exception ex)
            {
                Utils.Log.AddError(ex.Message);
                throw new Exception("Error al crear la Gramatica");
            }
        }