CppLexer: Add token type for "*="

This commit is contained in:
Nico Weber 2020-07-26 13:35:47 -04:00 committed by Andreas Kling
parent b09b8d99f2
commit 5a36d8acb8
2 changed files with 13 additions and 1 deletions

View file

@ -243,6 +243,17 @@ Vector<CppToken> CppLexer::lex()
tokens.append(token);
};
auto emit_token_equals = [&](auto type, auto equals_type) {
if (peek(1) == '=') {
begin_token();
consume();
consume();
commit_token(equals_type);
return;
}
emit_token(type);
};
auto match_escape_sequence = [&]() -> size_t {
switch (peek(1)) {
case '\'':
@ -336,7 +347,7 @@ Vector<CppToken> CppLexer::lex()
continue;
}
if (ch == '*') {
emit_token(CppToken::Type::Asterisk);
emit_token_equals(CppToken::Type::Asterisk, CppToken::Type::AsteriskEquals);
continue;
}
if (ch == ';') {

View file

@ -45,6 +45,7 @@ namespace GUI {
__TOKEN(RightBracket) \
__TOKEN(Comma) \
__TOKEN(Asterisk) \
__TOKEN(AsteriskEquals) \
__TOKEN(Semicolon) \
__TOKEN(DoubleQuotedString) \
__TOKEN(SingleQuotedString) \