Skip to content

Commit 5a62495

Browse files
committed
[pseudo] Fix some naming-style violations.
1 parent 45cb2df commit 5a62495

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ struct GrammarTable {
157157

158158
struct Nonterminal {
159159
std::string Name;
160-
// Corresponding rules that construct the non-terminal, it is a [start, end)
160+
// Corresponding rules that construct the non-terminal, it is a [Start, End)
161161
// index range of the Rules table.
162162
struct {
163-
RuleID start;
164-
RuleID end;
163+
RuleID Start;
164+
RuleID End;
165165
} RuleRange;
166166
};
167167

clang-tools-extra/pseudo/lib/Grammar.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ Grammar::Grammar(std::unique_ptr<GrammarTable> Table) : T(std::move(Table)) {
3636
llvm::ArrayRef<Rule> Grammar::rulesFor(SymbolID SID) const {
3737
assert(isNonterminal(SID));
3838
const auto &R = T->Nonterminals[SID].RuleRange;
39-
assert(R.end <= T->Rules.size());
40-
return llvm::makeArrayRef(&T->Rules[R.start], R.end - R.start);
39+
assert(R.End <= T->Rules.size());
40+
return llvm::makeArrayRef(&T->Rules[R.Start], R.End - R.Start);
4141
}
4242

4343
const Rule &Grammar::lookupRule(RuleID RID) const {
@@ -65,7 +65,7 @@ std::string Grammar::dumpRules(SymbolID SID) const {
6565
assert(isNonterminal(SID));
6666
std::string Result;
6767
const auto &Range = T->Nonterminals[SID].RuleRange;
68-
for (RuleID RID = Range.start; RID < Range.end; ++RID)
68+
for (RuleID RID = Range.Start; RID < Range.End; ++RID)
6969
Result.append(dumpRule(RID)).push_back('\n');
7070
return Result;
7171
}
@@ -140,17 +140,17 @@ std::vector<llvm::DenseSet<SymbolID>> followSets(const Grammar &G) {
140140
for (const auto &R : G.table().Rules) {
141141
// Rule 2: for a rule X := ... Y Z, we add all symbols from FIRST(Z) to
142142
// FOLLOW(Y).
143-
for (size_t i = 0; i + 1 < R.seq().size(); ++i) {
144-
if (isToken(R.seq()[i]))
143+
for (size_t I = 0; I + 1 < R.seq().size(); ++I) {
144+
if (isToken(R.seq()[I]))
145145
continue;
146146
// We only need to consider the next symbol because symbols are
147147
// non-nullable.
148-
SymbolID Next = R.seq()[i + 1];
148+
SymbolID Next = R.seq()[I + 1];
149149
if (isToken(Next))
150150
// First set for a terminal is itself.
151-
Changed |= ExpandFollowSet(R.seq()[i], {Next});
151+
Changed |= ExpandFollowSet(R.seq()[I], {Next});
152152
else
153-
Changed |= ExpandFollowSet(R.seq()[i], FirstSets[Next]);
153+
Changed |= ExpandFollowSet(R.seq()[I], FirstSets[Next]);
154154
}
155155
// Rule 3: for a rule X := ... Z, we add all symbols from FOLLOW(X) to
156156
// FOLLOW(Z).

clang-tools-extra/pseudo/lib/GrammarBNF.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class GrammarBuilder {
203203
const auto &T = G.table();
204204
for (SymbolID SID = 0; SID < T.Nonterminals.size(); ++SID) {
205205
auto Range = T.Nonterminals[SID].RuleRange;
206-
if (Range.start == Range.end)
206+
if (Range.Start == Range.End)
207207
Diagnostics.push_back(
208208
llvm::formatv("No rules for nonterminal: {0}", G.symbolName(SID)));
209209
llvm::StringRef NameRef = T.Nonterminals[SID].Name;
@@ -216,7 +216,7 @@ class GrammarBuilder {
216216
if (T.Rules[RID] == T.Rules[RID + 1])
217217
Diagnostics.push_back(
218218
llvm::formatv("Duplicate rule: `{0}`", G.dumpRule(RID)));
219-
// Warning for nullable non-terminals
219+
// Warning for nullable nonterminals
220220
if (T.Rules[RID].Size == 0)
221221
Diagnostics.push_back(
222222
llvm::formatv("Rule `{0}` has a nullable RHS", G.dumpRule(RID)));

clang-tools-extra/pseudo/lib/LRGraph.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ State closure(ItemSet Queue, const Grammar &G) {
7575
if (pseudo::isToken(NextSym))
7676
continue;
7777
auto RRange = G.table().Nonterminals[NextSym].RuleRange;
78-
for (RuleID RID = RRange.start; RID < RRange.end; ++RID) {
78+
for (RuleID RID = RRange.Start; RID < RRange.End; ++RID) {
7979
Item NewItem = Item::start(RID, G);
8080
if (InQueue.insert(NewItem).second) // new
8181
Queue.push_back(std::move(NewItem));
@@ -204,7 +204,7 @@ LRGraph LRGraph::buildLR0(const Grammar &G) {
204204
std::vector<StateID> PendingStates;
205205
// Initialize states with the start symbol.
206206
auto RRange = G.table().Nonterminals[G.startSymbol()].RuleRange;
207-
for (RuleID RID = RRange.start; RID < RRange.end; ++RID) {
207+
for (RuleID RID = RRange.Start; RID < RRange.End; ++RID) {
208208
auto StartState = std::vector<Item>{Item::start(RID, G)};
209209
auto Result = Builder.insert(std::move(StartState));
210210
assert(Result.second && "State must be new");

0 commit comments

Comments
 (0)