The function can match only first param and following params cannot be matched cuz the function is return after first loop.
file location: craftinginterpreters/blob/master/java/com/craftinginterpreters/lox/Parser.java
private boolean match(TokenType... types) {
for (TokenType type : types) {
if (check(type)) {
advance();
return true;
}
}
return false;
}
How about
private boolean match(TokenType... types) {
for (TokenType type : types) {
if (!check(type)) {
return false;
}
advance();
}
return true;
}
The function can match only first param and following params cannot be matched cuz the function is return after first loop. file location: craftinginterpreters/blob/master/java/com/craftinginterpreters/lox/Parser.java
private boolean match(TokenType... types) { for (TokenType type : types) { if (check(type)) { advance(); return true; } } return false; }
How about
private boolean match(TokenType... types) { for (TokenType type : types) { if (!check(type)) { return false; } advance(); } return true; }