-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminify.bf
57 lines (54 loc) · 1.46 KB
/
minify.bf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
[SPDX-FileCopyrightText: Brainfuck Enterprise Solutions
SPDX-License-Identifier: WTFPL]
[format.bf---Brainfuck code minifier.
Removes all the non-command character from the input. The input
should be valid Brainfuck code with balanced square brackets,
followed by the exclamation sign. The output is minified code as one
line without non-command characters
Memory layout is:
[case flag][char][char copy]
Code starts here:]
read char and subtract exclamation mark (33)
,----- ----- ----- ----- ----- ----- ---
[ restore the char
+++++ +++++ +++++ +++++ +++++ +++++ +++
[>+>+<<-] duplicate the char
+> set case flag
[ plus (43)
----- ----- ----- -----
----- ----- ----- ----- ---
[ comma (44)
-
[ minus (45)
-
[ period (46)
-
[ less than (60)
----- ----- ----
[ more than (62)
--
[ opening bracket (91)
----- ----- ----- ----- ----- ----
[ closing bracket (93)
--
default: kill the char and case flag and copy
[<->[-]>[-]<]
command case: kill flag
<[-]>]
command case: kill flag
<[-]>]
command case: kill flag
<[-]>]
command case: kill flag
<[-]>]
command case: kill flag
<[-]>]
command case: kill flag
<[-]>]
command case: kill flag
<[-]>]
command case: kill flag
<[-]>]
>[.[-]] print and kill the copy
read a new char and subtract exclamation mark
<<,----- ----- ----- ----- ----- ----- ---]