Added LoxPrintMultiple version
This commit is contained in:
parent
a21c16d7e5
commit
b0d934707b
4 changed files with 23 additions and 7 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue