diff options
| Commit | df537df158e0375b01c0a7acdd98aa2f57db5ac3 (patch) | |
|---|---|---|
| Author | 2018-09-07 19:58:36 +0300 | |
| Committer | 2018-09-07 19:58:36 +0300 | |
| Files | 696510080c4278f911c4ca364f22beeb6d4964b0 /JSImpl/src | |
| IPL-df537df158e0375b01c0a7acdd98aa2f57db5ac3.tar IPL-df537df158e0375b01c0a7acdd98aa2f57db5ac3.tar.gz IPL-df537df158e0375b01c0a7acdd98aa2f57db5ac3.zip | ||
| Parent | 7128a5853db709548f3ec9fe63973cbf7ccc5c54 (diff) | |
Add support for bitwise and logical operators to Lexer.
2 files changed, 17 insertions, 3 deletions
| -rw-r--r-- | JSImpl/src/Lexer.cpp | 10 | ||||
| -rw-r--r-- | JSImpl/src/Lexer.h | 10 |
diff --git a/JSImpl/src/Lexer.cpp b/JSImpl/src/Lexer.cpp index 2115a2b..3e78275 100644 --- a/JSImpl/src/Lexer.cpp +++ b/JSImpl/src/Lexer.cpp @@ -160,11 +160,17 @@ Token Tokenizer::NextToken() case '+': m_Current++; return Match('+') ? ProduceToken(TokenType::PlusPlus) : ProduceToken(TokenType::Plus); case ';': m_Current++; return ProduceToken(TokenType::Semicolon); case '*': m_Current++; return ProduceToken(TokenType::Star); + case '/': m_Current++; return ProduceToken(TokenType::Division); + case '%': m_Current++; return ProduceToken(TokenType::Modulo); case '~': m_Current++; return ProduceToken(TokenType::BitwiseNot); case '=': m_Current++; return Match('=') ? Match('=') ? ProduceToken(TokenType::StrictEqual) : ProduceToken(TokenType::EqualEqual) : ProduceToken(TokenType::Equal); case '!': m_Current++; return Match('=') ? Match('=') ? ProduceToken(TokenType::StrictNotEqual) : ProduceToken(TokenType::BangEqual) : ProduceToken(TokenType::Bang); - case '>': m_Current++; return Match('=') ? ProduceToken(TokenType::GreaterEqual) : ProduceToken(TokenType::Greater); - case '<': m_Current++; return Match('=') ? ProduceToken(TokenType::LessEqual) : ProduceToken(TokenType::Less); + case '>': m_Current++; return Match('=') ? ProduceToken(TokenType::GreaterEqual) : Match('>') ? ProduceToken(TokenType::RightShift) : ProduceToken(TokenType::Greater); + case '<': m_Current++; return Match('=') ? ProduceToken(TokenType::LessEqual) : Match('<') ? ProduceToken(TokenType::LeftShift) : ProduceToken(TokenType::Less); + case '&': m_Current++; return Match('&') ? ProduceToken(LogicalAnd) : ProduceToken(BitwiseAnd); + case '^': m_Current++; return ProduceToken(BitwiseXor); + case '|': m_Current++; return Match('|') ? ProduceToken(LogicalOr) : ProduceToken(BitwiseOr); + default: break; } diff --git a/JSImpl/src/Lexer.h b/JSImpl/src/Lexer.h index eb33e77..21c06cc 100644 --- a/JSImpl/src/Lexer.h +++ b/JSImpl/src/Lexer.h @@ -15,9 +15,13 @@ enum TokenType Minus, Plus, Semicolon, - Slash, Star, + Division, + Modulo, BitwiseNot, + BitwiseAnd, + BitwiseXor, + BitwiseOr, // One or two character tokens Bang, @@ -32,6 +36,10 @@ enum TokenType LessEqual, MinusMinus, PlusPlus, + LeftShift, + RightShift, + LogicalAnd, + LogicalOr, Identifier, String, |
