Menu

sábado, 30 de marzo de 2013

Análisis sintáctico predictivo no recursivo


Presentado a:
  • Julio Cesar Sierra
Por:
  • Steven Rodriguez
  • Andres Vega
  • Jorge Barrera
Archivos:

Implementación Algoritmo 4.3 Análisis sintáctico predictivo no recursivo (pag. 192, Aho)

 Vector buffer;
 int i = 1;
 String ae = "", X, a;

 Stack<String> pila = new Stack<String>();
 pila.push("$");
 pila.push("E");

 buffer = acciones.LlenarVector();
 ae = buffer.get(0).toString();

 while (pila.lastElement().toString() != ae) {
  X = pila.lastElement();
  a = ae;
  if (X.equals("$") || acciones.Validar(X) > 0) {
   if (X.equals(a)) {
    pila.remove(pila.lastElement());
    ae = buffer.get(i).toString();
    i++;
   } else {
    throw new Exception("Se encontro un error sintactico");
   }
  } else {
   if (acciones.Existe("M[" + X + "," + a + "]")) {
    pila.remove(pila.lastElement());
    acciones.MeterEnPila(pila, X, a);
    acciones.EmitirProduccion(X, a);
   } else {
    throw new Exception("Se encontro un error sintactico");
   }
  }
 }

No hay comentarios.: