CppLexer: Add token types for "::", "::*", ".*", "->*"

This commit is contained in:
Nico Weber 2020-07-26 18:35:17 -04:00 committed by Andreas Kling
parent 1992dbd637
commit 7a1c328417
Notes: sideshowbarker 2024-07-19 04:34:53 +09:00
2 changed files with 30 additions and 2 deletions

View file

@ -424,6 +424,11 @@ Vector<CppToken> CppLexer::lex()
}
if (peek() == '>') {
consume();
if (peek() == '*') {
consume();
commit_token(CppToken::Type::ArrowAsterisk);
continue;
}
commit_token(CppToken::Type::Arrow);
continue;
}
@ -491,7 +496,19 @@ Vector<CppToken> CppLexer::lex()
continue;
}
if (ch == ':') {
emit_token(CppToken::Type::Colon);
begin_token();
consume();
if (peek() == ':') {
consume();
if (peek() == '*') {
consume();
commit_token(CppToken::Type::ColonColonAsterisk);
continue;
}
commit_token(CppToken::Type::ColonColon);
continue;
}
commit_token(CppToken::Type::Colon);
continue;
}
if (ch == ';') {
@ -499,7 +516,14 @@ Vector<CppToken> CppLexer::lex()
continue;
}
if (ch == '.') {
emit_token(CppToken::Type::Dot);
begin_token();
consume();
if (peek() == '*') {
consume();
commit_token(CppToken::Type::DotAsterisk);
continue;
}
commit_token(CppToken::Type::Dot);
continue;
}
if (ch == '#') {

View file

@ -80,9 +80,13 @@ namespace GUI {
__TOKEN(Tilde) \
__TOKEN(QuestionMark) \
__TOKEN(Colon) \
__TOKEN(ColonColon) \
__TOKEN(ColonColonAsterisk) \
__TOKEN(Semicolon) \
__TOKEN(Dot) \
__TOKEN(DotAsterisk) \
__TOKEN(Arrow) \
__TOKEN(ArrowAsterisk) \
__TOKEN(DoubleQuotedString) \
__TOKEN(SingleQuotedString) \
__TOKEN(EscapeSequence) \