CppLexer: Add token types for "<", "<=", "<<", "<<=", "<>"

This commit is contained in:
Nico Weber 2020-07-26 16:37:23 -04:00 committed by Andreas Kling
parent 23082e528f
commit 97c4344f33
2 changed files with 41 additions and 0 deletions

View file

@ -342,6 +342,32 @@ Vector<CppToken> CppLexer::lex()
emit_token(CppToken::Type::RightBracket);
continue;
}
if (ch == '<') {
begin_token();
consume();
if (peek() == '<') {
consume();
if (peek() == '=') {
consume();
commit_token(CppToken::Type::LessLessEquals);
continue;
}
commit_token(CppToken::Type::LessLess);
continue;
}
if (peek() == '=') {
consume();
commit_token(CppToken::Type::LessEquals);
continue;
}
if (peek() == '>') {
consume();
commit_token(CppToken::Type::LessGreater);
continue;
}
commit_token(CppToken::Type::Less);
continue;
}
if (ch == ',') {
emit_token(CppToken::Type::Comma);
continue;
@ -358,6 +384,10 @@ Vector<CppToken> CppLexer::lex()
emit_token_equals(CppToken::Type::Asterisk, CppToken::Type::AsteriskEquals);
continue;
}
if (ch == '%') {
emit_token_equals(CppToken::Type::Percent, CppToken::Type::PercentEquals);
continue;
}
if (ch == '=') {
emit_token_equals(CppToken::Type::Equals, CppToken::Type::EqualsEquals);
continue;

View file

@ -43,6 +43,15 @@ namespace GUI {
__TOKEN(RightCurly) \
__TOKEN(LeftBracket) \
__TOKEN(RightBracket) \
__TOKEN(Less) \
__TOKEN(Greater) \
__TOKEN(LessEquals) \
__TOKEN(GreaterEquals) \
__TOKEN(LessLess) \
__TOKEN(GreaterGreater) \
__TOKEN(LessLessEquals) \
__TOKEN(GreaterGreaterEquals) \
__TOKEN(LessGreater) \
__TOKEN(Comma) \
__TOKEN(Plus) \
__TOKEN(PlusEquals) \
@ -52,6 +61,8 @@ namespace GUI {
__TOKEN(AsteriskEquals) \
__TOKEN(Slash) \
__TOKEN(SlashEquals) \
__TOKEN(Percent) \
__TOKEN(PercentEquals) \
__TOKEN(Equals) \
__TOKEN(EqualsEquals) \
__TOKEN(Semicolon) \