summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-07-26 16:40:57 -0400
committerAndreas Kling <kling@serenityos.org>2020-07-27 01:04:17 +0200
commit598b5e459559d32ab136dbde6fb615b7bdf62510 (patch)
tree3006a369dcda203e74a4c91444737c2d34fba67f
parent345b303262710cd66e4d3b98f364182b0ed96dc8 (diff)
downloadserenity-598b5e459559d32ab136dbde6fb615b7bdf62510.zip
CppLexer: Add token types for "&", "&&", "&=", "|", "||", "|="
-rw-r--r--Libraries/LibGUI/CppLexer.cpp32
-rw-r--r--Libraries/LibGUI/CppLexer.h6
2 files changed, 38 insertions, 0 deletions
diff --git a/Libraries/LibGUI/CppLexer.cpp b/Libraries/LibGUI/CppLexer.cpp
index 0a812a134c..c1f8853519 100644
--- a/Libraries/LibGUI/CppLexer.cpp
+++ b/Libraries/LibGUI/CppLexer.cpp
@@ -413,6 +413,38 @@ Vector<CppToken> CppLexer::lex()
emit_token_equals(CppToken::Type::Equals, CppToken::Type::EqualsEquals);
continue;
}
+ if (ch == '&') {
+ begin_token();
+ consume();
+ if (peek() == '&') {
+ consume();
+ commit_token(CppToken::Type::AndAnd);
+ continue;
+ }
+ if (peek() == '=') {
+ consume();
+ commit_token(CppToken::Type::AndEquals);
+ continue;
+ }
+ commit_token(CppToken::Type::And);
+ continue;
+ }
+ if (ch == '|') {
+ begin_token();
+ consume();
+ if (peek() == '|') {
+ consume();
+ commit_token(CppToken::Type::PipePipe);
+ continue;
+ }
+ if (peek() == '=') {
+ consume();
+ commit_token(CppToken::Type::PipeEquals);
+ continue;
+ }
+ commit_token(CppToken::Type::Pipe);
+ continue;
+ }
if (ch == ';') {
emit_token(CppToken::Type::Semicolon);
continue;
diff --git a/Libraries/LibGUI/CppLexer.h b/Libraries/LibGUI/CppLexer.h
index 4a7d077daa..88d0ebcf4e 100644
--- a/Libraries/LibGUI/CppLexer.h
+++ b/Libraries/LibGUI/CppLexer.h
@@ -65,6 +65,12 @@ namespace GUI {
__TOKEN(PercentEquals) \
__TOKEN(Equals) \
__TOKEN(EqualsEquals) \
+ __TOKEN(And) \
+ __TOKEN(AndAnd) \
+ __TOKEN(AndEquals) \
+ __TOKEN(Pipe) \
+ __TOKEN(PipePipe) \
+ __TOKEN(PipeEquals) \
__TOKEN(Semicolon) \
__TOKEN(DoubleQuotedString) \
__TOKEN(SingleQuotedString) \