Example #1
0
 public String getDecisionStatsDump() {
   StringBuffer buf = new StringBuffer();
   buf.append("location");
   buf.append(DATA_SEP);
   buf.append("n");
   buf.append(DATA_SEP);
   buf.append("avgk");
   buf.append(DATA_SEP);
   buf.append("maxk");
   buf.append(DATA_SEP);
   buf.append("synpred");
   buf.append(DATA_SEP);
   buf.append("sempred");
   buf.append(DATA_SEP);
   buf.append("canbacktrack");
   buf.append("\n");
   for (String fileName : decisions.keySet()) {
     for (int d : decisions.keySet(fileName)) {
       DecisionDescriptor s = decisions.get(fileName, d);
       buf.append(s.decision);
       buf.append("@");
       buf.append(locationDescription(s.fileName, s.ruleName, s.line, s.pos)); // decision number
       buf.append(DATA_SEP);
       buf.append(s.n);
       buf.append(DATA_SEP);
       buf.append(String.format("%.2f", s.avgk));
       buf.append(DATA_SEP);
       buf.append(s.maxk);
       buf.append(DATA_SEP);
       buf.append(s.numBacktrackOccurrences);
       buf.append(DATA_SEP);
       buf.append(s.numSemPredEvals);
       buf.append(DATA_SEP);
       buf.append(s.couldBacktrack ? "1" : "0");
       buf.append(newline);
     }
   }
   return buf.toString();
 }
Example #2
0
  public void enterDecision(int decisionNumber, boolean couldBacktrack) {
    lastRealTokenTouchedInDecision = null;
    stats.numDecisionEvents++;
    int startingLookaheadIndex = parser.getTokenStream().index();
    TokenStream input = parser.getTokenStream();
    if (dump)
      System.out.println(
          "enterDecision canBacktrack="
              + couldBacktrack
              + " "
              + decisionNumber
              + " backtrack depth "
              + backtrackDepth
              + " @ "
              + input.get(input.index())
              + " rule "
              + locationDescription());
    String g = (String) currentGrammarFileName.peek();
    DecisionDescriptor descriptor = decisions.get(g, decisionNumber);
    if (descriptor == null) {
      descriptor = new DecisionDescriptor();
      decisions.put(g, decisionNumber, descriptor);
      descriptor.decision = decisionNumber;
      descriptor.fileName = (String) currentGrammarFileName.peek();
      descriptor.ruleName = (String) currentRuleName.peek();
      descriptor.line = (Integer) currentLine.peek();
      descriptor.pos = (Integer) currentPos.peek();
      descriptor.couldBacktrack = couldBacktrack;
    }
    descriptor.n++;

    DecisionEvent d = new DecisionEvent();
    decisionStack.push(d);
    d.decision = descriptor;
    d.startTime = System.currentTimeMillis();
    d.startIndex = startingLookaheadIndex;
  }