From deefc189595b2ff89b5f6cfbaa9d466b1cd1a3dc Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Mon, 16 May 2022 12:32:10 +0200 Subject: [PATCH] js --- js/.gitignore | 2 +- js/fizzbuzz.bf | 3 +-- js/src/index.js | 7 +++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/js/.gitignore b/js/.gitignore index 22e6580..34977ee 100644 --- a/js/.gitignore +++ b/js/.gitignore @@ -1,2 +1,2 @@ -node_modules +node_modules .idea \ No newline at end of file diff --git a/js/fizzbuzz.bf b/js/fizzbuzz.bf index e4c514e..dd46222 100644 --- a/js/fizzbuzz.bf +++ b/js/fizzbuzz.bf @@ -1,2 +1 @@ - - ++[-]. \ No newline at end of file +hello...[[].]] diff --git a/js/src/index.js b/js/src/index.js index 81672ba..5e89184 100644 --- a/js/src/index.js +++ b/js/src/index.js @@ -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];