Analizador sintactico en c#
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace MiCompilador
{
class TAnalizadorSS
{
//Atributos
private TCompilador cmp;//referencia al objeto compilador
private const string VACIO = "vacio";
private const string ERROR_TIPO = "error";
private const stringBOOLEAN = "boolean";
private List<string> ListCol = new List<string>();
private List<string> ListVal = new List<string>();
//Constructores
//General
public TAnalizadorSS(TCompilador cmp)
{
this.cmp = cmp;
}
//Metodos/*--------------------------------------------------------------------------------------------------*/
//invoca reestablecer al buffer de entrada
public void inicializar()
{
cmp.be.reestablecer();
}
/*--------------------------------------------------------------------------------------------------*/
//inicia el analisis sintanctico
public void iniciar()
{TAtributosSS _PROGSQL = new TAtributosSS();
inicializar();
PROGSQL(_PROGSQL);
}
/*---------------------------------------------------------------------------------------------------*/
public void emparejar(string t)
{
if (cmp.be.preAnalisis.Complex == t)
cmp.be.siguiente();
elsecmp.me.error(100, t, cmp.be.preAnalisis.Lexema);
}
/*---------------------------------------------------------------------------------------------------*/
private void tipoBasededatos(StreamReader reader)
{
string linea = "";
while (reader.Peek() > -1)
{
linea = reader.ReadLine().Trim();if (linea != "")
{
TLinea_TS ts = new TLinea_TS();
ts.Complex = "id";
ts.Lexema = linea;
ts.Tipo = "base de datos";
cmp.ts.insertar(ts);
}
else
{
break;
}
}
}/*---------------------------------------------------------------------------------------------------*/
private void tipoProcedure(StreamReader reader)
{
string linea = "";
while (reader.Peek() > -1)
{
linea = reader.ReadLine().Trim();
if (linea != "")
{TLinea_TS ts = new TLinea_TS();
ts.Complex = "id";
ts.Lexema = linea;
ts.Tipo = "procedure";
cmp.ts.insertar(ts);
}
else
{
break;
}
}
}/*---------------------------------------------------------------------------------------------------*/
private void tipoTabla(StreamReader reader)
{
string linea = "";
while (reader.Peek() > -1)
{
linea = reader.ReadLine().Trim();
TLinea_TS ts = new TLinea_TS();
ts.Complex = "id";
ts.Lexema = linea;
ts.Tipo= "tabla";
cmp.ts.insertar(ts);
tipoColumna(linea);
}
}
/*---------------------------------------------------------------------------------------------------*/
private void tipoColumna(string archivo)
{
string linea = "";
FileStream stream;
StreamReader reader;...
Regístrate para leer el documento completo.