

Public Member Functions | |
| Profiler () | |
| Profiler (DebugParser parser) | |
| void | enterRule (String grammarFileName, String ruleName) |
| void | examineRuleMemoization (IntStream input, int ruleIndex, String ruleName) |
| void | memoize (IntStream input, int ruleIndex, int ruleStartIndex, String ruleName) |
| void | exitRule (String grammarFileName, String ruleName) |
| void | enterDecision (int decisionNumber) |
| void | exitDecision (int decisionNumber) |
| void | consumeToken (Token token) |
| boolean | inDecision () |
| void | consumeHiddenToken (Token token) |
| void | LT (int i, Token t) |
| void | beginBacktrack (int level) |
| void | endBacktrack (int level, boolean successful) |
| void | recognitionException (RecognitionException e) |
| void | semanticPredicate (boolean result, String predicate) |
| void | terminate () |
| void | setParser (DebugParser parser) |
| String | toNotifyString () |
| String | toString () |
| int | getNumberOfHiddenTokens (int i, int j) |
Static Public Member Functions | |
| static String | toString (String notifyDataLine) |
Public Attributes | |
| DebugParser | parser = null |
| int | numRuleInvocations = 0 |
| int | numGuessingRuleInvocations = 0 |
| int | maxRuleInvocationDepth = 0 |
| int | numFixedDecisions = 0 |
| int | numCyclicDecisions = 0 |
| int | numBacktrackDecisions = 0 |
| int[] | decisionMaxFixedLookaheads = new int[200] |
| int[] | decisionMaxCyclicLookaheads = new int[200] |
| List | decisionMaxSynPredLookaheads = new ArrayList() |
| int | numHiddenTokens = 0 |
| int | numCharsMatched = 0 |
| int | numHiddenCharsMatched = 0 |
| int | numSemanticPredicates = 0 |
| int | numSyntacticPredicates = 0 |
| int | numMemoizationCacheMisses = 0 |
| int | numMemoizationCacheHits = 0 |
| int | numMemoizationCacheEntries = 0 |
Static Public Attributes | |
| static final String | Version = "2" |
| static final String | RUNTIME_STATS_FILENAME = "runtime.stats" |
| static final int | NUM_RUNTIME_STATS = 29 |
Protected Member Functions | |
| int[] | trim (int[] X, int n) |
| int[] | toArray (List a) |
Static Protected Member Functions | |
| static String[] | decodeReportData (String data) |
Protected Attributes | |
| int | ruleLevel = 0 |
| int | decisionLevel = 0 |
| int | maxLookaheadInCurrentDecision = 0 |
| CommonToken | lastTokenConsumed = null |
| List | lookaheadStack = new ArrayList() |
| int | numberReportedErrors = 0 |
Definition at line 39 of file Profiler.java.
| org.antlr.runtime.debug.Profiler.Profiler | ( | ) |
Definition at line 79 of file Profiler.java.
| org.antlr.runtime.debug.Profiler.Profiler | ( | DebugParser | parser | ) |
Definition at line 82 of file Profiler.java.
| void org.antlr.runtime.debug.Profiler.enterRule | ( | String | grammarFileName, | |
| String | ruleName | |||
| ) |
The parser has just entered a rule. No decision has been made about which alt is predicted. This is fired AFTER init actions have been executed. Attributes are defined and available etc... The grammarFileName allows composite grammars to jump around among multiple grammar files.
Reimplemented from org.antlr.runtime.debug.BlankDebugEventListener.
Definition at line 86 of file Profiler.java.
| void org.antlr.runtime.debug.Profiler.examineRuleMemoization | ( | IntStream | input, | |
| int | ruleIndex, | |||
| String | ruleName | |||
| ) |
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.
Definition at line 100 of file Profiler.java.
| void org.antlr.runtime.debug.Profiler.memoize | ( | IntStream | input, | |
| int | ruleIndex, | |||
| int | ruleStartIndex, | |||
| String | ruleName | |||
| ) |
Definition at line 118 of file Profiler.java.
| void org.antlr.runtime.debug.Profiler.exitRule | ( | String | grammarFileName, | |
| String | ruleName | |||
| ) |
This is the last thing executed before leaving a rule. It is executed even if an exception is thrown. This is triggered after error reporting and recovery have occurred (unless the exception is not caught in this rule). This implies an "exitAlt" event. The grammarFileName allows composite grammars to jump around among multiple grammar files.
Reimplemented from org.antlr.runtime.debug.BlankDebugEventListener.
Definition at line 128 of file Profiler.java.
| void org.antlr.runtime.debug.Profiler.enterDecision | ( | int | decisionNumber | ) |
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. You will see a single enter/exit subrule but multiple enter/exit decision events, one for each loop iteration.
Reimplemented from org.antlr.runtime.debug.BlankDebugEventListener.
Definition at line 132 of file Profiler.java.
| void org.antlr.runtime.debug.Profiler.exitDecision | ( | int | decisionNumber | ) |
Reimplemented from org.antlr.runtime.debug.BlankDebugEventListener.
Definition at line 139 of file Profiler.java.
| void org.antlr.runtime.debug.Profiler.consumeToken | ( | Token | t | ) |
An input token was consumed; matched by any kind of element. Trigger after the token was matched by things like match(), matchAny().
Reimplemented from org.antlr.runtime.debug.BlankDebugEventListener.
Definition at line 171 of file Profiler.java.
| boolean org.antlr.runtime.debug.Profiler.inDecision | ( | ) |
The parser is in a decision if the decision depth > 0. This works for backtracking also, which can have nested decisions.
Definition at line 179 of file Profiler.java.
| void org.antlr.runtime.debug.Profiler.consumeHiddenToken | ( | Token | t | ) |
An off-channel input token was consumed. Trigger after the token was matched by things like match(), matchAny(). (unless of course the hidden token is first stuff in the input stream).
Reimplemented from org.antlr.runtime.debug.BlankDebugEventListener.
Definition at line 183 of file Profiler.java.
| void org.antlr.runtime.debug.Profiler.LT | ( | int | i, | |
| Token | t | |||
| ) |
Track refs to lookahead if in a fixed/nonfixed decision.
Reimplemented from org.antlr.runtime.debug.BlankDebugEventListener.
Definition at line 190 of file Profiler.java.
| void org.antlr.runtime.debug.Profiler.beginBacktrack | ( | int | level | ) |
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
Reimplemented from org.antlr.runtime.debug.BlankDebugEventListener.
Definition at line 225 of file Profiler.java.
| void org.antlr.runtime.debug.Profiler.endBacktrack | ( | int | level, | |
| boolean | successful | |||
| ) |
Successful or not, track how much lookahead synpreds use
Reimplemented from org.antlr.runtime.debug.BlankDebugEventListener.
Definition at line 231 of file Profiler.java.
| void org.antlr.runtime.debug.Profiler.recognitionException | ( | RecognitionException | e | ) |
A recognition exception occurred such as NoViableAltException. I made this a generic event so that I can alter the exception hierachy later without having to alter all the debug objects.
Upon error, the stack of enter rule/subrule must be properly unwound. If no viable alt occurs it is within an enter/exit decision, which also must be rewound. Even the rewind for each mark must be unwount. In the Java target this is pretty easy using try/finally, if a bit ugly in the generated code. The rewind is generated in DFA.predict() actually so no code needs to be generated for that. For languages w/o this "finally" feature (C++?), the target implementor will have to build an event stack or something.
Across a socket for remote debugging, only the RecognitionException data fields are transmitted. The token object or whatever that caused the problem was the last object referenced by LT. The immediately preceding LT event should hold the unexpected Token or char.
Here is a sample event trace for grammar:
b : C ({;}A|B) // {;} is there to prevent A|B becoming a set | D ;
The sequence for this rule (with no viable alt in the subrule) for input 'c c' (there are 3 tokens) is:
commence LT(1) enterRule b location 7 1 enter decision 3 LT(1) exit decision 3 enterAlt1 location 7 5 LT(1) consumeToken [c/<4>,1:0] location 7 7 enterSubRule 2 enter decision 2 LT(1) LT(1) recognitionException NoViableAltException 2 1 2 exit decision 2 exitSubRule 2 beginResync LT(1) consumeToken [c/<4>,1:1] LT(1) endResync LT(-1) exitRule b terminate
Reimplemented from org.antlr.runtime.debug.BlankDebugEventListener.
Definition at line 261 of file Profiler.java.
| void org.antlr.runtime.debug.Profiler.semanticPredicate | ( | boolean | result, | |
| String | predicate | |||
| ) |
A semantic predicate was evaluate with this result and action text
Reimplemented from org.antlr.runtime.debug.BlankDebugEventListener.
Definition at line 265 of file Profiler.java.
| void org.antlr.runtime.debug.Profiler.terminate | ( | ) |
Parsing is over; successfully or not. Mostly useful for telling remote debugging listeners that it's time to quit. When the rule invocation level goes to zero at the end of a rule, we are done parsing.
Reimplemented from org.antlr.runtime.debug.BlankDebugEventListener.
Definition at line 271 of file Profiler.java.
| void org.antlr.runtime.debug.Profiler.setParser | ( | DebugParser | parser | ) |
Definition at line 283 of file Profiler.java.
| String org.antlr.runtime.debug.Profiler.toNotifyString | ( | ) |
Definition at line 289 of file Profiler.java.
| String org.antlr.runtime.debug.Profiler.toString | ( | ) |
Definition at line 362 of file Profiler.java.
| static String [] org.antlr.runtime.debug.Profiler.decodeReportData | ( | String | data | ) | [static, protected] |
Definition at line 366 of file Profiler.java.
| static String org.antlr.runtime.debug.Profiler.toString | ( | String | notifyDataLine | ) | [static] |
Definition at line 380 of file Profiler.java.
| int [] org.antlr.runtime.debug.Profiler.trim | ( | int[] | X, | |
| int | n | |||
| ) | [protected] |
Definition at line 476 of file Profiler.java.
| int [] org.antlr.runtime.debug.Profiler.toArray | ( | List | a | ) | [protected] |
Definition at line 485 of file Profiler.java.
| int org.antlr.runtime.debug.Profiler.getNumberOfHiddenTokens | ( | int | i, | |
| int | j | |||
| ) |
Get num hidden tokens between i..j inclusive
Definition at line 495 of file Profiler.java.
final String org.antlr.runtime.debug.Profiler.Version = "2" [static] |
Because I may change the stats, I need to track that for later computations to be consistent.
Definition at line 43 of file Profiler.java.
final String org.antlr.runtime.debug.Profiler.RUNTIME_STATS_FILENAME = "runtime.stats" [static] |
Definition at line 44 of file Profiler.java.
final int org.antlr.runtime.debug.Profiler.NUM_RUNTIME_STATS = 29 [static] |
Definition at line 45 of file Profiler.java.
Definition at line 47 of file Profiler.java.
int org.antlr.runtime.debug.Profiler.ruleLevel = 0 [protected] |
Definition at line 51 of file Profiler.java.
int org.antlr.runtime.debug.Profiler.decisionLevel = 0 [protected] |
Definition at line 52 of file Profiler.java.
int org.antlr.runtime.debug.Profiler.maxLookaheadInCurrentDecision = 0 [protected] |
Definition at line 53 of file Profiler.java.
CommonToken org.antlr.runtime.debug.Profiler.lastTokenConsumed = null [protected] |
Definition at line 54 of file Profiler.java.
List org.antlr.runtime.debug.Profiler.lookaheadStack = new ArrayList() [protected] |
Definition at line 56 of file Profiler.java.
Definition at line 60 of file Profiler.java.
Definition at line 61 of file Profiler.java.
Definition at line 62 of file Profiler.java.
Definition at line 63 of file Profiler.java.
Definition at line 64 of file Profiler.java.
Definition at line 65 of file Profiler.java.
| int [] org.antlr.runtime.debug.Profiler.decisionMaxFixedLookaheads = new int[200] |
Definition at line 66 of file Profiler.java.
| int [] org.antlr.runtime.debug.Profiler.decisionMaxCyclicLookaheads = new int[200] |
Definition at line 67 of file Profiler.java.
| List org.antlr.runtime.debug.Profiler.decisionMaxSynPredLookaheads = new ArrayList() |
Definition at line 68 of file Profiler.java.
Definition at line 69 of file Profiler.java.
Definition at line 70 of file Profiler.java.
Definition at line 71 of file Profiler.java.
Definition at line 72 of file Profiler.java.
Definition at line 73 of file Profiler.java.
int org.antlr.runtime.debug.Profiler.numberReportedErrors = 0 [protected] |
Definition at line 74 of file Profiler.java.
Definition at line 75 of file Profiler.java.
Definition at line 76 of file Profiler.java.
Definition at line 77 of file Profiler.java.
1.5.5