Skip to content

Commit

Permalink
Correctly showing illegal operator error
Browse files Browse the repository at this point in the history
  • Loading branch information
envenomator committed Feb 25, 2024
1 parent f4a2270 commit c56cabb
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ uint8_t getDefineValueToken(streamtoken_t *token, char *src) {
uint8_t getOperatorToken(streamtoken_t *token, char *src) {
uint8_t length = 0;
bool normalmode = true;
bool shift = false;
bool shift = false, error = false;

// skip leading space
while(*src && (isspace(*src))) src++;
Expand All @@ -290,11 +290,12 @@ uint8_t getOperatorToken(streamtoken_t *token, char *src) {
while(*src) {
if(*src == '\'') normalmode = !normalmode;
if(normalmode && strchr("+-*<>&|^~/",*src)) { // terminator found
if((*src == '<') || (*src == '>')) {
if(*(src+1) == *src) shift = true;
if((*src == '<') || (*src == '>')) {
if(*(src+1) == *src) {
shift = true;
}
else {
token->terminator = '!'; // ERROR
break;
error = true;
}
}
break;
Expand All @@ -303,7 +304,10 @@ uint8_t getOperatorToken(streamtoken_t *token, char *src) {
length++;
}

token->terminator = *src;
if(!error) token->terminator = *src;
else {
token->terminator = '!';
}
if(*src) token->next = shift?src+2:src+1;
else token->next = NULL;

Expand Down

0 comments on commit c56cabb

Please sign in to comment.