From 68326a19a1c52d1c337ea3b62e32174e97df022f Mon Sep 17 00:00:00 2001 From: Dario48 Date: Mon, 2 Mar 2026 22:16:12 +0100 Subject: [PATCH 1/2] added symbol table for repl mode --- src/bfhs.hs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/bfhs.hs b/src/bfhs.hs index a7b3f0d..a205b8b 100644 --- a/src/bfhs.hs +++ b/src/bfhs.hs @@ -36,6 +36,28 @@ repl interpreter = do | other == size - 0 -> printf "... %u %u |%u| ]\n" (arr ! (size - 2)) (arr ! (size - 1)) (arr ! size) | otherwise -> printf "... %u %u |%u| %u %u ...\n" (arr ! (other - 2)) (arr ! (other - 1)) (arr ! other) (arr ! (other + 1)) (arr ! (other + 2)) >> repl interpreter + ":s" -> + return () + >> putStrLn "|--------+-------------------------------------------------------------------------------------------------------|" + >> putStrLn "| symbol | description |" + >> putStrLn "|========+=======================================================================================================|" + >> putStrLn "| > | Increment the data pointer by one (to point to the next cell to the right). |" + >> putStrLn "|--------+-------------------------------------------------------------------------------------------------------|" + >> putStrLn "| < | Decrement the data pointer by one (to point to the next cell to the left). Undefined if at 0. |" + >> putStrLn "|--------+-------------------------------------------------------------------------------------------------------|" + >> putStrLn "| + | Increment the byte at the data pointer by one modulo 256. |" + >> putStrLn "|--------+-------------------------------------------------------------------------------------------------------|" + >> putStrLn "| - | Decrement the byte at the data pointer by one modulo 256. |" + >> putStrLn "|--------+-------------------------------------------------------------------------------------------------------|" + >> putStrLn "| . | Output the byte at the data pointer. |" + >> putStrLn "|--------+-------------------------------------------------------------------------------------------------------|" + >> putStrLn "| , | Accept one byte of input, storing its value in the byte at the data pointer.[b] |" + >> putStrLn "|--------+-------------------------------------------------------------------------------------------------------|" + >> putStrLn "| [ | If the byte at the data pointer is zero, jump forward to the command after the matching ] command. |" + >> putStrLn "|--------+-------------------------------------------------------------------------------------------------------|" + >> putStrLn "| ] | If the byte at the data pointer is nonzero, jump back to the command after the matching [ command.[c] |" + >> putStrLn "|--------+-------------------------------------------------------------------------------------------------------|" + >> repl interpreter brainfuck -> interpreter `execStr` brainfuck >>= repl main :: IO () From 482152c303387e0a3f117e6d811a1fabb59a8333 Mon Sep 17 00:00:00 2001 From: Dario48 Date: Mon, 2 Mar 2026 22:18:36 +0100 Subject: [PATCH 2/2] added :s to the help text and fixed copy-pasting error --- src/bfhs.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bfhs.hs b/src/bfhs.hs index a205b8b..4a30117 100644 --- a/src/bfhs.hs +++ b/src/bfhs.hs @@ -21,6 +21,7 @@ repl interpreter = do putStrLn " :h = this text" putStrLn " :q = quit" putStrLn " :d = print the state of the array around the index" + putStrLn " :s = print a table of all symbols and their functionality" repl interpreter ":q" -> return () ":d" -> @@ -51,11 +52,11 @@ repl interpreter = do >> putStrLn "|--------+-------------------------------------------------------------------------------------------------------|" >> putStrLn "| . | Output the byte at the data pointer. |" >> putStrLn "|--------+-------------------------------------------------------------------------------------------------------|" - >> putStrLn "| , | Accept one byte of input, storing its value in the byte at the data pointer.[b] |" + >> putStrLn "| , | Accept one byte of input, storing its value in the byte at the data pointer. |" >> putStrLn "|--------+-------------------------------------------------------------------------------------------------------|" >> putStrLn "| [ | If the byte at the data pointer is zero, jump forward to the command after the matching ] command. |" >> putStrLn "|--------+-------------------------------------------------------------------------------------------------------|" - >> putStrLn "| ] | If the byte at the data pointer is nonzero, jump back to the command after the matching [ command.[c] |" + >> putStrLn "| ] | If the byte at the data pointer is nonzero, jump back to the command after the matching [ command. |" >> putStrLn "|--------+-------------------------------------------------------------------------------------------------------|" >> repl interpreter brainfuck -> interpreter `execStr` brainfuck >>= repl