diff options
author | Nico Weber <thakis@chromium.org> | 2020-07-26 16:37:23 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-27 01:04:17 +0200 |
commit | 97c4344f33ba1e030c0ebe657b550127b27f93b5 (patch) | |
tree | 469b1ca00bc2adad67a860942838b9431e9f0ab9 | |
parent | 23082e528f8d57742169baef43646f36ce6e3c88 (diff) | |
download | serenity-97c4344f33ba1e030c0ebe657b550127b27f93b5.zip |
CppLexer: Add token types for "<", "<=", "<<", "<<=", "<>"
-rw-r--r-- | Libraries/LibGUI/CppLexer.cpp | 30 | ||||
-rw-r--r-- | Libraries/LibGUI/CppLexer.h | 11 |
2 files changed, 41 insertions, 0 deletions
diff --git a/Libraries/LibGUI/CppLexer.cpp b/Libraries/LibGUI/CppLexer.cpp index 4631a9185e..6f9cc1e101 100644 --- a/Libraries/LibGUI/CppLexer.cpp +++ b/Libraries/LibGUI/CppLexer.cpp @@ -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; diff --git a/Libraries/LibGUI/CppLexer.h b/Libraries/LibGUI/CppLexer.h index cc0c76ecb6..4a7d077daa 100644 --- a/Libraries/LibGUI/CppLexer.h +++ b/Libraries/LibGUI/CppLexer.h @@ -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) \ |