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