Skip to content

Commit 217f267

Browse files
committed
Revert "[pseudo] Split greatergreater token."
This reverts commit f66d375. It breaks windows bot.
1 parent 8cd8bd4 commit 217f267

File tree

4 files changed

+6
-46
lines changed

4 files changed

+6
-46
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ enum class LexFlags : uint8_t {
180180
NeedsCleaning = 1 << 1,
181181
};
182182

183-
/// Derives a token stream by decoding escapes, interpreting raw_identifiers and
184-
/// splitting the greatergreater token.
183+
/// Derives a token stream by decoding escapes and interpreting raw_identifiers.
185184
///
186185
/// Tokens containing UCNs, escaped newlines, trigraphs etc are decoded and
187186
/// their backing data is owned by the returned stream.

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,9 @@ TokenStream cook(const TokenStream &Code, const LangOptions &LangOpts) {
9898
Tok.Length = Text.size();
9999
Tok.Flags &= ~static_cast<decltype(Tok.Flags)>(LexFlags::NeedsCleaning);
100100
}
101-
102-
if (Tok.Kind == tok::raw_identifier) {
103-
// Cook raw_identifiers into identifier, keyword, etc.
101+
// Cook raw_identifiers into identifier, keyword, etc.
102+
if (Tok.Kind == tok::raw_identifier)
104103
Tok.Kind = Identifiers.get(Tok.text()).getTokenID();
105-
} else if (Tok.Kind == tok::greatergreater) {
106-
// Split the greatergreater token.
107-
// FIXME: split lessless token to support Cuda triple angle brackets <<<.
108-
assert(Tok.text() == ">>");
109-
Tok.Kind = tok::greater;
110-
Tok.Length = 1;
111-
Result.push(Tok);
112-
// Line is wrong if the first greater is followed by an escaped newline!
113-
Tok.Data = Tok.text().data() + 1;
114-
}
115-
116104
Result.push(std::move(Tok));
117105
}
118106

clang-tools-extra/pseudo/lib/cxx.bnf

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
# - the file merely describes the core C++ grammar. Preprocessor directives and
1414
# lexical conversions are omitted as we reuse clang's lexer and run a fake
1515
# preprocessor;
16-
# - grammar rules with the >> token are adjusted, the greatergreater token is
17-
# split into two > tokens, to make the GLR parser aware of nested templates
18-
# and right shift operator;
1916
#
2017
# Guidelines:
2118
# - nonterminals are lower_case; terminals (aka tokens) correspond to
@@ -99,7 +96,7 @@ fold-operator := %
9996
fold-operator := ^
10097
fold-operator := |
10198
fold-operator := <<
102-
fold-operator := greatergreater
99+
fold-operator := >>
103100
fold-operator := +=
104101
fold-operator := -=
105102
fold-operator := *=
@@ -205,7 +202,7 @@ additive-expression := additive-expression - multiplicative-expression
205202
# expr.shift
206203
shift-expression := additive-expression
207204
shift-expression := shift-expression << additive-expression
208-
shift-expression := shift-expression greatergreater additive-expression
205+
shift-expression := shift-expression >> additive-expression
209206
# expr.spaceship
210207
compare-expression := shift-expression
211208
compare-expression := compare-expression <=> shift-expression
@@ -618,7 +615,7 @@ operator-name := <=>
618615
operator-name := ^^
619616
operator-name := ||
620617
operator-name := <<
621-
operator-name := greatergreater
618+
operator-name := >>
622619
operator-name := <<=
623620
operator-name := >>=
624621
operator-name := ++
@@ -740,8 +737,3 @@ contextual-zero := NUMERIC_CONSTANT
740737
module-keyword := IDENTIFIER
741738
import-keyword := IDENTIFIER
742739
export-keyword := IDENTIFIER
743-
744-
#! greatergreater token -- clang lexer always lexes it as a single token, we
745-
#! split it into two tokens to make the GLR parser aware of the nested-template
746-
#! case.
747-
greatergreater := > >

clang-tools-extra/pseudo/unittests/TokenTest.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -171,25 +171,6 @@ no_indent \
171171
}));
172172
}
173173

174-
TEST(TokenTest, SplitGreaterGreater) {
175-
LangOptions Opts;
176-
std::string Code = R"cpp(
177-
>> // split
178-
// >> with an escaped newline in the middle, split
179-
>\
180-
>
181-
>>= // not split
182-
)cpp";
183-
TokenStream Split = stripComments(cook(lex(Code, Opts), Opts));
184-
EXPECT_THAT(Split.tokens(), ElementsAreArray({
185-
token(">", tok::greater),
186-
token(">", tok::greater),
187-
token(">", tok::greater),
188-
token(">", tok::greater),
189-
token(">>=", tok::greatergreaterequal),
190-
}));
191-
}
192-
193174
TEST(TokenTest, DropComments) {
194175
LangOptions Opts;
195176
std::string Code = R"cpp(

0 commit comments

Comments
 (0)