mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 22:28:45 +01:00
Handle empty (or comment-only) files. Fix #57.
This commit is contained in:
@ -90,12 +90,8 @@ static int runRepl(WrenVM* vm)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Do nothing if we received an empty line.
|
||||
if (strcmp(line, "\n") != 0)
|
||||
{
|
||||
// TODO: Handle failure.
|
||||
wrenInterpret(vm, "Prompt", line);
|
||||
}
|
||||
// TODO: Handle failure.
|
||||
wrenInterpret(vm, "Prompt", line);
|
||||
|
||||
free(line);
|
||||
|
||||
|
||||
@ -2747,7 +2747,7 @@ ObjFn* wrenCompile(WrenVM* vm, const char* sourcePath, const char* source)
|
||||
|
||||
WREN_UNPIN(vm);
|
||||
|
||||
for (;;)
|
||||
while (!match(&compiler, TOKEN_EOF))
|
||||
{
|
||||
definition(&compiler);
|
||||
|
||||
@ -2757,8 +2757,6 @@ ObjFn* wrenCompile(WrenVM* vm, const char* sourcePath, const char* source)
|
||||
consume(&compiler, TOKEN_EOF, "Expect end of file.");
|
||||
break;
|
||||
}
|
||||
|
||||
if (match(&compiler, TOKEN_EOF)) break;
|
||||
}
|
||||
|
||||
emit(&compiler, CODE_NULL);
|
||||
|
||||
1
test/comments/only_line_comment.wren
Normal file
1
test/comments/only_line_comment.wren
Normal file
@ -0,0 +1 @@
|
||||
// comment
|
||||
1
test/comments/only_line_comment_and_line.wren
Normal file
1
test/comments/only_line_comment_and_line.wren
Normal file
@ -0,0 +1 @@
|
||||
// comment
|
||||
0
test/empty_file.wren
Normal file
0
test/empty_file.wren
Normal file
Reference in New Issue
Block a user