feat: add zero-arg IO.print overload and remove newline skipping in parameter parsing
Add a static `print` method with no arguments that writes only a newline, enabling blank-line output. Remove the `ignoreNewlines` calls before closing parentheses in parameter lists and method calls, tightening syntax rules. Add a `strlen` TODO comment in symbol table lookup for future optimization. Move the `Foo.toString` test from `test/io/write.wren` to `test/io/print.wren` and delete the old write test file.
This commit is contained in:
@@ -1405,8 +1405,6 @@ static int parameterList(Compiler* compiler, char* name, int* length,
|
||||
}
|
||||
while (match(compiler, TOKEN_COMMA));
|
||||
|
||||
// Allow a newline before the closing ')'.
|
||||
ignoreNewlines(compiler);
|
||||
const char* message = (endToken == TOKEN_RIGHT_PAREN) ?
|
||||
"Expect ')' after parameters." : "Expect '|' after parameters.";
|
||||
consume(compiler, endToken, message);
|
||||
@@ -1443,8 +1441,6 @@ static void methodCall(Compiler* compiler, Code instruction,
|
||||
}
|
||||
while (match(compiler, TOKEN_COMMA));
|
||||
|
||||
// Allow a newline before the closing ')'.
|
||||
ignoreNewlines(compiler);
|
||||
consume(compiler, TOKEN_RIGHT_PAREN, "Expect ')' after arguments.");
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
// This string literal is generated automatically from io.wren. Do not edit.
|
||||
static const char* libSource =
|
||||
"class IO {\n"
|
||||
" static print {\n"
|
||||
" IO.writeString_(\"\n\")\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" static print(obj) {\n"
|
||||
" IO.writeString_(obj.toString)\n"
|
||||
" IO.writeString_(\"\n\")\n"
|
||||
|
||||
@@ -59,6 +59,7 @@ int wrenSymbolTableFind(SymbolTable* symbols, const char* name, size_t length)
|
||||
// TODO: O(n). Do something better.
|
||||
for (int i = 0; i < symbols->count; i++)
|
||||
{
|
||||
// TODO: strlen() here is gross. Symbol table should store lengths.
|
||||
if (strlen(symbols->data[i]) == length &&
|
||||
strncmp(symbols->data[i], name, length) == 0) return i;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user