public bool Estructura()
        {
            bool Bandera = false;

            for (int i = 0; i < reconocidos.Count; i++)
            {
                if (reconocidos[0].Equals("declare"))
                {
                    Bandera = true;
                }
                else
                {
                    Bandera = false;
                    txtb_Error.AppendText("no hay espacio de declare");
                    break;
                }


                if (!reconocidos.Contains("main"))
                {
                    Bandera = false;
                    txtb_Error.AppendText("no declaro main principal");
                    break;
                }
                if (td.RecoTipo(reconocidos[i].ToString()).Equals("tipo"))
                {
                    String cost = reconocidos[i + 1].ToString().Substring(0, 1);
                    if (!cost.Equals("#") && !reconocidos[i + 2].ToString().Equals(","))
                    {
                        Bandera = false;
                        txtb_Error.AppendText("variable tipo (" + reconocidos[i].ToString() + ")sin identificador");
                        // reconocidos.Clear();
                        break;
                    }
                }
                if (reconocidos[i].Equals("main"))
                {
                    int posicion = i + 1;
                    for (int j = posicion; posicion < reconocidos.Count; posicion++)
                    {
                        if (td.RecoTipo(reconocidos[posicion].ToString()).Equals("tipo"))
                        {
                            Bandera = false;
                            txtb_Error.AppendText("no se permite declaracion de variables despues de main");
                            reconocidos.Clear();
                            break;
                        }
                        else
                        {
                            Bandera = true;
                        }
                    }
                }
            }
            return(Bandera);
        }
Ejemplo n.º 2
0
        public void MostrarTDS()
        {
            TipoDato tipod = new TipoDato();
            int      n     = 0;

            for (int i = 0; i < Listorec.Count; i++)
            {
                String lexe        = Listorec[i].Lexema;
                string numerotoken = tipod.RecoTipo(Convert.ToInt16(Listorec[i].NumToken));

                if (tipod.RecoTipo(Convert.ToInt16(Listorec[i].NumToken)).Equals("tipo"))//analiza si es un tipo int,double,string,char.etc. con el metodo RecoTipo
                {
                    for (int j = i; j < Listorec.Count; i++)
                    {
                        char c = Listorec[j + 1].Lexema[0];


                        char lexema = Listorec[j + 2].Lexema[0];


                        if (!Listorec[j].Lexema.Equals(";"))
                        {
                            char signo = Listorec[j + 1].Lexema[0];

                            if (Listorec[j + 1].Lexema[0].Equals('#') && !Listorec[j + 2].Lexema.Equals(":="))
                            {
                                string lex          = Listorec[j + 1].Lexema;
                                string le           = lex.Remove(0, 1);
                                string tipo         = lexe;
                                int    analizartipo = tipod.TipoVariable(lexe);
                                n++;


                                TDS tds1 = new TDS(
                                    n,
                                    tipod.TipoVariable(lexe),
                                    Listorec[j + 3].Lexema.Length,
                                    le,
                                    ""
                                    );
                                tabla.Add(tds1);
                            }
                            //if (Listorec[j + 1].Lexema[0].Equals('#') && Listorec[j+2].Lexema.Equals(":="))
                            //{
                            //    string lex = Listorec[j + 1].Lexema;
                            //    string le = lex.Remove(0, 1);
                            //    string tipo = lexe;
                            //    int analizartipo = tipod.TipoVariable(lexe);



                            //    TDS tds1 = new TDS(
                            //    Convert.ToInt16(Listorec[j].NumToken),
                            //    tipod.TipoVariable(lexe),
                            //    Listorec[j + 3].Lexema.Length,
                            //    le,
                            //    Listorec[j + 3].Lexema
                            //    );
                            //    tabla.Add(tds1);

                            //}

                            j = j + 2;
                        }



                        else
                        {
                            break;
                        }
                    }
                }
                if (Listorec[i].Lexema.Equals("main"))
                {
                    break;
                }
            }

            // tbl_TDS.ItemsSource = tabla;
        }