Added LoxPrintMultiple version

This commit is contained in:
nazrin 2025-06-02 02:24:09 +00:00
parent a21c16d7e5
commit b0d934707b
4 changed files with 23 additions and 7 deletions

View file

@ -81,9 +81,18 @@ class Parser{
}
private Stmt printStatement(){
Expr value = expression();
consume(TokenType.SEMICOLON, "Expect ';' after value.");
return new Stmt.Print(value);
version(LoxPrintMultiple){
Expr[] values;
do {
values ~= expression();
} while(match(TokenType.COMMA));
consume(TokenType.SEMICOLON, "Expect ';' after values.");
return new Stmt.Print(values);
} else {
Expr value = expression();
consume(TokenType.SEMICOLON, "Expect ';' after value.");
return new Stmt.Print(value);
}
}
private Stmt returnStatement(){
Token keyword = previous();