]> Git — Sourcephile - haskell/symantic-parser.git/blob - parsers/Parsers/Brainfuck/inputs/compiler.bf
change ShowLetName into HideableName
[haskell/symantic-parser.git] / parsers / Parsers / Brainfuck / inputs / compiler.bf
1 Thanks to: https://github.com/matslina/awib
2 # This is the awib frontend
3 # Please refer to the documentation in the full source distribution
4 # of awib for details regarding this file
5 ## Phase 1
6 ## Target identification
7 ##
8 % *T (where T = index of target platform)
9 # read bytes until EOF or bf instruction or '@' is reached
10 >>>>+[>[-],+
11 % T 0 0 0 1 *inc(X) 0 0 0 (where X is byte read)
12 [->+>+<<]>>[-<<+>>]+<
13 % T 0 0 0 1 inc(X) *inc(X) 1 0
14 [-[>+++++[-<------->]+<-[-[-[-[--------------[--[-->>+<<[>>-<++
15 [-<--------->]+<[--[>+++++++++[-<++++++++++>]<[-]]]]]]]]]]]<->]
16 >[-<<<->>>]<<<]
17 % T 0 0 0 *0 X 0 0 d
18 % if( X=='@' ) d=1 else if(EOF) X=0 else X = a bf instruction
19 # if '@' was encountered then read a string at most 20 bytes long
20 # whitespace and EOF and bf all terminate the string when read
21 >>>>[->++++++++++++++++++++<<<<[-]>>>+[
22 % T 0 0 0 0 (target) 0 0 0 *1 C (where C = sub(20 strlen(target)))
23 -<,+[-<+<+>>]+<<->
24 % T 0 0 0 0 (target) X *X 1 0 C
25 [-[---------[-[---[>++++[-<---->]+<+[-----------[-[-[-[--------------
26 [--[>++[-<--------->]+<--[--[>+++++++++[-<++++++++++>]<[-]]]]]]]]]]]]]]]
27 +>[-<->]
28 % T 0 0 0 0 (target) X c *0 0 C (where c=(X EOF or bf or whitespace ? 0 : 1))
29 >>[->+<]
30 <<<[->>>+>->+<[>-]>[>]<[-<<->>]<<<<<]>>>
31 % T 0 0 0 0 (target) X 0 0 0 *c D
32 % where c=(string terminated ? 0 : 1) and D=(c==1 ? sub(C 1) : C)
33 ]
34 # if string was ended due to strlen exceeding limit then read one char extra
35 +>[<-]<[<]>[-<<<,>>>>]
36 % T 0 0 0 0 (target) X 0 0 0 *0 D
37 # now check if the read target string matches any known target string
38 # and overwrite the target index T accordingly
39 # we take care not to overwrite the last read X as it may be bf and should
40 # be passed on to the bytecode compiler below
41 <<<<+[->+<]>[-<<[<]<<<+>>>>[>]>]++++++++++++++++++++>>>>[-<<<<->>>>]<<<++++++++
42 <<<[<]<<<->>>>[>]>>
43 % T X 0 0 0 (target) 0 s *8 0 0 (where s = strlen(target))
44 [[->+>+<<]>[-<+>]+>-[-[-[-[-[-[-[-[<->[-]]
45 <[-
46 # build target string for backend index 8
47 % T X 0 0 0 (target) 0 s 8 *0 0
48 >+++++++++[->+>++++++++++++<<]>>[->+>+>+>+>+>+>+>+>+<<<<<<<<<]
49 >>----------->++>----->------------->-->----------->++++++++++>-----------
50 <<<<<<<<<<<<
51 % T X 0 0 0 (target) 0 s 8 *0 0 9 0 "lang_java" 0
52 ]>]
53 <[-
54 # build target string for backend index 7
55 % T X 0 0 0 (target) 0 s 7 *0 0
56 >+++++++++[->+>++++++++++++<<]>->[->+>+>+>+>+>+>+>+<<<<<<<<]>>----------->++
57 >----->------------->++++++++>---------
58 <<<<<<<<<<
59 % T X 0 0 0 (target) 0 s 7 *0 0 8 0 "lang_tcl" 0
60 ]>]
61 <[-
62 # build target string for backend index 6
63 % T X 0 0 0 (target) 0 s 6 *0 0
64 >+++++++++[->+>++++++++++++<<]>>[->+>+>+>+>+>+>+>+>+<<<<<<<<<]>>----------->++
65 >----->------------->++++++>+++++++++>---------->+++++++++++++
66 <<<<<<<<<<<<
67 % T X 0 0 0 (target) 0 s 6 *0 0 9 0 "lang_ruby" 0
68 ]>]
69 <[-
70 # build target string for backend index 5
71 % T X 0 0 0 (target) 0 s 5 *0 0
72 >+++++++++++[->+>++++++++++<<]>>[->+>+>+>+>+>+>+>+>+>+>+<<<<<<<<<<<]
73 >-->------------->>------->--------------->++>+++++++++++>++++++>------>+
74 <<<<<<<<<<<<<
75 % T X 0 0 0 (target) 0 s 5 *0 0 11 0 "lang_python" 0
76 ]>]
77 <[-
78 # build target string for backend index 4
79 % T X 0 0 0 (target) 0 s 4 *0 0
80 >>+++++++[->+++++++<]+++++++>
81 [->++>++>++>++>++>++>++<<<<<<<]>
82 ++++++++++>->++++++++++++>+++++>--->+++++>+++++++++++++
83 <<<<<<<<<<
84 % T X 0 0 0 (target) 0 s 4 *0 0 7 0 "lang_go" 0
85 ]>]
86 <[-
87 # build target string for backend index 3
88 % T X 0 0 0 (target) 0 s 3 *0 0
89 >>+++++++[->+++++++<]++++++++++>
90 [->++>++>++>++>++>++>++>++>++>++<<<<<<<<<<]>
91 ++++++++++>->++++++++++++>+++++>--->++>+++++++++++++++++++>+++++++++++>
92 +++++++++++>+++++++++++++++++++++++<<<<<<<<<<<<<
93 % T X 0 0 0 (target) 0 s 3 *0 0 10 0 "lang_dummy" 0
94 ]>]
95 <[-
96 # build target string for backend index 2
97 % T X 0 0 0 (target) 0 s 2 *0 0
98 >>+++++++[->+++++++<]++++++>[->++>++>++>++>++>++<<<<<<]
99 >++++++++++>->++++++++++++>+++++>--->+<<<<<<<<<
100 % T X 0 0 0 (target) 0 s 2 *0 0 6 0 "lang_c" 0
101 ]>]
102 <[-
103 # build target string for backend index 1
104 % T X 0 0 0 (target) 0 s 1 *0 0
105 >>+++++++[->+++++++<]+++++++++>[->+>+>+>++>++>++>++>++>++<<<<<<<<<]
106 >++>+++++++>+++++>--->++++++++++>+++++++>++++++++++++>+++
107 ++++++++++++++++>++++++++++++++++++++++<<<<<<<<<<<<
108 % T X 0 0 0 (target) 0 s 1 *0 0 9 0 "386_linux" 0
109 ]
110 % T X 0 0 0 (target) 0 s i *0 0 S 0 (string) 0
111 % where S = strlen(string) and i is the backend index of the target (string)
112 # if (target) equals (string) then set T=i and break else decrease s and retry
113 <<[->>+>>-<<<<]>>[-<<+>>]>+>[<++++[->++++<]>[-]]<
114 % T X 0 0 0 (target) 0 s i 0 *e 0 0 (string) 0 (where e=(S==s ? 1 : 0))
115 [-
116 <+<<<<[<]>
117 % T X 0 0 0 *(target) 0 s i 1 0 0 0 (string) 0
118 [
119 % T X 0 (target) 0 0 *(F target) 0 s i c 0 (1sled) 0 0 (G string) 0
120 % where c = (strings equal so far ? 1 : 0 ) and (1sled) is a (initially empty)
121 % sequence of cells holding 1 and F/G first cells of respective block
122 [-<+<+>>]<[>>[>]>>>>>[>]>+>[<-]<[<]>[-<<[<]<[-]<<<<[<]<[-]+>>[>]>>>>>[>]>>+<]>-<<<[<]<<<<<[<]<-]
123 % T X 0 (target F) *0 0 (target) 0 s i c 0 (1sled) 0 0 sub(G F) (string) 0
124 >>[>]>>>>>[>]>>[[-]<<<[<]<[-]>>[>]>>]<<+[<]<<<<<[<]>
125 % T X 0 (target F) 0 0 *(target) 0 s i c 0 (1sled) 1 0 0 (string)
126 ]
127 % T X 0 (target) 0 0 *0 s i c 0 (1sled) 0
128 <<<[[->>+<<]<]>>>[>]>>>>>[>]<[-<]<
129 % T X 0 0 0 (target) 0 s i *c 0
130 # if c==1 then we have a match and write T=i and set i=1
131 [-<<<<[<]<<<<[-]>>>>>[>]>>[-<<<[<]<<<<+>>>>>[>]>>]+>]>
132 % T X 0 0 0 (target) 0 s i 0 *0
133 ]
134 # remove (string) if string lengths didn't match and then sub 1 from i
135 >>>[>]<[[-]<]<<
136 <<-]
137 % T X 0 0 0 (target) 0 s *0 0 0
138 <[-]<<[[-]<]<<<+[->>>>+<<<<]>>>>->>>
139 % T 0 0 0 0 X 0 0 *0
140 ]
141 % T 0 0 0 0 X 0 0 *0
142 <<<+[->>>>>>>+<<<<<<<]>>>>>>>-
143 % T 11(0) *X 0 0
144 ## Phase 2
145 ## Bytecode compilation
146 ##
147 % T 11(0) *X (where X is user input)
148 # if read char X is not EOF then enter main loop
149 +[[-<+>]>+<]>[-<<->>]<<
150 [
151 % T 8(0) (code) 0 0 *X (cells left of code ignored for a while hereafter)
152 # check if X is brainfuck
153 [->+>+<<]>[-<+>]++++++[->-------<]+>-
154 [-[-[-[--------------[--[<+++[->-----
155 --<]+>-[--[<->>+++++++[-<++++++++++++
156 +>]<++[-]]]]]]]]]<<
157 % (code) 0 0 *X isbf(X) 0 0
158 # if bf then add to bytecode
159 >[-
160 ++++++[-<------->]+<
161 % (code) 0 0 *sub(X 42) 1 0 0
162 [-[-[-[-[--------------[--[-----------------------------[
163 # CLOSING BRACKET
164 # if this closes OPEN SUB(1) or OPEN ADD(1) then overwrite with SET(0)
165 # else append CLOSE
166 --<<
167 +<<<<-------[>>>>-]>>>>[>>>>]<<<<<<<<+++++++>>>>
168 % (code) P i Q j *c 0 0 1 0 (where c = (P(i) == OPEN(0)))
169 [<<---[>>-]>>[>>]<<[->>>>+<<<<]+
170 << ++[>>-]>>[>>]<<[->>>>+<<<<]<<+>>>>>>
171 % (code) OPEN 0 Q j 0 0 0 1 *d (where d = (Q == ADD or Q == SUB))
172 [-<<<<+<-[>-]>[>]<<+>
173 % (code) OPEN 0 Q j *e 0 0 1 0 (where e = (j == 1) == overwrite SET(0))
174 [->>>-<<<<-<[-]<<++>>]>>>>]<<<<]>
175 % (code) 0 *0 0 f 0 (where f = 1 if append CLOSE)
176 >>[-<<<++++++++>>>>>]<<
177 % (code) CLOSE()/SET(0) 0 *0 0 0
178 ]
179 # OPENING BRACKET
180 # if previous op was SET(0) or CLOSE or if this is the first op
181 # then ignore this loop
182 >[-
183 % (code) 0 0 0 *0 0 0
184 +++<<<<<
185 [>>>>>-<<<<<[->>>+<<<]]>>>
186 --------[++++++++[-<+>]<-------->>>-<<]<
187 -[+++++++++[-<<+>>]<<--------->>>>>-<<<]<<+++++++++>>
188 +<[>-]>[>]<[->>>[-<+>]<<<]>>>[-]<<<+++++++>>
189 % (code) OPEN *c 0 0 0 (where c = (should this loop be ignored ? 1 : 0))
190 [[-]+>>>>>+<<<<<[
191 % (code) OPEN *1 0 0 0 L l
192 >>+<,[>-]>[>]<[-<<->>]+<+[>-]>[>]<[-<<->>]<-
193 % (code) OPEN c *X 0 0 L l (where c = (EOF reached ? 0 : 1) and X = byte read)
194 >+++++++++[-<---------->]+<-[>-]>[>]<[->>
195 { 16b inc >>>++++++++[-<++++++++>]<[->++++<]<
196 [->+>-<<]>+[-<+>]+>-[<->[-]]<[-<[-]<+>>]<< }
197 <<]+<--[>-]>[>]<[->>
198 { 16b dec >>+<[>-<[->>+<<]]>>[-<<+>>]<<->[-<+
199 <->++++++++[->++++++++<]>[-<++++>]<->]<< }
200 <<]+++++++++[-<++++++++++>]<++++[-]
201 >>>
202 { 16b iszero >>+<[>-]>[>]<<<[[->>>+<<<]>>[-]<<]>>>[-<<<+>>>]<<< }
203 # if Ll=0 then delete OPEN and set c=0 to break
204 >>[-<<<<<<[-]<<------->>>>>>]<<<<<<
205 ]]
206 % (code) *0 0 0 0 L l (where Ll is nonzero iff EOF occurred prematurely)
207 >>>>[-]>[-]<<<
208 % (code) 0 0 *0 0
209 ]<]
210 # MOVE RIGHT
211 # if previous op is RIGHT(i) and i is not 255 then overwrite with RIGHT(inc(i))
212 # else append RIGHT(1)
213 >[
214 -<<<<<[->>+>+<<<]>>[-<<+>>]<[->+>>+<<<]>[-<+>]
215 % (code) *0 P i 0 (where P(i) = previous op)
216 ++++++++++++++++[->>----------------<<]>>+
217 [<<++++++++++++++++[->>++++++++++++++++<<]+>>[-]]<------[<[-]>++++++[-]]
218 <[->>+<<]++++++>+>[-<-<------<+>]>>
219 ]<
220 % (code) RIGHT(?) 0 *0 0 0
221 ]
222 # MOVE LEFT
223 # if previous op is LEFT(i) and i is not 255 then overwrite with LEFT(inc(i))
224 # else append LEFT(1)
225 >[
226 -<<<<<[->>+>+<<<]>>[-<<+>>]<[->+>>+<<<]>[-<+>]
227 % (code) *0 P i 0 (where P(i) = previous op)
228 ++++++++++++++++[->>----------------<<]>>+
229 [<<++++++++++++++++[->>++++++++++++++++<<]+>>[-]]<-----[<[-]>+++++[-]]
230 <[->>+<<]+++++>+>[-<-<-----<+>]>>
231 ]<
232 % (code) LEFT(?) 0 *0 0 0
233 ]
234 # OUTPUT
235 >[
236 <<<++++>>>->
237 ]<
238 % (code) OUTPUT 0 *0 0 0
239 ]
240 # SUB
241 #if previous op is SUB(i)
242 # if i is 255 then remove previous op
243 # else overwrite with SUB(inc(i))
244 #else append SUB(1)
245 >[
246 -<<<<<[->>+>+<<<]>>[-<<+>>]<[->+>>+<<<]>[-<+>]
247 % (code) *0 P i 0 (where P(i) = previous op)
248 >---[<+++>+++[-]+>[-]>]>
249 [<++++++++++++++++[->----------------<]>+>+<
250 [<<<+>>++++++++++++++++[->++++++++++++++++<]>[-]>-<]
251 >[-<<<<[-]<--->>>]<]
252 ]<
253 % (code) SET/SUB(?) 0 *0 0 0
254 ]
255 # INPUT
256 >[
257 <<<++>>>->
258 ]<
259 % (code) INPUT 0 *0 0 0
260 ]
261 # ADD
262 #if previous op is ADD(i)
263 # if i is 255 then remove previous op
264 # else overwrite with ADD(inc(i))
265 #else append ADD(1)
266 >[
267 -<<<<<[->>+>+<<<]>>[-<<+>>]<[->+>>+<<<]>[-<+>]
268 % (code) *0 P i 0 (where P(i) = previous op)
269 >-[<+>+[-]+>[-]>]>
270 [<++++++++++++++++[->----------------<]>+>+<
271 [<<<+>>++++++++++++++++[->++++++++++++++++<]>[-]>-<]
272 >[-<<<<[-]<->>>]<]
273 ]<
274 % (code) ADD(?) 0 *0 0 0
275 ]
276 # Cancellation
277 % (code P i Q j) 0 *0 (where P(i) and Q(j) are the two most recent ops)
278 # if P/Q in (LEFT/RIGHT RIGHT/LEFT ADD/SUB SUB/ADD) and j == 1
279 # remove Q(j) and decrement i
280 # if dec(i) == 0 then remove P(i)
281 >>+<<<+<-[>-]>[>]<<+>[
282 # j == 1
283 % P i Q 1 *1 0 0 1
284 <<<[>>-]>>[>>]<<[->-<]+>[-
285 # i != 0
286 <-<[->+<<<+>>]
287 % add(P Q) i *0 Q 0 0 0 1
288 +<<----[>>-]>>[>>]<<[->>>+<<<]+<<-------[>>-]>>[>>]<<[->>>+<<<]
289 >[-<+<<->>>]+<<<+++++++++++>>>>>
290 % P i Q 1 0 *c 0 1 (where c = add(P Q) in (add(LEFT RIGHT) add(ADD SUB)))
291 [->>-<<<<-<[-]+<-[>-]>[>]<[-<<[-]]>]<]]>>>
292 % (code) 0 0 0 *z (where z = 1 if we should attempt further optimizations)
293 #if P in (ADD SUB) and Q == SET then remove P
294 [>+<-<<<+<<---------[>>-]>>[>>]<<[
295 # Q == SET
296 >>>>-<<<<
297 -<<+<<-[>>-]>>[>>]<<[->>>+<<<]+<<--[>>-]>>[>>]<<[->>>+<<<]<<+++>>>>>
298 % P i 0 j 0 *c 0 0 0 (where c = P in (ADD SUB))
299 [-<<<<<[-]>[-]>>[-<<+>>]]<]<<+++++++++>>>>>]
300 % (code) 0 0 0 *0 z (where z = 1 if we should attempt further optimizations)
301 # if P == SET and Q(j) in (ADD(1) SUB(1)) then inc/dec i and remove Q(j)
302 +>[-
303 <<<<+<<<<---------[>>>>-]>>>>[>>>>]<<<<<<<<+++++++++>>>>[
304 # P == SET
305 % 9 i Q j *1 0 0 1 0
306 <-[>-]>[>]<<+>[
307 # j == 1
308 <<-[>>-]>>[>>]<<<<+>>[-
309 # Q == ADD
310 >>>-<<<<-<<<+++++++[->----------------<]>+[>-]>[>]+<[->-<]>
311 [-<++++++++++++++++[-<++++++++++++++++>]>]
312 <<<+++++++++>>]
313 +<<---[>>-]>>[>>]<<<<+++>>[-
314 # Q == SUB
315 >>>-<<<<-<--
316 <[>-]>[>]<[+++++++++++++++[-<++++++++++++++++>]]<->
317 ]]]>>>>]<
318 % (code) 0 0 0 *z 0 (where z = 1 if we should attempt further optimizations)
319 # if P == CLOSE then try the copy loop optimization
320 [
321 -<<<+<<--------[>>-]>>[>>]<<<<++++++++>>[# P == CLOSE
322 ->>>>>>>++++++++<<++++++++[-<++++++++++++++++>]<-[-<+<+>>]
323 <<<<<+<-------
324 % (code) Q j *1 1 0 0 128 128 *0 0 0 P
325 <<[>>-]>>[>>]<<[->-<]>[-<+>]<
326 [ # determine if loop can be optimized
327 % (code) *k 0 0 0 l r a 0 0 (code)
328 % where k = 1 iff next op should be inspected
329 % l = sub(127 num_left)
330 % r = sub(127 num_right)
331 % a = 1 iff SUB(1) on cell 0 processed
332 <<-[>>-]>>[>>]<<[# P == ADD
333 >>>>[->->>+<<<]+>[<-]<[<]>[ # l == r: kill l ->>>[-<<+>>]<<<]
334 >>>[-<<+<+>>>]<<<<<<+<-]+
335 <<--[>>-]>>[>>]<<[# P == SUB
336 >>>>[->->>+<<<]+>[<-]<[<]>[ # l == r
337 >>[<<-]<<[<<]>+>[-<<<<<-[>-]>[>]<<+>[->>>->>>+<<<<<<]+>>>>]
338 <[->>>>[-<<+>>]<<<<]>]
339 >>>[-<<+<+>>>]<<<<<<+<-]+
340 <<--[>>-]>>[>>]<<[# P == LEFT
341 -<[->+>>>+>-[<-]<[<]>[-<<<<[->+<]>>>>]<<<<]>[-<+>]>+<]+
342 <<-[>>-]>>[>>]<<[ # P == RIGHT
343 -<[->+>>>+>>-[<<-]<<[<<]>>[-<<<<[->+<]>>>>]<<<<]>[-<+>]>+<]
344 % (code) sub(P 6) i *0 q 0 0 l r a 0 0 (code) 0
345 % where q = P in (ADD SUB LEFT RIGHT)
346 # keep going if q==1 && l!=0 && r!=0 && next op exists
347 <[->>>>>>>>>+<<<<<<<<<]<++++++[->>>>>>>>>+<<<<<<<<<]
348 +<<[>>->>>+<<<]>>[>>]<<[-]>>>>>>
349 [[-<<+>>]>[[-<<+>>]<<<<+>>>>]<]>[-<<+>>]>[-<<+>>]<<<<<
350 ---[<<<->>>+++[-]]<<<+
351 % (code) *k 0 0 0 l r a 0 0 P i (code)
352 ]
353 >>>>>>>>+>-------[<-]<[<]>>+++++++
354 <<<[->>+<<]+<<[-<+>>-<]>[>-]>[>]<[->>+<<]>+>---[<-]<[<]>>+++[-]
355 <<<<<[->>+<<]>>[-]>+>
356 % (code) 0 0 0 0 0 0 1 *w 0 (loop)
357 % where w = 1 iff copy loop optimization can be applied
358 [<->->>[-]>[-]<<<<<<<<<+>+>+>+>+>>>>>>
359 [ # replace loop with LMUL/RMUL
360 % (code) 0 1 ::: 1 0 0 n d 0 *P i (loop)
361 % where d = offset to current cell
362 % n = 1 iff offset is negative
363 <+>-[--[--[-[++++++[-]<->]<[ # RIGHT(i)
364 ->>[<<+<[>-]>[>]<[-<<[-]>>]<+>>>-]<<
365 ]>]<[ # LEFT(i)
366 ->>[<<+<[>-]>[>]<[-<<[-]+>>]<->>>-]<<
367 ]>]<[ # SUB(i)
368 % (code) 0 1 ::: 1 0 0 n d *1 0 i (loop)
369 <[>-]>[>]+<[->-<]>[ # d != 0
370 +++++++++++++++[-<<<<++++++++++++++++>>>>]>[-<<<<<->>>>>]<]<
371 % (code) 0 1 ::: 1 0 sub(256 i) n d *0 0 0 (loop)
372 ]>]<[ # ADD(i)
373 % (code) 0 1 ::: 1 0 0 n d *1 0 i (loop)
374 <[>-]>[>]+<[->-<]>[ # d != 0
375 ->[-<<<<<+>>>>>]<]<
376 % (code) 0 1 ::: 1 0 i n d *0 0 0 (loop)
377 ]
378 % (code) 0 1 ::: 1 0 y n d *0 0 i (loop)
379 % where y!=0 iff MUL op should be appended to code
380 % and y is the second op argument
381 <<<[ # y!=0
382 <+>>[ # n=1 so d negative
383 <<-<[<]++++++++++>->++++++++++>->->[>]
384 >>>[+<<<<[<]<<<+>>>>[>]>>>>>-<<]>+<<-]
385 <<[ # n=0 so d positive
386 -<[<]++++++++++++>->++++++++++++>->->[>]
387 >>>[->>+<<<<<<[<]<<<+>>>>[>]>>>]
388 <<<]
389 >[-<<[<]<+>>[>]>]
390 % (code) LMUL/RMUL y 0 1 ::: 1 0 *0 0 0 n d 0? (loop)
391 ]
392 % (code) 0 1 ::: 1 0 *0 n d 0 0 i (loop)
393 >[>[+>>-<<]>+<<-]>[->>+<<]
394 <<+<+>>>>>>>
395 % (code) 0 1 ::: 1 0 0 n d 0 *(loop)
396 ]
397 % (code) 0 1 ::: 1 0 0 n 0 0 *0
398 <<<[-]<<<[-<]+++++++++>>>>>>>>>
399 % (code) SET(0) 0 0 0 0 0 0 0 *0
400 ]
401 % (code) 0 0 0 0 0 0 v *0 0 (loop)
402 % where v = 1 iff copy loop optimization was not applied
403 <[->>>[[-<<<<<<<<<+>>>>>>>>>]>[-<<<<<<<<<+>>>>>>>>>]>]
404 <<<]<<<<<<
405 ]>>>
406 % (code) 0 0 0 *0 0
407 ]
408 ]
409 % 8(0) (code) 0 0 X *0 (where X may be the last byte read)
410 # read next byte and and break if EOF
411 <[-]>
412 ,+[[-<+>]>+<]>[-<<->>]<<
413 ]
414 <<<<[<<]
415 % 6(0) *0 0 (code)
416 ## Phase 3
417 ## Code verification
418 ##
419 # move code leftwards and ensure that all OPEN/CLOSE are balanced
420 # in the process we calculate the maximum loop (ie OPEN/CLOSE) depth
421 % 6(0) *0 0 (code)
422 <+<<+>>>>>[
423 % 0 0 (code) M m D d 0 0 *P p (code) 0 c
424 % where Pp is first op of right code block
425 % Dd holds current loop depth (starting at 1)
426 % Mm holds the max loop depth yet encountered
427 % c = (unbalanced code ? 1 : 0)
428 <<<[->>+<<]<[->>+<<]<[->>+<<]<[->>+<<]>>>>>>>[-<<<<<<+>>>>>>]<
429 [->+<<<<<<<+>>>>>>]+>
430 % 0 0 (code) P p M m D d 1 *P (code) 0 c
431 -------[-[<->++++++++[-]]
432 <[-<<
433 # P is CLOSE; decrease Dd and leave Mm as it was
434 { 16b dec >>+<[>-<[->>+<<]]>>[-<<+>>]<<->[-<+<->++++++
435 ++[->++++++++<]>[-<++++>]<->]<< }
436 >>]>]
437 <[
438 # P is OPEN; if Mm==Dd then Mm=Dd=inc(Dd) else Dd=inc(Dd)
439 % (code) P p M m D d *1 0 (code) 0 c (note: p=0 since P=OPEN)
440 <<[-<<->>>>>+<<<]<<[[->>+<<]>>>>-<<<<]
441 % (code) P p *0 m sub(M D) d e D (code) 0 c (where e=(M==D ? 1 : 0))
442 >>>[-<<-<+>>>]<<[[->>+<<]>>>[-]<<<]
443 % (code) P p d *0 sub(M D) sub(m d) e D (code) 0 c (where e=(Mm==Dd ? 1 : 0))
444 >>[-<<+>>]<<<[->+>>+<<<]>>[-<<+>>]>>>[-<<<+<<+>>>>>]<[-<<<<<+>>>>>]<<
445 % (code) P e M m *D d 0 0 (code) 0 c (where e = (Mm==Dd ? 1 : 0))
446 { 16b inc >>>++++++++[-<++++++++>]<[->++++<]<[->+>-<<]
447 >+[-<+>]+>-[<->[-]]<[-<[-]<+>>]<< }
448 <<<[->[-]>[-]>[-<+<+>>]<[->+<]>>[->+<<<+>>]>[-<+>]<<<<<]>>>>>
449 ]
450 % 0 0 (code P p) M m D d *0 0 (code) 0 c (where Dd is properly updated)
451 << { 16b iszero [[->>+<<]>>>+<<<]>>[-<<+>>]<[[->+<]>>+<<]>[-<+>]+>[<->[-]]<<< }
452 >>[-<+>>>[>>]>[-]+<<<[<<]]>>
453 % 0 0 (code P p) M m D d 0 0 *(code) 0 c (where c is properly updated)
454 ]
455 % 0 0 (code) M m D d 0 0 *0 c
456 <<<<
457 { 16b dec >>+<[>-<[->>+<<]]>>[-<<+>>]<<->[-<+<->++++++
458 ++[->++++++++<]>[-<++++>]<->]<< }
459 { 16b isnonzero >[>>+<]>[<]<<[[->>+<<]>>>+<<<]>>[-<<+>>]>[[-]<+>]<<< }
460 >>[->>>[-]+<<<]<[-]<[-]<[->+<]<[->+<]>>>>>>>[-<<<<+>>>>]<<<<
461 <<<<<[<<]>+>[>>]>>>
462 % 0 1 (code) 0 M m *c 0 0 0
463 # if c==1 output string "Error: unbalanced brackets!\n"
464 [-<[-]<[-]<<<[<<]>->[>>]
465 +++++++++++[->++++++>++++++++++>+++<<<]>
466 % (code) 0 *66 110 33
467 +++.>++++..---.+++.<-----------.>>-.<+++.-------.
468 ------------.-.+++++++++++.-----------.+++++++++++++.
469 -----------.++.-.>.<--.++++++++++++++++.-----------------.
470 ++.++++++++.------.+++++++++++++++.-.>+.---[--->+<]>.[-]<<[-]<[-]>>>]
471 <<<<<[<<]
472 % T *0 b (code) 0 M m
473 % where b = (bytecode OK ? 1 : 0) and Mm = maximum loop depth
474
475 # This is the Java language backend for awib
476 # Please refer to the documentation in the full source code distribution
477 # of awib for additional details
478 % 23(0) *8 (code) 0 M m
479 # print Java header
480 ++[-<++++++++<++++++++<++++++++++<++++++++++<+++<++++++++++<++++++++++<+
481 +++++++++<+++<++++++<++<+++++++++++>>>>>>>>>>>>]<<<+++++.++++.+++.-.+++.
482 ++.<<++.>++++++.<<---.>>>++.<<<.>++++++++++++++.>-.++++++.<.>>>-------.<
483 <-.++.>-.-.>>+++.<<.--.<<<<+.>.>>---.<<<<<<-.<----------.<-----.++++.+++
484 .-.+++.++.>>>++.>>+++++.>.>>>++++.<<<.>.<<-.>>>++.<.>>>>----.<<-.-.<+.>+
485 .-.>>++++.<<.--.<<<<<+.>>.>>---.<<<<<<.<.>>>>.>>>.>--.-.+++.++.<<<<<<.>>
486 +.>.>>>++.<<<.>.<<-.>>>++.<.>>>.>----.<----.<++.<<<++.++.>>+.++++.<<<.++
487 ++++.-.<<<.<..<----.+++++.>>>>---.>--.---.<+.<.>.>+++.<--.>>>>-..<<<<<.<
488 +++++++.>>>>+.<<<.>>>>>>+++.<<<<<<<<.>>....>+.>>>>>--.<+.<<-.<<-------.+
489 +.<.>>+.<<<-------.<.>>....>>----.+++++.>>>.<<<<<.>>++.<<<.<.>>....>>>>>
490 >>++++.<<<<<--.++.>>>+.-.>>>++++.<<<.--.<<.----.<---.<<.>>----.<<<.<.>>.
491 ...>>>>>>>>----.<<----.-.<--.>+.-.>>++++.<<.--.<<<++++.----.>>---.<<<<<.
492 >>>>>++.<<<<<<.<..>>....>>>>>+.>+++.<<<+.<+++.---.>+.<<<.<+++++++.>>>---
493 .>>------.>>>.<<--.++.>.-.>>.<<.--.<<<++.----.>>---.<<<<<.>>+++.>>++++.<
494 <<<.>>>>>>>>----.<<+++.-.----.+++++.-.>>++++.<<.--.<<<++++.----.>>.<<<<<
495 .>>>>>++.<---.<<<<.<<<++++++.>.>>........>>++++.<<<-----.>>>+.>++++.>>>+
496 ++++.<<<<<<.>>>---.>>>++.-----.<<<+++.<<--.>>>+++++++.>>++++.<<+.-.+.-..
497 <<<++.<<--.<.>>........>>++.<<<++.>>>>>+.+.+++++.++++.<<<<<<.>>........>
498 >++++.>+++.+.<-.>>-------------.<.<<<<.>>>>.<<<<--.<.>>........>>+.>-.+.
499 <-.>>.>.<<<<<<++.>>>>>>.<<<<<<--.<.>>....<<<++.>..>>....>>---.+++++.<+++
500 ++.>>+++.---.<<+.<.>>+.>>>.<<.<<+.<.>>----.+++.>>>-.<<<<<.++++++++.+.---
501 ------.<<<--.>.>>........>>-.>-.+.<-.>>.<<<-----.>>>++.--------.+.<<<<<.
502 <.>>....<<<++.>..>>....>>---.+++++.<+++.>>+++.---.<<+.<.>>--.+.<--.>.>.<
503 <++.<.>>++.>>>+.<<.<<+.<.>>>>>--.<<<<---.>>.>>+.<-.>>>>.<<----.--.<<<.>>
504 .<<--.<<------.++.<.>++++.>>>>>.<<<.>>>+.<<+.<<<<.<<<--.>.>>........>>>>
505 >.<<--.<+.<<.<+++++++.>>>>+.>-.>>>>.<<++++++.------.+.<<<-.>>-.<++++++.>
506 ----.+++++.<--.>>>>.<<+++++.------.+.<<<.>>-.<++.>++.>+.-.<<-----.+++++.
507 >>--.+++.<-.<------.+.<<<<<-------.<.>>....<<<++.>..>>....>>>>>++.++.<<+
508 +++.<-.<.>--.>----.<<<.>>++.>>>---.------.<<-.<<<.>>----.>>-.+.<<<<.<<<-
509 -.>.>>........>>++.--.+++++++.<<.<<<.>.>>............>>>>>.<+++++.>>---.
510 <<<+.<<.>>-.>------.>++++.<++++.>>--.<<.+++++.--------.<<<<<.<.>>.......
511 .<<<++.>>>.>++.--.>-----.>-.+++++.<<<.>>>>-.>>>.>----.<----.<++++++++.<<
512 <<<++.++.>----.++++.>+.>>++.-.<<<<<.>.>>>+.<<<<.<<<--.++.>.>>....<<<.>..
513 >>....>>----.++.>.>>>--.<<<<<----.>++.>----.<<<.>>++.>>>+.------.<<-.<<<
514 .>>+.>>-.+.<<<<.<<<--.>.>>........>>---.--.>>>>+++.<<<<<<.<<<.>.>>......
515 ......>>---.>>+++++.>>--.-----.<.>++.<<<+.>------.<<--.<------.>+++.<++.
516 >>>+.<<<<<.<.>>............>>-.>>+++++.<+.<---.>>>>+.--.<-.<------.+.<<<
517 <<.<.>>........<<<++.>>>.>>>---.--.>>>+.<<<++.>>.<<<<<.>>>>-.>>>++++.>.<
518 ----.<++++.<<<.++.<++++.++++.>>>+.++++++.-.<<<<<.>>>.>+.<<<<.<<<--.++.>.
519 >>....<<<.>..>>....>>----.++.>++++.>>>--.<<<<<++++.>++.>----.<<<.>>++.>>
520 >+.------.<<-.<<<.>--.>>>+++++++.--------.+.<<<<.<<<--.>.[<]>[[-]>]
521 % 23(0) *0 (code) 0 M m
522 ++++++++++++++++[-<++++++++++++++++>]<-[-<<<<<<<<<<<<<<<+<+>>>>>>>>>>>>>>>>]
523 <<<<<<<<<<<<<<<<<<+<+>>>>>>>>>>>>>>>>>>>>
524 % 4(0) 1 0 255 255 15(0) *0 (code) 0 M m
525 >[<+>
526 % ::: (stack) 0 1:::1 0 c d 15(0) 1 *P i (code) 0 M m
527 % (where c and d form a two cell counter
528 % P(i) is the next op code)
529 # the stack segment is a sequence of adjacent C and D; these values
530 # are previous values of the cd counter that have been pushed to stack
531 # on OPEN; they are in turn popped on CLOSE
532 -[-[-[-[-[-[-[-[-[-[-[-[[-]
533 <[
534 # RMUL2
535 % ::: (stack) 0 1:::1 0 c d 15(0) *1 0 i (code) 0 M m
536 +++++[->+++++++++++++++<]>+++.-[--<+>]<---.-[-->+++<]>--.------[-<++>]<-.-
537 -----------------.+[---->+++++<]>---.+++[-----<++++>]<+.-[-->+<]>----.[-]
538 <<<+<<+>>>>
539 % ::: (stack) 0 1:::1 0 c d 11(0) 1 0 1 0 *0 0 i (code) 0 M m
540 ]>]
541 <[
542 # RMUL1
543 % ::: (stack) 0 1:::1 0 c d 15(0) *1 0 i (code) 0 M m
544 ++++++++.---[->++++++++++++++++++<]>+.------------------.+[----<+++++>]<---.
545 --[----->++<]>-.[-]<<<+>>
546 % ::: (stack) 0 1:::1 0 c d 11(0) 0 0 1 0 *0 0 i (code) 0 M m
547 ]>]
548 <[
549 # LMUL2
550 % ::: (stack) 0 1:::1 0 c d 15(0) *1 0 i (code) 0 M m
551 +++++[->+++++++++++++++<]>+++.-[--<+>]<---.-[-->+++<]>--.------[-<++>]<-.-
552 -----------------.+[---->+++++<]>---.+++[-----<++++>]<+.-[-->+<]>----.[-]
553 <<<+<<+>>>>
554 % ::: (stack) 0 1:::1 0 c d 11(0) 1 0 1 0 *0 0 i (code) 0 M m
555 ]>]
556 <[
557 # LMUL1
558 % ::: (stack) 0 1:::1 0 c d 15(0) *1 0 i (code) 0 M m
559 ++++++++.---[->++++++++++++++++++<]>+.------------------.+[----<+++++>]<---.
560 --[----->++<]>+.[-]<
561 <<+>>
562 % ::: (stack) 0 1:::1 0 c d 11(0) 0 0 1 0 *0 0 i (code) 0 M m
563 ]>]
564 <[
565 # SET
566 % ::: (stack) 0 1:::1 0 c d 15(0) *1 0 i (code) 0 M m
567 ++++[->++++++<]>[-<++++<+++<+<++>>>>]<-----------.<+.>+++.<++.
568 <<+.>++++++++++.>+++++.>+++++++++.-----.<+++.<+.>>[[-]<]+>>+>>
569 % ::: (stack) 0 1:::1 0 c d 11(0) 1 0 1 0 *0 0 i (code) 0 M m
570 ]>]
571 <[-
572 # CLOSE
573 % ::: (stack) 0 1:::1 0 c d 15(0) *0 0 0 (code) 0 M m
574 # output: ' }\n\n private void '
575 +++++++++++++++++++++++++[-<+<+++++<++++<++<+++>>>>>]<+++++++....<.
576 >>++++++++++..<....<-------------.++.<+++++.>++++.<--------.>--.<++++
577 .>>.<++.-------.<++++.-----.>>.>[[-]<]<<<<<<<<<<<<
578 % ::: (stack) 0 1:::1 *0 c d 15(0) 0 0 0 (code) 0 M m
579 # fetch xy from top of stack
580 <[<]<[->>[>]>>>>+<<<<<[<]<]<[->>>[>]>>>>>+<<<<<<[<]<<]>+>+[>]
581 % ::: (stack) 0 1:::1 *0 c d 0 y x 12(0) 0 0 0 (code) 0 M m
582 # output: '_x_y'
583 >>>>>[
584 >++++++++[->++++++++++++<]>-.[-]
585 # itoa
586 ++++++++++<<[->>->+<[>-]>[>]<[-<++++++++++<+>>]<<<]++++++++++>>[-<<->>]
587 >++++++++++<<[->>->+<[>-]>[>]<[-<++++++++++<+>>]<<<]++++++++++>>[-<<->>]
588 >++++++[-<++++++++>]<<[>[-<+<+>>]<.[-]<.[-]>]
589 <[>>[-<<+>>]<<.[-]]>>[-]<<++++++[-<++++++++>]<.[-]<
590 ]
591 % ::: (stack) 0 1:::1 0 c d *0 14(0) 0 0 0 (code) 0 M m
592 # output: '() {'
593 +++++++++++++++++++++++++++++++++++++++++[->+++>+>++<<<]
594 >>-.+.---------.<.<++++++++++.[[-]>]>>>>>>>>>>>
595 % ::: (stack) 0 1:::1 0 c d 15(0) *0 0 0 (code) 0 M m
596 ]>]
597 <[-
598 # OPEN
599 % ::: (stack) 0 1:::1 0 c d 15(0) *0 0 0 (code) 0 M m
600 # build ef = dec(cd)
601 <<<<<<<<<<<<<<<<[[->>+>>>>>>>>+<<<<<<<<<<]<]
602 >>>>>+<-[>-]>[>]<[+++++++++++++++[-<++++++++++++++++>]<-<->>]<
603 % ::: (stack) 0 1:::1 0 0 0 e *f 6(0) c d 5(0) *0 0 0 (code) 0 M m
604 # push a copy of ef to stack
605 <<<<<[<]>->->[>]>>>
606 [-<<<<[<]<<+>>>[>]>>>>>>>>>+<<<<<<]>
607 [-<<<<<[<]<+>>[>]>>>>>>>>>>+<<<<<<]>>>>>>>>
608 % ::: (stack ef) 0 1:::1 9(0) e f c *d 5(0) 0 0 0 (code) 0 M m
609 # construct decimal representations of e f c and d
610 [
611 % 0 (counters) *n 5(0) 0 0 0
612 % (where n is the rightmost counter)
613 # itoa
614 % (counters) *n 5(0) 0 0 0
615 >>++++++++++<<[->>->+<[>-]>[>]<[-<++++++++++<+>>]<<<]++++++++++>>[-<<->>]
616 >++++++++++<<[->>->+<[>-]>[>]<[-<++++++++++<+>>]<<<]++++++++++>>[-<<->>]
617 >++++++[-<++++++++>]<<[>[-<+<+>>]<:[->>>>+<<<<]<:[->>>>>>+<<<<<<]>]
618 <[>>[-<<+>>]<<[->>>>>>+<<<<<<]]>>[-]<<++++++[-<++++++++>]<[->>>>>>>>+<<<<<<<<]
619 % (counters) *0 5(0) n2 n1 n0
620 % (where n2n1n0 is n in base 10
621 % ni is 0 if not significant)
622 # move down remaining counters to make room for next base 10 rep
623 <[<]>[[-<<+>>]>]<<<
624 ]
625 % ::: (stack) 0 1:::1 *0 8(0) e2 e1 e0 f2 f1 f0 c2 c1 c0 *d2 d1 d0 (code) 0 M m
626 # output: ' while(m{p}!=0){_'
627 # but with brackets instead of braces
628 ++++++++++++++++++++++++++++++[->++>+>++++>+++<<<<]>>++........>-.
629 ---------------.+.+++.-------.<++++++++.>++++++++.>+.<+++.>++.
630 <<-------.<+.-------------.-------.>>+++++++++++.>++.>
631 % 0 41 33 123 95 *0 0 0 0 e2 e1 e0 f2 f1 f0 c2 c1 c0 d2 d1 d0
632 # output: '_c_d();}'
633 # replace c and d with the corresponding decimal representation
634 >>>>>>>>>
635 >[.[-<<<<<<<<<+>>>>>>>>>]]>[.[-<<<<<<<<<+>>>>>>>>>]]>[.[-<<<<<<<<<+>>>>>>>>>]]
636 <<<<<<<<<<<<<.>>>>>>>>>>>>>
637 >[.[-<<<+>>>]]>[.[-<<<+>>>]]>[.[-<<<+>>>]]
638 <<<<<<<<<<<<<<<<<<<-.+.++++++++++++++++++.------------------>>++.
639 <<<++++++++++.>->-
640 % 10 40 *32 125 95 0 c2 c1 c0 e2 e1 e0 f2 f1 f0 d2 d1 d0 0 0 0
641 # output: ' _e_f();\n }\n\n private void _c_d'
642 # again with e f c and d replaced by their base 10 reps
643 ........>>.>>>>
644 >[.[->>>>>>>>>+<<<<<<<<<]]
645 >[.[->>>>>>>>>+<<<<<<<<<]]
646 >[.[->>>>>>>>>+<<<<<<<<<]]
647 <<<<<<<.>>>>>>>
648 >[.[-<<<+>>>]]
649 >[.[-<<<+>>>]]
650 >[.[-<<<+>>>]]
651 % 10 40 32 125 95 0 c2 c1 c0 f2 f1 f0 0 0 *0 d2 d1 d0 e2 e1 e0
652 <<<<<<<<<
653 <<<<.+.++++++++++++++++++.<.>>....>.<<<..>>....>-------------.++.---------.
654 +++++++++++++.>++.<--.>++++.<<.>++.-------.>++++.-----.<<.>>-----.<<<<
655 % *10 59 32 111 95 0 c2 c1 c0 f2 f1 f0 0 0 0 d2 d1 d0 e2 e1 e0
656 >>>>>
657 >[.[-]]>[.[-]]>[.[-]]
658 <<<<.>>>>>>>>>>
659 >[.[-]]>[.[-]]>[.[-]]
660 % 10 59 32 111 95 0 0 0 0 f2 f1 f0 0 0 0 0 0 *0 e2 e1 e0
661 # restore ef
662 >[[-<+>]++++++[-<-------->]]
663 >[[-<+>]++++++[-<-------->]]
664 >[[-<+>]++++++[-<-------->]]
665 <<[->++++++++++<]
666 <[->++++++++++[->++++++++++<]<]
667 <<<<<
668 <[[->+<]++++++[->--------<]]
669 <[[->+<]++++++[->--------<]]
670 <[[->+<]++++++[->--------<]]
671 >>[->++++++++++<]<[->++++++++++[->++++++++++<]<]
672 % 10 59 32 111 95 0 0 0 0 0 *0 0 f 0 0 0 0 0 0 e 0
673 # output: '() {'
674 # and move ef into position
675 <<<<<<<<++++++++.+.---------.>++++++++++++.<<<.
676 [[-]>]
677 >>>>>>>[-<<<<<<<<<<+>>>>>>>>>>]
678 >>>>>>>[-<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>]
679 % 0 e f 15(0) 0 *0 0
680 # leave behind gh = dec(dec(cd)) = dec(ef)
681 <<<<<<<<<<<<<<<<+<-[>-]>[>]<[+++++++++++++++[-<++++++++++++++++>]<-<->>]
682 >>>>>>>>>>>>>>>
683 % ::: (stack) 0 1:::1 0 g h 15(0) *0 0 0 (code) 0 M m
684 ]>]
685 <[
686 # RIGHT
687 % ::: (stack) 0 1:::1 0 c d 15(0) *1 0 i (code) 0 M m
688 ++++++++.---[->+++++++++++++++++++<]>--.--[-----<++>]<-.-[-->+++<]>--.[-]<
689 <<+<<+>>>>
690 % ::: (stack) 0 1:::1 0 c d 11(0) 1 0 1 0 *0 0 i (code) 0 M m
691 ]>]
692 <[
693 # LEFT
694 % ::: (stack) 0 1:::1 0 c d 15(0) *1 0 i (code) 0 M m
695 ++++++++.---[->+++++++++++++++++++<]>--.--[-----<++>]<+.[--->++++<]>+.[-]<
696 <<+<<+>>>>
697 % ::: (stack) 0 1:::1 0 c d 11(0) 1 0 1 0 *0 0 i (code) 0 M m
698 ]>]
699 <[
700 # OUTPUT
701 % ::: (stack) 0 1:::1 0 c d 15(0) *1 0 i (code) 0 M m
702 ++++++++.---[->++++++++++++++++++++<]>-.+[---<+>]<.+.[-]
703 <<<<+>>>>
704 % ::: (stack) 0 1:::1 0 c d 11(0) 1 0 0 0 *0 0 i (code) 0 M m
705 ]>]
706 <[
707 # SUB
708 % ::: (stack) 0 1:::1 0 c d 15(0) *1 0 i (code) 0 M m
709 ++++++++.---[->++++++++++++++++++<]>+.------------------.+[----<+++++>]<---.
710 +++[----->++++<]>+.-[--<+>]<-.[--->++++<]>+.[-]<
711 <<+<<+>>>>
712 % ::: (stack) 0 1:::1 0 c d 11(0) 1 0 1 0 *0 0 i (code) 0 M m
713 ]>]
714 <[
715 # INPUT
716 % ::: (stack) 0 1:::1 0 c d 15(0) *1 0 i (code) 0 M m
717 ++++++++.---[->+++++++++++++++++++<]>.[---<+>]<++.+.[-]
718 <<<<+>>>>
719 % ::: (stack) 0 1:::1 0 c d 11(0) 1 0 0 0 *0 0 i (code) 0 M m
720 ]>]
721 <[
722 # ADD
723 % ::: (stack) 0 1:::1 0 c d 15(0) *1 0 i (code) 0 M m
724 ++++++++.---[->++++++++++++++++++<]>+.------------------.+[----<+++++>]<---.
725 +++[----->++++<]>+.-[--<+>]<---.-[-->+++<]>--.[-]<
726 <<+<<+>>>>
727 % ::: (stack) 0 1:::1 0 c d 11(0) 1 0 1 0 *0 0 i (code) 0 M m
728 ]
729 # optionally append ; and/or itoa(i)
730 % ::: (stack) 0 1:::1 0 c d 11(0) b 0 a 0 *0 0 i (code) 0 M m
731 % (where a==1 iff i should be output
732 % b==1 iff ';\n' should be output)
733 <<[->>
734 % ::: b 0 0 0 *0 0 i (code) 0 M m
735 # itoa
736 ++++++++++>>[-<<-<+>[<-]<[<]>[->++++++++++>+<<]>>>]++++++++++<<[->>-<<]
737 <++++++++++>>[-<<-<+>[<-]<[<]>[->++++++++++>+<<]>>>]++++++++++<<[->>-<<]
738 <++++++[->++++++++<]>>[<[->+>+<<]>.[-]>.[-]<]
739 >[<<[->>+<<]>>.[-]]<<[-]>>++++++[->++++++++<]>.[-]
740 <<<<]
741 <<[+++++[->++++++++++<]>-.[-]++++++++++.[-]<]>>>>>>[-]
742 % ::: (stack) 0 1:::1 0 c d 15(0) 0 0 *0 (code) 0 M m
743 # copy up cd; extend the 1 sled; process next operation
744 <<<<<<<<<<<<<<<<<<[->>+<<]<[->>+<<]+<+>>>>>>>>>>>>>>>>>>>>
745 >]
746 % ::: 0 0 0 *0 M m
747 # footer
748 >[-]>[-]++++[->++++++++<]>....[->++++<]>---.>++++++++++.<.[-]>.[-]
749 % ::: 0 0 *0 0 0