Example #1
0
  private void CorrerActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_CorrerActionPerformed
    // TODO add your handling code here:
    int Indice;

    Indice = this.jTP.getSelectedIndex();
    if (Indice >= 0) {
      InputStream inS = new ByteArrayInputStream(this.TAREAS.get(Indice).getText().getBytes());
      ;

      ScannerProyecto scp = new ScannerProyecto(inS);
      ParserP pap = new ParserP();
      pap.setScanner(scp);
      try {
        pap.CanonicalPath = this.archivos.get(Indice).getParent();
        pap.parse();
        // DeclaraciĆ³n de variables Globales
        pap.TSC.InsertarVG("Vida", "int", null);
        pap.TSC.InsertarVG("Energia", "int", null);
        pap.TSC.InsertarVG("Angulo", "int", null);
        pap.TSC.InsertarVG("X", "int", null);
        pap.TSC.InsertarVG("Y", "int", null);

        LinkedList<Simbolo> sparameteros = new LinkedList();
        Simbolo s = new Simbolo("a", "int", true);
        sparameteros.add(s);
        pap.TSC.InsertarMG("Mover", "void", sparameteros);
        sparameteros = new LinkedList();
        s = new Simbolo("a", "int", true);
        sparameteros.add(s);
        pap.TSC.InsertarMG("Disparar", "void", sparameteros);
        sparameteros = new LinkedList();
        s = new Simbolo("a", "int", true);
        sparameteros.add(s);
        pap.TSC.InsertarMG("MoverAtras", "void", sparameteros);
        sparameteros = new LinkedList();
        s = new Simbolo("a", "int", true);
        sparameteros.add(s);
        pap.TSC.InsertarMG("Girar", "void", sparameteros);
        sparameteros = new LinkedList();
        s = new Simbolo("a", "int", true);
        sparameteros.add(s);
        pap.TSC.InsertarMG("Imprimir", "void", sparameteros);

        boolean ret = pap.ins.CargarTS();

        if (ret) {
          TextArea a = new TextArea();

          Entrada = pap.ins.Generar3Direcciones();
          Entrada = TablaDeSimbolos.GenerarCadenaTemporales(1000, 1000) + Entrada;

          a.setText(Entrada);

          FileWriter fw =
              new FileWriter(
                  this.archivos.get(Indice).getParent() + "/" + Proyecto.getName() + "TAC.c");
          fw.write(Entrada);
          fw.close();

          // this.jTP.add(a);
          // pap.ins.CrearA();
        } else {
          System.out.println(":@ :@");
          // Error
        }

      } catch (Exception ex) {

      }
    }
    // String tabselected=this.jTP.getTitleAt(this.jTP.getSelectedIndex());

  } // GEN-LAST:event_CorrerActionPerformed