From 5d8403f5a3deb02c08f46ccb1e179a807f0e0a69 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Thu, 28 Dec 2017 19:58:32 -0500 Subject: [PATCH] Debugger: Even more operators --- src/debugger/cli-debugger.c | 15 +++++++++++++++ src/debugger/parser.c | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/debugger/cli-debugger.c b/src/debugger/cli-debugger.c index 3077dbdc8..786afcb60 100644 --- a/src/debugger/cli-debugger.c +++ b/src/debugger/cli-debugger.c @@ -569,6 +569,21 @@ static uint32_t _performOperation(enum Operation operation, uint32_t current, ui case OP_XOR: current ^= next; break; + case OP_LESS: + current = current < next; + break; + case OP_GREATER: + current = current > next; + break; + case OP_EQUAL: + current = current == next; + break; + case OP_LE: + current = current <= next; + break; + case OP_GE: + current = current >= next; + break; } return current; } diff --git a/src/debugger/parser.c b/src/debugger/parser.c index bf6e0b5af..ff9e28cdf 100644 --- a/src/debugger/parser.c +++ b/src/debugger/parser.c @@ -43,6 +43,12 @@ static struct LexVector* _lexOperator(struct LexVector* lv, char operator) { case '^': lvNext->token.operatorValue = OP_XOR; break; + case '<': + lvNext->token.operatorValue = OP_LESS; + break; + case '>': + lvNext->token.operatorValue = OP_GREATER; + break; default: lvNext->token.type = TOKEN_ERROR_TYPE; break; @@ -125,6 +131,8 @@ size_t lexExpression(struct LexVector* lv, const char* string, size_t length) { case '&': case '|': case '^': + case '<': + case '>': lv->token.type = TOKEN_IDENTIFIER_TYPE; lv->token.identifierValue = strndup(tokenStart, string - tokenStart - 1); lv = _lexOperator(lv, token); @@ -151,6 +159,11 @@ size_t lexExpression(struct LexVector* lv, const char* string, size_t length) { case '-': case '*': case '/': + case '&': + case '|': + case '^': + case '<': + case '>': lv->token.type = TOKEN_UINT_TYPE; lv->token.uintValue = next; lv = _lexOperator(lv, token); @@ -189,6 +202,8 @@ size_t lexExpression(struct LexVector* lv, const char* string, size_t length) { case '&': case '|': case '^': + case '<': + case '>': lv->token.type = TOKEN_UINT_TYPE; lv->token.uintValue = next; lv = _lexOperator(lv, token); @@ -246,6 +261,8 @@ size_t lexExpression(struct LexVector* lv, const char* string, size_t length) { case '&': case '|': case '^': + case '<': + case '>': lv->token.type = TOKEN_UINT_TYPE; lv->token.uintValue = next; lv = _lexOperator(lv, token); @@ -291,6 +308,8 @@ size_t lexExpression(struct LexVector* lv, const char* string, size_t length) { case '&': case '|': case '^': + case '<': + case '>': lv->token.type = TOKEN_UINT_TYPE; lv->token.uintValue = next; lv = _lexOperator(lv, token); @@ -327,6 +346,8 @@ size_t lexExpression(struct LexVector* lv, const char* string, size_t length) { case '&': case '|': case '^': + case '<': + case '>': lvNext = malloc(sizeof(struct LexVector)); lvNext->next = lv->next; lvNext->token.type = TOKEN_CLOSE_PAREN_TYPE;