Skip to content

Commit db1643f

Browse files
committed
[Parser] Factor out token prefix checking. NFC.
1 parent bb5d42d commit db1643f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

include/swift/Parse/Parser.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -517,16 +517,16 @@ class Parser {
517517
/// Add a camel-cased option if it is different than the first option.
518518
void diagnoseConsecutiveIDs(StringRef First, SourceLoc FirstLoc,
519519
StringRef DeclKindName);
520-
521-
/// \brief Check whether the current token starts with '<'.
522-
bool startsWithLess(Token Tok) {
523-
return Tok.isAnyOperator() && Tok.getText()[0] == '<';
520+
521+
bool startsWithSymbol(Token Tok, char symbol) {
522+
return (Tok.isAnyOperator() || Tok.isPunctuation()) &&
523+
Tok.getText()[0] == symbol;
524524
}
525+
/// \brief Check whether the current token starts with '<'.
526+
bool startsWithLess(Token Tok) { return startsWithSymbol(Tok, '<'); }
525527

526528
/// \brief Check whether the current token starts with '>'.
527-
bool startsWithGreater(Token Tok) {
528-
return Tok.isAnyOperator() && Tok.getText()[0] == '>';
529-
}
529+
bool startsWithGreater(Token Tok) { return startsWithSymbol(Tok, '>'); }
530530

531531
/// \brief Consume the starting '<' of the current token, which may either
532532
/// be a complete '<' token or some kind of operator token starting with '<',

0 commit comments

Comments
 (0)