public class Profiler extends BlankDebugEventListener
| Modifier and Type | Class and Description |
|---|---|
static class |
Profiler.DecisionDescriptor |
static class |
Profiler.DecisionEvent |
static class |
Profiler.ProfileStats |
| Modifier and Type | Field and Description |
|---|---|
protected int |
backtrackDepth |
protected java.util.Stack<java.lang.String> |
currentGrammarFileName |
protected java.util.Stack<java.lang.Integer> |
currentLine |
protected java.util.Stack<java.lang.Integer> |
currentPos |
protected java.util.Stack<java.lang.String> |
currentRuleName |
static java.lang.String |
DATA_SEP |
protected java.util.List<Profiler.DecisionEvent> |
decisionEvents |
protected DoubleKeyMap<java.lang.String,java.lang.Integer,Profiler.DecisionDescriptor> |
decisions |
protected java.util.Stack<Profiler.DecisionEvent> |
decisionStack |
protected Token |
lastRealTokenTouchedInDecision |
static java.lang.String |
newline |
DebugParser |
parser
Ack, should not store parser; can't do remote stuff.
|
protected int |
ruleLevel |
static java.lang.String |
RUNTIME_STATS_FILENAME |
protected java.util.Set<java.lang.String> |
uniqueRules |
static java.lang.String |
Version
Because I may change the stats, I need to track that for later
computations to be consistent.
|
FALSE, PROTOCOL_VERSION, TRUE| Constructor and Description |
|---|
Profiler() |
Profiler(DebugParser parser) |
| Modifier and Type | Method and Description |
|---|---|
void |
beginBacktrack(int level)
Track backtracking decisions.
|
void |
consumeHiddenToken(Token token)
An off-channel input token was consumed.
|
void |
consumeToken(Token token)
An input token was consumed; matched by any kind of element.
|
protected Profiler.DecisionEvent |
currentDecision() |
void |
endBacktrack(int level,
boolean successful)
Successful or not, track how much lookahead synpreds use
|
void |
enterDecision(int decisionNumber,
boolean couldBacktrack)
Every decision, fixed k or arbitrary, has an enter/exit event
so that a GUI can easily track what LT/consume events are
associated with prediction.
|
void |
enterRule(java.lang.String grammarFileName,
java.lang.String ruleName)
The parser has just entered a rule.
|
void |
examineRuleMemoization(IntStream input,
int ruleIndex,
int stopIndex,
java.lang.String ruleName)
Track memoization; this is not part of standard debug interface
but is triggered by profiling.
|
void |
exitDecision(int decisionNumber) |
void |
exitRule(java.lang.String grammarFileName,
java.lang.String ruleName)
This is the last thing executed before leaving a rule.
|
java.util.List<Profiler.DecisionEvent> |
getDecisionEvents() |
DoubleKeyMap<java.lang.String,java.lang.Integer,Profiler.DecisionDescriptor> |
getDecisionStats() |
java.lang.String |
getDecisionStatsDump() |
int |
getNumberOfHiddenTokens(int i,
int j)
Get num hidden tokens between i..j inclusive
|
Profiler.ProfileStats |
getReport() |
boolean |
inDecision()
The parser is in a decision if the decision depth > 0.
|
void |
location(int line,
int pos)
To watch a parser move through the grammar, the parser needs to
inform the debugger what line/charPos it is passing in the grammar.
|
protected java.lang.String |
locationDescription() |
protected java.lang.String |
locationDescription(java.lang.String file,
java.lang.String rule,
int line,
int pos) |
void |
LT(int i,
Token t)
Track refs to lookahead if in a fixed/nonfixed decision.
|
void |
mark(int i)
The parser is going to look arbitrarily ahead; mark this location,
the token stream's marker is sent in case you need it.
|
void |
memoize(IntStream input,
int ruleIndex,
int ruleStartIndex,
java.lang.String ruleName)
Warning: doesn't track success/failure, just unique recording event
|
void |
recognitionException(RecognitionException e)
A recognition exception occurred such as NoViableAltException.
|
void |
rewind()
Rewind to the input position of the last marker.
|
void |
rewind(int i)
After an arbitrairly long lookahead as with a cyclic DFA (or with
any backtrack), this informs the debugger that stream should be
rewound to the position associated with marker.
|
void |
semanticPredicate(boolean result,
java.lang.String predicate)
A semantic predicate was evaluate with this result and action text
|
void |
setParser(DebugParser parser) |
void |
terminate()
Parsing is over; successfully or not.
|
protected int[] |
toArray(java.util.List<java.lang.Integer> a) |
java.lang.String |
toNotifyString() |
java.lang.String |
toString() |
static java.lang.String |
toString(Profiler.ProfileStats stats) |
protected int[] |
trim(int[] X,
int n) |
addChild, becomeRoot, beginResync, commence, consumeNode, createNode, createNode, endResync, enterAlt, enterSubRule, errorNode, exitSubRule, LT, nilNode, setTokenBoundariespublic static final java.lang.String DATA_SEP
public static final java.lang.String newline
public static final java.lang.String Version
public static final java.lang.String RUNTIME_STATS_FILENAME
public DebugParser parser
protected int ruleLevel
protected Token lastRealTokenTouchedInDecision
protected java.util.Set<java.lang.String> uniqueRules
protected java.util.Stack<java.lang.String> currentGrammarFileName
protected java.util.Stack<java.lang.String> currentRuleName
protected java.util.Stack<java.lang.Integer> currentLine
protected java.util.Stack<java.lang.Integer> currentPos
protected DoubleKeyMap<java.lang.String,java.lang.Integer,Profiler.DecisionDescriptor> decisions
protected java.util.List<Profiler.DecisionEvent> decisionEvents
protected java.util.Stack<Profiler.DecisionEvent> decisionStack
protected int backtrackDepth
public Profiler()
public Profiler(DebugParser parser)
public void enterRule(java.lang.String grammarFileName,
java.lang.String ruleName)
DebugEventListenerenterRule in interface DebugEventListenerenterRule in class BlankDebugEventListenerpublic void exitRule(java.lang.String grammarFileName,
java.lang.String ruleName)
DebugEventListenerexitRule in interface DebugEventListenerexitRule in class BlankDebugEventListenerpublic void examineRuleMemoization(IntStream input, int ruleIndex, int stopIndex, java.lang.String ruleName)
public void memoize(IntStream input, int ruleIndex, int ruleStartIndex, java.lang.String ruleName)
public void location(int line,
int pos)
DebugEventListenerlocation in interface DebugEventListenerlocation in class BlankDebugEventListenerpublic void enterDecision(int decisionNumber,
boolean couldBacktrack)
DebugEventListenerenterDecision in interface DebugEventListenerenterDecision in class BlankDebugEventListenerpublic void exitDecision(int decisionNumber)
exitDecision in interface DebugEventListenerexitDecision in class BlankDebugEventListenerpublic void consumeToken(Token token)
DebugEventListenerconsumeToken in interface DebugEventListenerconsumeToken in class BlankDebugEventListenerpublic boolean inDecision()
public void consumeHiddenToken(Token token)
DebugEventListenerconsumeHiddenToken in interface DebugEventListenerconsumeHiddenToken in class BlankDebugEventListenerpublic void LT(int i,
Token t)
LT in interface DebugEventListenerLT in class BlankDebugEventListenerpublic void beginBacktrack(int level)
beginBacktrack in interface DebugEventListenerbeginBacktrack in class BlankDebugEventListenerpublic void endBacktrack(int level,
boolean successful)
endBacktrack in interface DebugEventListenerendBacktrack in class BlankDebugEventListenerpublic void mark(int i)
DebugEventListenermark in interface DebugEventListenermark in class BlankDebugEventListenerpublic void rewind(int i)
DebugEventListenerrewind in interface DebugEventListenerrewind in class BlankDebugEventListenerpublic void rewind()
DebugEventListenerrewind in interface DebugEventListenerrewind in class BlankDebugEventListenerprotected Profiler.DecisionEvent currentDecision()
public void recognitionException(RecognitionException e)
DebugEventListenerrecognitionException in interface DebugEventListenerrecognitionException in class BlankDebugEventListenerpublic void semanticPredicate(boolean result,
java.lang.String predicate)
DebugEventListenersemanticPredicate in interface DebugEventListenersemanticPredicate in class BlankDebugEventListenerpublic void terminate()
DebugEventListenerterminate in interface DebugEventListenerterminate in class BlankDebugEventListenerpublic void setParser(DebugParser parser)
public java.lang.String toNotifyString()
public java.lang.String toString()
toString in class java.lang.Objectpublic Profiler.ProfileStats getReport()
public DoubleKeyMap<java.lang.String,java.lang.Integer,Profiler.DecisionDescriptor> getDecisionStats()
public java.util.List<Profiler.DecisionEvent> getDecisionEvents()
public static java.lang.String toString(Profiler.ProfileStats stats)
public java.lang.String getDecisionStatsDump()
protected int[] trim(int[] X,
int n)
protected int[] toArray(java.util.List<java.lang.Integer> a)
public int getNumberOfHiddenTokens(int i,
int j)
protected java.lang.String locationDescription()
protected java.lang.String locationDescription(java.lang.String file,
java.lang.String rule,
int line,
int pos)