-
-
Notifications
You must be signed in to change notification settings - Fork 592
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Remove All Whitespace in Brainfuck (#3673)
* Add Remove All Whitespace in Brainfuck * Clean up formatting * Clean up comments
- Loading branch information
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
[ | ||
Source for error message text: | ||
https://copy.sh/brainfuck/text.html | ||
] | ||
; Mem 0 = 1 (indicate no input) | ||
+ | ||
; Mem 1 = input; Loop while input not null | ||
>,[ | ||
; Mem 0 = 0 (indicate input) | ||
<[-] | ||
; Mem 2 = input; Mem 3 = input; Mem 1 = 0 | ||
>>[-] ; Mem 2 = 0 | ||
>[-] ; Mem 3 = 0 | ||
<<[ | ||
>+ ; Inc Mem 2 | ||
>+ ; Mem Mem 3 | ||
<<- ; Dec Mem 1 | ||
] | ||
; Sub 9 from Mem 3; If not zero (not tab) | ||
>>---------[ | ||
; Dec Mem 3; If not zero (not newline) | ||
-[ | ||
; Sub 3 from Mem 3; If not zero (not carriage return) | ||
---[ | ||
; Sub 19 from Mem 3; If not zero (not space) | ||
>+++[ ; Mem 4 = 3 | ||
<------ ; Sub 6 from Mem 3 | ||
>- ; Dec Mem 4 | ||
] | ||
<- ; Dec Mem 3 | ||
[ | ||
; Display input (Mem 2) and reset Mem 3 | ||
<. | ||
>[-] | ||
] | ||
] | ||
] | ||
] | ||
; Mem 1 = input | ||
<<, | ||
] | ||
; If no input; display error message | ||
<[ | ||
[-] | ||
-[--->+<]>. | ||
+[--->+<]>+. | ||
++[->+++<]>++. | ||
++++++. | ||
--. | ||
+++[->+++<]>++. | ||
[-->+<]>+++. | ||
[-->+++++++<]>. | ||
----. | ||
-------. | ||
----. | ||
--[--->+<]>--. | ||
++++[->+++<]>. | ||
--[--->+<]>-. | ||
[-->+++++++<]>. | ||
++. | ||
---. | ||
+++++++. | ||
[------>+<]>. | ||
-----. | ||
+. | ||
--[--->+<]>-. | ||
[->+++<]>+. | ||
-[->+++<]>. | ||
---[->++++<]>-. | ||
+. | ||
--. | ||
---------. | ||
+++++. | ||
-------. | ||
[-] | ||
] |