/** Track backtracking decisions. You'll see a fixed or cyclic decision * and then a backtrack. * * enter rule * ... * enter decision * LA and possibly consumes (for cyclic DFAs) * begin backtrack level * mark m * rewind m * end backtrack level, success * exit decision * ... * exit rule */ public void beginBacktrack(int level) { if (dump) System.out.println("enter backtrack "+level); backtrackDepth++; DecisionEvent e = currentDecision(); if ( e.decision.couldBacktrack ) { stats.numBacktrackOccurrences++; e.decision.numBacktrackOccurrences++; e.backtracks = true; } }
/** Track backtracking decisions. You'll see a fixed or cyclic decision * and then a backtrack. * * enter rule * ... * enter decision * LA and possibly consumes (for cyclic DFAs) * begin backtrack level * mark m * rewind m * end backtrack level, success * exit decision * ... * exit rule */ @Override public void beginBacktrack(int level) { if (dump) System.out.println("enter backtrack "+level); backtrackDepth++; DecisionEvent e = currentDecision(); if ( e.decision.couldBacktrack ) { stats.numBacktrackOccurrences++; e.decision.numBacktrackOccurrences++; e.backtracks = true; } }
@Override public void semanticPredicate(boolean result, String predicate) { stats.numSemanticPredicates++; if ( inDecision() ) { DecisionEvent d = currentDecision(); d.evalSemPred = true; d.decision.numSemPredEvals++; if (dump) System.out.println("eval "+predicate+" in "+d.decision.ruleName+"-"+ d.decision.decision); } }
@Override public void semanticPredicate(boolean result, String predicate) { stats.numSemanticPredicates++; if ( inDecision() ) { DecisionEvent d = currentDecision(); d.evalSemPred = true; d.decision.numSemPredEvals++; if (dump) System.out.println("eval "+predicate+" in "+d.decision.ruleName+"-"+ d.decision.decision); } }
public void semanticPredicate(boolean result, String predicate) { stats.numSemanticPredicates++; if ( inDecision() ) { DecisionEvent d = currentDecision(); d.evalSemPred = true; d.decision.numSemPredEvals++; if (dump) System.out.println("eval "+predicate+" in "+d.decision.ruleName+"-"+ d.decision.decision); } }
@Override public void semanticPredicate(boolean result, String predicate) { stats.numSemanticPredicates++; if ( inDecision() ) { DecisionEvent d = currentDecision(); d.evalSemPred = true; d.decision.numSemPredEvals++; if (dump) System.out.println("eval "+predicate+" in "+d.decision.ruleName+"-"+ d.decision.decision); } }
@Override public void semanticPredicate(boolean result, String predicate) { stats.numSemanticPredicates++; if ( inDecision() ) { DecisionEvent d = currentDecision(); d.evalSemPred = true; d.decision.numSemPredEvals++; if (dump) System.out.println("eval "+predicate+" in "+d.decision.ruleName+"-"+ d.decision.decision); } }
@Override public void semanticPredicate(boolean result, String predicate) { stats.numSemanticPredicates++; if ( inDecision() ) { DecisionEvent d = currentDecision(); d.evalSemPred = true; d.decision.numSemPredEvals++; if (dump) System.out.println("eval "+predicate+" in "+d.decision.ruleName+"-"+ d.decision.decision); } }
/** 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++; } }
/** 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++; } }
/** 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++; } }
/** 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++; } }
/** 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++; } }
/** 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++; } }
@Override public void consumeToken(Token token) { if (dump) System.out.println("consume token "+token); if ( !inDecision() ) { stats.numTokens++; return; } if ( lastRealTokenTouchedInDecision==null || lastRealTokenTouchedInDecision.getTokenIndex() < token.getTokenIndex() ) { lastRealTokenTouchedInDecision = token; } DecisionEvent d = currentDecision(); // compute lookahead depth int thisRefIndex = token.getTokenIndex(); int numHidden = getNumberOfHiddenTokens(d.startIndex, thisRefIndex); int depth = thisRefIndex - d.startIndex - numHidden + 1; // +1 counts consuming start token as 1 //d.maxk = Math.max(d.maxk, depth); if (dump) System.out.println("consume "+thisRefIndex+" "+depth+" tokens ahead in "+ d.decision.ruleName+"-"+d.decision.decision+" start index "+d.startIndex); }
public void consumeToken(Token token) { if (dump) System.out.println("consume token "+token); if ( !inDecision() ) { stats.numTokens++; return; } if ( lastRealTokenTouchedInDecision==null || lastRealTokenTouchedInDecision.getTokenIndex() < token.getTokenIndex() ) { lastRealTokenTouchedInDecision = token; } DecisionEvent d = currentDecision(); // compute lookahead depth int thisRefIndex = token.getTokenIndex(); int numHidden = getNumberOfHiddenTokens(d.startIndex, thisRefIndex); int depth = thisRefIndex - d.startIndex - numHidden + 1; // +1 counts consuming start token as 1 //d.maxk = Math.max(d.maxk, depth); if (dump) System.out.println("consume "+thisRefIndex+" "+depth+" tokens ahead in "+ d.decision.ruleName+"-"+d.decision.decision+" start index "+d.startIndex); }
@Override public void consumeToken(Token token) { if (dump) System.out.println("consume token "+token); if ( !inDecision() ) { stats.numTokens++; return; } if ( lastRealTokenTouchedInDecision==null || lastRealTokenTouchedInDecision.getTokenIndex() < token.getTokenIndex() ) { lastRealTokenTouchedInDecision = token; } DecisionEvent d = currentDecision(); // compute lookahead depth int thisRefIndex = token.getTokenIndex(); int numHidden = getNumberOfHiddenTokens(d.startIndex, thisRefIndex); int depth = thisRefIndex - d.startIndex - numHidden + 1; // +1 counts consuming start token as 1 //d.maxk = Math.max(d.maxk, depth); if (dump) System.out.println("consume "+thisRefIndex+" "+depth+" tokens ahead in "+ d.decision.ruleName+"-"+d.decision.decision+" start index "+d.startIndex); }
@Override public void consumeToken(Token token) { if (dump) System.out.println("consume token "+token); if ( !inDecision() ) { stats.numTokens++; return; } if ( lastRealTokenTouchedInDecision==null || lastRealTokenTouchedInDecision.getTokenIndex() < token.getTokenIndex() ) { lastRealTokenTouchedInDecision = token; } DecisionEvent d = currentDecision(); // compute lookahead depth int thisRefIndex = token.getTokenIndex(); int numHidden = getNumberOfHiddenTokens(d.startIndex, thisRefIndex); int depth = thisRefIndex - d.startIndex - numHidden + 1; // +1 counts consuming start token as 1 //d.maxk = Math.max(d.maxk, depth); if (dump) System.out.println("consume "+thisRefIndex+" "+depth+" tokens ahead in "+ d.decision.ruleName+"-"+d.decision.decision+" start index "+d.startIndex); }
@Override public void consumeToken(Token token) { if (dump) System.out.println("consume token "+token); if ( !inDecision() ) { stats.numTokens++; return; } if ( lastRealTokenTouchedInDecision==null || lastRealTokenTouchedInDecision.getTokenIndex() < token.getTokenIndex() ) { lastRealTokenTouchedInDecision = token; } DecisionEvent d = currentDecision(); // compute lookahead depth int thisRefIndex = token.getTokenIndex(); int numHidden = getNumberOfHiddenTokens(d.startIndex, thisRefIndex); int depth = thisRefIndex - d.startIndex - numHidden + 1; // +1 counts consuming start token as 1 //d.maxk = Math.max(d.maxk, depth); if (dump) System.out.println("consume "+thisRefIndex+" "+depth+" tokens ahead in "+ d.decision.ruleName+"-"+d.decision.decision+" start index "+d.startIndex); }
@Override public void consumeToken(Token token) { if (dump) System.out.println("consume token "+token); if ( !inDecision() ) { stats.numTokens++; return; } if ( lastRealTokenTouchedInDecision==null || lastRealTokenTouchedInDecision.getTokenIndex() < token.getTokenIndex() ) { lastRealTokenTouchedInDecision = token; } DecisionEvent d = currentDecision(); // compute lookahead depth int thisRefIndex = token.getTokenIndex(); int numHidden = getNumberOfHiddenTokens(d.startIndex, thisRefIndex); int depth = thisRefIndex - d.startIndex - numHidden + 1; // +1 counts consuming start token as 1 //d.maxk = Math.max(d.maxk, depth); if (dump) System.out.println("consume "+thisRefIndex+" "+depth+" tokens ahead in "+ d.decision.ruleName+"-"+d.decision.decision+" start index "+d.startIndex); }