Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for cell value-wrapping and IndexOutOfBounds on unmatching loop tokens #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

TrapperHell
Copy link

No description provided.

The tape is supposedly working on bytes, therefore the cell values should never end up with values less than zero or greater than 255. While the values can be capped, it is much better to implement value-wrapping.

Brainfuck.Run() now accepts two additional, optional parameters for the in/out streams, instead of assuming Console streams.

Minor refactoring of Tape class.

Added a UnitTest project with a few BFLib Brainfuck tests, also demonstrating a use-case for the tape cell value-wrapping.
Some invalid Brainfuck code with an unequal amount loop start/end tokens will lead to an IndexOutOfRange exception. This fix will ensure that the program does not attempt to traverse beyond the code range and will stop execution silently instead.

Some implementations of BF refuse to run the code immediately upon detecting it as invalid. This currently does not perform any pre-run checks, and as such some portions of the code may finish executing by the time the loop is encountered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant