示例#1
0
 /**
  * Track memoization; this is not part of standard debug interface but is triggered by profiling.
  * Code gen inserts an override for this method in the recognizer, which triggers this method.
  * Called from alreadyParsedRule().
  */
 public void examineRuleMemoization(
     IntStream input,
     int ruleIndex,
     int stopIndex, // index or MEMO_RULE_UNKNOWN...
     String ruleName) {
   if (dump)
     System.out.println("examine memo " + ruleName + " at " + input.index() + ": " + stopIndex);
   if (stopIndex == BaseRecognizer.MEMO_RULE_UNKNOWN) {
     // System.out.println("rule "+ruleIndex+" missed @ "+input.index());
     stats.numMemoizationCacheMisses++;
     stats.numGuessingRuleInvocations++; // we'll have to enter
     currentDecision().numMemoizationCacheMisses++;
   } else {
     // regardless of rule success/failure, if in cache, we have a cache hit
     // System.out.println("rule "+ruleIndex+" hit @ "+input.index());
     stats.numMemoizationCacheHits++;
     currentDecision().numMemoizationCacheHits++;
   }
 }
示例#2
0
 public Object getInputSymbol(int k) {
   if (input instanceof TokenStream) {
     return ((TokenStream) input).LT(k);
   }
   return new Character((char) input.LA(k));
 }