Skip to content

Commit

Permalink
remove new lines from user loaded .hack code
Browse files Browse the repository at this point in the history
  • Loading branch information
ArhanChaudhary committed Jul 11, 2024
1 parent b664b79 commit 5012494
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/app/MemoryView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,14 @@
alert("Only one .hack file is supported.");
return;
}
machineCode = programFiles[0].file;
machineCode = programFiles[0].file
// remove new lines
.filter((line) => line);
for (let instruction of machineCode) {
if (!/^[01]{16}$/.test(instruction)) {
$compilerError = new BroadCompilerError(
"",
"Invalid .hack file format"
"Invalid .hack file format: expected sixteen 0s or 1s per line"
);
return;
}
Expand Down

0 comments on commit 5012494

Please sign in to comment.