mirror of
https://github.com/Noratrieb/brainfuck.git
synced 2026-01-14 13:35:00 +01:00
js
This commit is contained in:
parent
54b5c9b1f8
commit
deefc18959
3 changed files with 7 additions and 5 deletions
2
js/.gitignore
vendored
2
js/.gitignore
vendored
|
|
@ -1,2 +1,2 @@
|
|||
node_modules
|
||||
node_modules
|
||||
.idea
|
||||
3
js/fizzbuzz.bf
vendored
3
js/fizzbuzz.bf
vendored
|
|
@ -1,2 +1 @@
|
|||
|
||||
++[-].
|
||||
hello...[[].]]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import fs from 'fs/promises';
|
||||
|
||||
const RED = '\x1B[1;31m';
|
||||
const RESET = '\x1B[1;0m';
|
||||
|
||||
function lex(string) {
|
||||
const tokens = [];
|
||||
|
||||
|
|
@ -83,9 +86,9 @@ function reportError(source, message, span) {
|
|||
const linePrefix = `${lineNumber} | `;
|
||||
const lineSpan = span - lastNewlineIdx;
|
||||
|
||||
console.error(`error: ${message}`);
|
||||
console.error(`${RED}error: ${message}${RESET}`);
|
||||
console.error(`${linePrefix}${line}`);
|
||||
console.error(`${' '.repeat(linePrefix.length)}${'-'.repeat(lineSpan)}^`);
|
||||
console.error(`${' '.repeat(linePrefix.length + lineSpan)}${RED}^${RESET}`);
|
||||
}
|
||||
|
||||
const file = process.argv[2];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue