Ejemplo n.º 1
0
  public Program compile(String programCode) {
    long ms = System.currentTimeMillis();
    owner.debug("Program Code:", 2);
    owner.debug(programCode, 2);
    Vector programList = stringToList(programCode);
    owner.debug("Program List:", 2);
    owner.debug("String to List: " + (System.currentTimeMillis() - ms) + " ms.", -1);
    owner.debug(programList.toString(), 2);
    CompilerStructure struc = new CompilerStructure();

    ms = System.currentTimeMillis();
    if ((program(programList, struc)) && (programList.size() == 0)) {
      owner.debug("List to Structure: " + (System.currentTimeMillis() - ms) + " ms.", -1);
      updateNames(struc);
      owner.debug(struc.toString(), 2);
      ms = System.currentTimeMillis();
      Program p = structureToCode(struc);
      owner.debug("Structure to Code: " + (System.currentTimeMillis() - ms) + " ms.", -1);
      return p;
    } else {
      if (errorString.length() > 0) owner.writeLn(errorString);
      return null;
    }
  } // end of PrologCompiler.compile(String)