Handle empty (or comment-only) files. Fix #57.

This commit is contained in:
Bob Nystrom
2015-01-04 13:00:53 -08:00
parent 005688da96
commit a9bb2387a1
5 changed files with 5 additions and 9 deletions

View File

@ -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);

View File

@ -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);

View File

@ -0,0 +1 @@
// comment

View File

@ -0,0 +1 @@
// comment

0
test/empty_file.wren Normal file
View File