varDeclaration method
Implementation
Stmt varDeclaration() {
Token name = consume(TokenType.IDENTIFIER, "Expect variable name.");
Expr? initializer;
if (match([TokenType.EQUAL])) {
initializer = expression();
} else {
initializer = null;
}
consume(TokenType.SEMICOLON, "Expect ';' after variable declaration.");
return Var(name, initializer);
}