| Copyright | (c) Allele Dev 2014 |
|---|---|
| License | BSD-3 |
| Maintainer | allele.dev@gmail.com |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Language.Brainfuck.Eval
Description
Documentation
eval :: Tape -> String -> IO Tape Source #
eval operates over the given tape, parses the string, and returns the state of the tape.
Potential unhandled errors:
- Out of bounds access to the tape
- Infinite loops
- Exceptions thrown by
print - Exceptions thrown by
putChar
Handled errors:
- Matching jump not found for '[' and ']': terminate eval and return tape
As a result of evaluating the BF program, the following instructions are effectful:
- ',': pauses evaluation to receive user input
.: prints the tape contents at DP as a Char
Here's how eval might be called:
>>>let tape = listArray (0,99) (replicate 100 0)>>>eval tape "+.+."\1\2>>>eval tape ",."aa