Esempio n. 1
0
void PGEN_STATS_print(void) {
  FILE *logFile;
  int numberOfStates = PGEN_getNumberOfStates();

  if (PGEN_getVerboseModeFlag) {
    ATwarning("Logging statistics\n");
  }

  logFile = openLog(PGEN_getStatsFileName());
  
  fprintf(logFile, "int user-productions = %d\n", PGEN_STATS_userProductions);
/*  fprintf(logFile, "int conflicts = %d\n", );
  fprintf(logFile, "int reductions = %d\n", );
  fprintf(logFile, "int shifts = %d\n", );
  fprintf(logFile, "int followRestrictedReductions = %d\n", );
*/

  fprintf(logFile, "int user-rejects = %d\n", PGEN_STATS_userRejects);
  fprintf(logFile, "int user-prefers = %d\n", PGEN_STATS_userPrefers);
  fprintf(logFile, "int user-avoids = %d\n", PGEN_STATS_userAvoids);
  fprintf(logFile, "int user-no-attributes = %d\n", PGEN_STATS_userNoAttributes);


  fprintf(logFile, "int states = %u\n", numberOfStates);
  fprintf(logFile, "int items = %u\n", PGEN_STATS_items);
  fprintf(logFile, "int gotos = %u\n", PGEN_STATS_gotos);
  fprintf(logFile, "int actions = %u\n\n", PGEN_STATS_actions);

  fprintf(logFile, "int max-number-of-items-in-states = %u\n", PGEN_STATS_maxItemsInState);
  fprintf(logFile, "int max-number-of-gotos-in-states = %u\n", PGEN_STATS_maxGotosInState);
  fprintf(logFile, "int max-number-of-actions-in-states = %u\n\n", PGEN_STATS_maxActionsInStates);

  fprintf(logFile, "%%%% items/states = %d\n", (PGEN_STATS_items/numberOfStates));
  fprintf(logFile, "%%%% gotos/state = %d\n", (PGEN_STATS_gotos/numberOfStates));
  fprintf(logFile, "%%%% actions/states = %d\n\n", (PGEN_STATS_actions/numberOfStates));

  fprintf(logFile, "%%%% Normalization-to-Kernel-Sdf = %.6fs\n", PGEN_STATS_normalizationTime);
  fprintf(logFile, "%%%% Parse-table-generation = %.6fs\n", PGEN_STATS_generationTime); 
  fprintf(logFile, "int kernel-productions = %d\n", PGEN_STATS_kernelProductions);
  fprintf(logFile, "int max-user-production-left-hand-side-length = %d\n", PGEN_STATS_maxUserProductionLhsLength);
  fprintf(logFile, "int max-production-left-hand-side-length = %d\n", PGEN_STATS_maxProductionLhsLength);
  fprintf(logFile, "%%%% production-lhs-length/kernel-productions = %d\n", (PGEN_STATS_maxProductionLhsLength/PGEN_STATS_kernelProductions));

  fprintf(logFile, "int priorities = %d\n", PGEN_STATS_priorities);

  closeLog(logFile);

}
Esempio n. 2
0
static PTBL_ParseTable generateParseTable() {
  int i;

  ATermList vertex; 

  PTBL_State state;
  PTBL_States statelist = PTBL_makeStatesEmpty();
  PTBL_Gotos gotos; 
  PTBL_Choices actions;

  
  calc_first_table();
  calc_follow_table();
  createDFA();

  for (i = PGEN_getNumberOfStates()-1; i >= 0; i--) {
    vertex = PGEN_getStateOfStateNumber(i);

    gotos = (PTBL_Gotos)PGEN_getGotosOfState(vertex);
    if (!gotos) {
      gotos = PTBL_makeGotosEmpty();
    } 
    else if (PGEN_getStatsFlag) {
      PGEN_STATS_increaseGotos(PTBL_getGotosLength(gotos));
    }

    actions = PGEN_getActionsOfState(vertex);
    if (!actions) {
      actions = PTBL_makeChoicesEmpty();
    }
    else if (PGEN_getStatsFlag) {
      PGEN_STATS_increaseActions(PTBL_getChoicesLength(actions));
    }

    state = PTBL_makeStateDefault(i, gotos, actions);
    statelist = PTBL_makeStatesMany(state, statelist);
  }

  if (PGEN_getStatsFlag) { PGEN_STATS_print(); }

  return PTBL_makeParseTableParseTable(PTBL_makeVersionDefault(), PGEN_getInitialStateNumber(), PGEN_getLabelSection(), statelist, PGEN_getPrioSection());
}