Skip to content

Commit

Permalink
Add == and != operators to lexer
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolashn committed Dec 8, 2021
1 parent b48eb38 commit 3d72ca4
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ int ba_Tokenize(FILE* srcFile, struct ba_Controller* ctr) {
++fileIter;
continue;
}
else if (c == ';' || c == '!' || c == '~' || c == '@' ||
c == '(' || c == ')' || c == '=')
else if (c == ';' || c == '~' || c == '@' ||
c == '(' || c == ')')
{
nextLex->type = c;
}
Expand All @@ -158,7 +158,15 @@ int ba_Tokenize(FILE* srcFile, struct ba_Controller* ctr) {
colStart = col++;
c = fileBuf[++fileIter];

if (oldC == '+') {
if (oldC == '=') {
((c == '=') && (nextLex->type = BA_TK_DBEQUAL)) ||
((nextLex->type = '=') && (needsToIterate = 0));
}
else if (oldC == '!') {
((c == '=') && (nextLex->type = BA_TK_NEQUAL)) ||
((nextLex->type = '!') && (needsToIterate = 0));
}
else if (oldC == '+') {
((c == '=') && (nextLex->type = BA_TK_ADDEQ)) ||
((nextLex->type = '+') && (needsToIterate = 0));
}
Expand Down

0 comments on commit 3d72ca4

Please sign in to comment.