added EQ and NEQ
This commit is contained in:
@@ -14,12 +14,16 @@ namespace lexer {
|
||||
|
||||
switch (c) {
|
||||
case '=':
|
||||
if (input.peek() == '=')
|
||||
return {token::type::EQ, std::string{c, (char) input.get()}};
|
||||
return {token::type::ASSIGN, c};
|
||||
case '+':
|
||||
return {token::type::PLUS, c};
|
||||
case '-':
|
||||
return {token::type::MINUS, c};
|
||||
case '!':
|
||||
if (input.peek() == '=')
|
||||
return {token::type::NEQ, std::string{c, (char) input.get()}};
|
||||
return {token::type::BANG, c};
|
||||
case '*':
|
||||
return {token::type::ASTERISK, c};
|
||||
|
@@ -30,6 +30,8 @@ namespace token {
|
||||
X(ELSE, "ELSE") \
|
||||
X(TRUE, "TRUE") \
|
||||
X(FALSE, "FALSE") \
|
||||
X(EQ, "==") \
|
||||
X(NEQ, "!=") \
|
||||
X(RETURN, "RETURN")
|
||||
|
||||
// Define the TokenType enum using the X-macro
|
||||
|
Reference in New Issue
Block a user