Skip to content

Commit

Permalink
replace and & or with && & ||
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonymousAAArdvark committed Jan 10, 2022
1 parent 3e2525c commit 9a2511b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ static TokenType checkKeyword(int start, int length, const char* rest, TokenType

static TokenType identifierType() {
switch (scanner.start[0]) {
case 'a': return checkKeyword(1, 2, "nd", TOKEN_AND);
case 'b': return checkKeyword(1, 4, "reak", TOKEN_BREAK);
case 'c':
if (scanner.current - scanner.start > 1) {
Expand All @@ -136,7 +135,6 @@ static TokenType identifierType() {
break;
case 'i': return checkKeyword(1, 1, "f", TOKEN_IF);
case 'n': return checkKeyword(1, 2, "il", TOKEN_NIL);
case 'o': return checkKeyword(1, 1, "r", TOKEN_OR);
case 'p': return checkKeyword(1, 4, "rint", TOKEN_PRINT);
case 'r': return checkKeyword(1, 5, "eturn", TOKEN_RETURN);
case 's':
Expand Down Expand Up @@ -232,6 +230,8 @@ Token scanToken() {
case '"': return string();
case '[': return makeToken(TOKEN_LEFT_BRACKET);
case ']': return makeToken(TOKEN_RIGHT_BRACKET);
case '&': if (match('&')) return makeToken(TOKEN_AND);
case '|': if (match('|')) return makeToken(TOKEN_OR);
}

return errorToken("Unexpected character.");
Expand Down
8 changes: 8 additions & 0 deletions test/scratch.qi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
print true && false;
print true && true;
print false && false;
print false && true;
print true || false;
print true || true;
print false || false;
print false || true;

0 comments on commit 9a2511b

Please sign in to comment.