Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -2207,6 +2207,8 @@ static Node *conditional(Token **rest, Token *tok) {
node->cond = cond;
node->then = expr(&tok, tok->next);
tok = skip(tok, ":");
if (tok->at_bol)
error_tok(tok, "expected an expression");
node->els = conditional(rest, tok);
return node;
}
Expand Down
2 changes: 1 addition & 1 deletion tokenize.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void warn_tok(Token *tok, char *fmt, ...) {

// Consumes the current token if it matches `op`.
bool equal(Token *tok, char *op) {
return memcmp(tok->loc, op, tok->len) == 0 && op[tok->len] == '\0';
return strlen(op) == tok->len && strncmp(tok->loc, op, tok->len) == 0;
}

// Ensure that the current token is `op`.
Expand Down