-
Notifications
You must be signed in to change notification settings - Fork 0
/
ook2bf.bf
203 lines (167 loc) · 15.5 KB
/
ook2bf.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
( Ook! code to Brainfuck code translator: written by moskensoap 2024 )
( https://github(dot)com/moskensoap/brainfuck )
# Converts Ook! code to Brainfuck code
# Assumes the interpreter or compiler supports EOF=0 or leaves EOF unchanged
variable: this(0)
backup: this(1)
temp: this(2)
const: right left plus minus dot comma bra ket b a n
cell: this(3) this(4) this(5) this(6) this(7) this(8) this(9) this(10) this(11) this(12) this(13)
ASCII: 62 60 43 45 46 44 91 93 98 97 110
input new !flag new flag old flag
(dot) this(14) this(15) this(16)
? this(17) this(18) this(19)
! this(20) this(21) this(22)
new@!flag should be initialized to 0 and new@flag should be initialized to 1
if no target char found(comma) set new@!flag to 1 and new@flag to 0
if target char found(comma) do nothing
>>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 0 this(3)=62 3
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 this(4)=60 4
>+++++++++++++++++++++++++++++++++++++++++++ 4 this(5)=43 5
>+++++++++++++++++++++++++++++++++++++++++++++ 5 this(6)=45 6
>++++++++++++++++++++++++++++++++++++++++++++++ 6 this(7)=46 7
>++++++++++++++++++++++++++++++++++++++++++++ 7 this(8)=44 8
>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 8 this(9)=91 9
>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 9 this(10)=93 10
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 10 this(11)=98 11
>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 11 this(12)=97 12
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ this(13)=110 13
<<<<<<<<<<<<< 13 0
+[ 0 while(this(0)!=0) 0
[-]
, 0 this(0)=getchar() 0
#initialize this(1) and this(2) to 0
>[-]>[-]<< 0 this(1)=0 this(2)=0 0
#cp this(0) to this(1) and this(0)
+[->>+<<]>>- 0 move this(0) to this(2) 2
+[-<+<+>>]<-<- 0 move this(2) to this(1) and this(0) 0
#initialize this(14) this(17) this(20) to 0 and this(15) this(18) this(21) to 1
>>>>>>>>>>>>>>[-]>[-]+>>[-]>[-]+>>[-]>[-]+<<<<<<<<<<<<<<<<<<<<< 0 initialize new@!flag and new@flag 0
#############################################################################################################
#generate !flag of dot(ASCII=46)
#if(this(0)!=dot)this(14)=1
----------------------------------------------
[ 0 while(this(0)) 0
>>>>>>>>>>>>>>+<<<<<<<<<<<<<< 0 this(14)=1 0
[-] 0 this(0)=0 0
] 0 0
#generate flag of dot
#if(this(14)!=0)this(15)=0
>>>>>>>>>>>>>>[ 0 while(this(14)) 14
>-< 14 this(15)=0 14
[-] 14 this(14)=0 14
]<<<<<<<<<<<<<< 14 0
#begin#cp this(1) to this(1) and this(0)#####################################################################
>+[->+<]>- 0 move this(1) to this(2) 2
+[-<+<+>>]<-<- 2 move this(2) to this(1) and this(0) 0
#end#cp this(1) to this(1) and this(0)#######################################################################
#generate !flag of ?(ASCII=63)
#if(this(0)!=?)this(17)=1
---------------------------------------------------------------
[ 0 while(this(0)) 0
>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<< 0 this(17)=1 0
[-] 0 this(0)=0 0
] 0 0
#generate flag of ?
#if(this(17)!=0)this(18)=0
>>>>>>>>>>>>>>>>>[ 0 while(this(17)) 17
>-< 17 this(18)=0 17
[-] 17 this(17)=0 17
]<<<<<<<<<<<<<<<<< 17 0
#begin#cp this(1) to this(1) and this(0)#####################################################################
>+[->+<]>- 0 move this(1) to this(2) 2
+[-<+<+>>]<-<- 2 move this(2) to this(1) and this(0) 0
#end#cp this(1) to this(1) and this(0)#######################################################################
#generate !flag of !(ASCII=33)
#if(this(0)!=!)this(20)=1
---------------------------------
[ 0 while(this(0)) 0
>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<< 0 this(20)=1 0
[-] 0 this(0)=0 0
] 0 0
#generate flag of !
#if(this(20)!=0)this(21)=0
>>>>>>>>>>>>>>>>>>>>[ 0 while(this(20)) 20
>-< 20 this(21)=0 20
[-] 20 this(20)=0 20
]<<<<<<<<<<<<<<<<<<<< 20 0
#begin#cp this(1) to this(1) and this(0)#####################################################################
>+[->+<]>- 0 move this(1) to this(2) 2
+[-<+<+>>]<-<- 2 move this(2) to this(1) and this(0) 0
#end#cp this(1) to this(1) and this(0)#######################################################################
#if new@flag==(dot)
>>>>>>>>>>>>>>>[ 0 while(this(15)) 15
#if old@flag==(dot)
>[ 15 while(this(16)) 16
<<<<<<<<<<<.>>>>>>>>>>> 16 putchar(this(5)(plus)) 16
<[-]> 16 this(15)=0 16
[-] 16 this(16)=0 16
] 16 16
#if old@flag==?
>>>[ 16 while(this(19)) 19
<<<<<<<<<<<<<<<.>>>>>>>>>>>>>>> 19 putchar(this(4)(left)) 19
<<<<[-]>>>> 19 this(15)=0 19
[-] 19 this(19)=0 19
] 19 19
#if old@flag==!
>>>[ 19 while(this(22)) 22
<<<<<<<<<<<<<<<.>>>>>>>>>>>>>>> 22 putchar(this(7)(dot)) 22
<<<<<<<[-]>>>>>>> 22 this(15)=0 22
[-] 22 this(22)=0 22
] 22 22
<<<<<<< 22 15
#move this(15) to this(16)
+[->+<]>- 15 this(16)=this(15) 16
< 16 15
]<<<<<<<<<<<<<<< 15 0
#if new@flag==(?)
>>>>>>>>>>>>>>>>>>[ 0 while(this(18)) 18
#if old@flag==(dot)
<<[ 18 while(this(16)) 16
<<<<<<<<<<<<<.>>>>>>>>>>>>> 16 putchar(this(3)(right)) 16
>>[-]<< 16 this(18)=0 16
[-] 16 this(16)=0 16
] 16 16
#if old@flag==?
>>>[ 16 while(this(19)) 19
<<<<<<<<.>.>.<.>.<.>>>>>>> 19 putchar(b11a12n13a12n13a12) 19
<[-]> 19 this(18)=0 19
[-] 19 this(19)=0 19
] 19 19
#if old@flag==!
>>>[ 19 while(this(22)) 22
<<<<<<<<<<<<<.>>>>>>>>>>>>> 22 putchar(this(9)(bra)) 22
<<<<[-]>>>> 22 this(18)=0 22
[-] 22 this(22)=0 22
] 22 22
<<<< 22 18
#move this(18) to this(19)
+[->+<]>- 18 this(19)=this(18) 19
< 19 18
]<<<<<<<<<<<<<<<<<< 18 0
#if new@flag==(!)
>>>>>>>>>>>>>>>>>>>>>[ 0 while(this(21)) 21
#if old@flag==(dot)
<<<<<[ 21 while(this(16)) 16
<<<<<<<<.>>>>>>>> 16 putchar(this(8)(comma)) 16
>>>>>[-]<<<<< 16 this(21)=0 16
[-] 16 this(16)=0 16
] 16 16
#if old@flag==?
>>>[ 16 while(this(19)) 19
<<<<<<<<<.>>>>>>>>> 19 putchar(this(10)(ket)) 19
>>[-]<< 19 this(21)=0 19
[-] 19 this(19)=0 19
] 19 19
#if old@flag==!
>>>[ 19 while(this(22)) 22
<<<<<<<<<<<<<<<<.>>>>>>>>>>>>>>>> 22 putchar(this(6)(minus)) 22
<[-]> 22 this(21)=0 22
[-] 22 this(22)=0 22
] 22 22
< 22 21
#move this(21) to this(22)
+[->+<]>- 21 this(22)=this(21) 22
< 22 21
]<<<<<<<<<<<<<<<<<<<<< 21 0
] 0 loop until EOF 0