added symbol table for repl mode
This commit is contained in:
parent
9aa14f7a2a
commit
68326a19a1
1 changed files with 22 additions and 0 deletions
22
src/bfhs.hs
22
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 ()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue