blob: 95a89ac8559da492579a45b1da91f5f9598c799d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
#include "atn/ProfilingATNSimulator.h"
#include "dfa/DFA.h"
#include "atn/ParseInfo.h"
using namespace antlr4::atn;
ParseInfo::ParseInfo(ProfilingATNSimulator *atnSimulator) : _atnSimulator(atnSimulator) {
}
ParseInfo::~ParseInfo() {
}
std::vector<DecisionInfo> ParseInfo::getDecisionInfo() {
return _atnSimulator->getDecisionInfo();
}
std::vector<size_t> ParseInfo::getLLDecisions() {
std::vector<DecisionInfo> decisions = _atnSimulator->getDecisionInfo();
std::vector<size_t> LL;
for (size_t i = 0; i < decisions.size(); ++i) {
long long fallBack = decisions[i].LL_Fallback;
if (fallBack > 0) {
LL.push_back(i);
}
}
return LL;
}
long long ParseInfo::getTotalTimeInPrediction() {
std::vector<DecisionInfo> decisions = _atnSimulator->getDecisionInfo();
long long t = 0;
for (size_t i = 0; i < decisions.size(); ++i) {
t += decisions[i].timeInPrediction;
}
return t;
}
long long ParseInfo::getTotalSLLLookaheadOps() {
std::vector<DecisionInfo> decisions = _atnSimulator->getDecisionInfo();
long long k = 0;
for (size_t i = 0; i < decisions.size(); ++i) {
k += decisions[i].SLL_TotalLook;
}
return k;
}
long long ParseInfo::getTotalLLLookaheadOps() {
std::vector<DecisionInfo> decisions = _atnSimulator->getDecisionInfo();
long long k = 0;
for (size_t i = 0; i < decisions.size(); i++) {
k += decisions[i].LL_TotalLook;
}
return k;
}
long long ParseInfo::getTotalSLLATNLookaheadOps() {
std::vector<DecisionInfo> decisions = _atnSimulator->getDecisionInfo();
long long k = 0;
for (size_t i = 0; i < decisions.size(); ++i) {
k += decisions[i].SLL_ATNTransitions;
}
return k;
}
long long ParseInfo::getTotalLLATNLookaheadOps() {
std::vector<DecisionInfo> decisions = _atnSimulator->getDecisionInfo();
long long k = 0;
for (size_t i = 0; i < decisions.size(); ++i) {
k += decisions[i].LL_ATNTransitions;
}
return k;
}
long long ParseInfo::getTotalATNLookaheadOps() {
std::vector<DecisionInfo> decisions = _atnSimulator->getDecisionInfo();
long long k = 0;
for (size_t i = 0; i < decisions.size(); ++i) {
k += decisions[i].SLL_ATNTransitions;
k += decisions[i].LL_ATNTransitions;
}
return k;
}
size_t ParseInfo::getDFASize() {
size_t n = 0;
std::vector<dfa::DFA> &decisionToDFA = _atnSimulator->decisionToDFA;
for (size_t i = 0; i < decisionToDFA.size(); ++i) {
n += getDFASize(i);
}
return n;
}
size_t ParseInfo::getDFASize(size_t decision) {
dfa::DFA &decisionToDFA = _atnSimulator->decisionToDFA[decision];
return decisionToDFA.states.size();
}
|