public void Ejecutar()
        {
            reiniciarEjecucion();
            definirContextoGlobal();

            Contexto local = new Contexto();

            foreach (ParseTreeNode declaracion in variables)
            {
                Declaracion decla = new Declaracion(declaracion);
                decla.ejecutar(local, Constantes.GLOBAL);
            }
            Console.WriteLine("contexto global creado");
            if (Principal == null)
            {
                ListaErrores.getInstance().nuevoErrorGeneral("El metodo principal no ha sido definido", archivo);
                return;
            }
            Cuerpo _principal = new Cuerpo(Principal.ChildNodes[0], false);

            _principal.ejecutar(local, Constantes.GLOBAL + 1);
            Console.WriteLine("Ejecucion Exitosa");
            Console.WriteLine("Salida");
            Interprete.getContextoGlobal().reporte();
            local.reporte();
            Console.WriteLine(Interprete.Salida);
        }
        public static ParseTreeNode getFuncion(ParseTreeNode fun, Contexto ctx)
        {
            String nombreFuncion       = fun.ChildNodes[0].Token.Text;
            List <ParseTreeNode> Lista = Interprete.getListaMetodos(nombreFuncion);

            if (Lista == null)
            {
                //No existe la funcion
                return(null);
            }
            ParseTreeNode funcion           = null;
            int           parametrosFuncion = fun.ChildNodes[1].ChildNodes.Count;

            foreach (ParseTreeNode nodo in Lista)
            {
                int nodosFuncionLista = nodo.ChildNodes.Count;
                if (nodosFuncionLista == 3 && parametrosFuncion == 0)
                {
                    return(nodo);
                }
                else if (nodosFuncionLista == 4)
                {
                    int par1 = nodo.ChildNodes[2].ChildNodes.Count;
                    if (par1 == parametrosFuncion)
                    {
                        int i, j = 0;
                        for (i = 0; i < par1; i++)
                        {
                            Resultado res   = new Expresion(fun.ChildNodes[1].ChildNodes[i].ChildNodes[0]).resolver(ctx);
                            String    tipo1 = res.Tipo;
                            String    tipo2 = nodo.ChildNodes[2].ChildNodes[i].ChildNodes[0].ToString();
                            if (tipo1 == tipo2)
                            {
                                j++;
                            }
                        }
                        if (i == j)
                        {
                            return(nodo);
                        }
                    }
                }
            }
            return(funcion);
        }
        private void definirContextoGlobal()
        {
            if (Arbol != null)
            {
                if (Arbol.ChildNodes.Count == 1)
                {
                    var Nodo = Arbol.ChildNodes[0];
                    switch (Nodo.ToString())
                    {
                    case Constantes.ENCABEZADO:
                        foreach (var nodo_encabezado in Nodo.ChildNodes)
                        {
                            switch (nodo_encabezado.ToString())
                            {
                            case Constantes.INCERTEZA:
                                Interprete.Incerteza = Convert.ToDouble(nodo_encabezado.ChildNodes[0].Token.Text);
                                break;

                            case Constantes.RUTA:
                                String _ruta = nodo_encabezado.ChildNodes[0].Token.Text;
                                if (Directory.Exists(_ruta))
                                {
                                    Interprete.Ruta = _ruta + "\\";
                                }
                                break;

                            case Constantes.INCLUYE:
                                Encabezado e = new Encabezado(nodo_encabezado.ChildNodes[0].Token.Text, archivo);
                                encabezado.Add(e);
                                break;
                            }
                        }
                        break;

                    case Constantes.CUERPO_PROGRAMA:
                        foreach (var nodo in Nodo.ChildNodes)
                        {
                            foreach (var nodo_cuerpo in Nodo.ChildNodes)
                            {
                                switch (nodo_cuerpo.ToString())
                                {
                                case Constantes.DECLARACION:
                                    variables.Add(nodo_cuerpo);
                                    break;

                                case Constantes.FUNCION:
                                    Interprete.addMetodo(nodo_cuerpo);
                                    break;

                                case Constantes.PRINCIPAL:
                                    if (Principal != null)
                                    {
                                        ListaErrores.getInstance().nuevoErrorGeneral("No pueden haber dos funciones principales", archivo);
                                    }
                                    else
                                    {
                                        Principal = nodo_cuerpo;
                                    }
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
                else if (Arbol.ChildNodes.Count == 2)
                {
                    foreach (var Nodo in Arbol.ChildNodes)
                    {
                        switch (Nodo.ToString())
                        {
                        case Constantes.ENCABEZADO:
                            foreach (var nodo_encabezado in Nodo.ChildNodes)
                            {
                                switch (nodo_encabezado.ToString())
                                {
                                case Constantes.INCERTEZA:
                                    Interprete.Incerteza = Convert.ToDouble(nodo_encabezado.ChildNodes[0].Token.Text);
                                    break;

                                case Constantes.RUTA:
                                    String _ruta = nodo_encabezado.ChildNodes[0].Token.Text;
                                    _ruta = _ruta.Substring(1, _ruta.Length - 2);
                                    if (Directory.Exists(_ruta) == true)
                                    {
                                        Interprete.Ruta = _ruta + "\\";
                                    }
                                    break;

                                case Constantes.INCLUYE:
                                    Encabezado e = new Encabezado(nodo_encabezado.ChildNodes[0].Token.Text, archivo);
                                    encabezado.Add(e);
                                    break;
                                }
                            }
                            break;

                        case Constantes.CUERPO_PROGRAMA:
                            foreach (var nodo_cuerpo in Nodo.ChildNodes)
                            {
                                switch (nodo_cuerpo.ToString())
                                {
                                case Constantes.DECLARACION:
                                    variables.Add(nodo_cuerpo);
                                    break;

                                case Constantes.FUNCION:
                                    Interprete.addMetodo(nodo_cuerpo);
                                    break;

                                case Constantes.PRINCIPAL:
                                    if (Principal != null)
                                    {
                                        ListaErrores.getInstance().nuevoErrorGeneral("No pueden haber dos funciones principales", archivo);
                                    }
                                    else
                                    {
                                        Principal = nodo_cuerpo;
                                    }
                                    break;
                                }
                            }
                            break;

                        default:
                            break;
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Arbol Vacio!");
                }
            }
        }