-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Possible code generation bug shown by this code, when run, the program gets stuck in the inner drain loop.
// example:
// 3 3388833555666706 666777 330933 06444 4 448
// ouputs: DEVELOP MORE WE MIGHT
cell FIFTY = 50;
cell run_length = 0;
cell curr;
cell prev; input prev;
drain FIFTY {
while prev {
input curr;
run_length += 1;
cell[3] _prevs;
cell __prev;
drain prev into *_prevs __prev;
_prevs[0] -= curr;
drain _prevs[0] {
_prevs[0] = 0;
// different character to previous
// ignore if space
_prevs[1] -= ' ';
drain _prevs[1] {
_prevs[1] = 0;
// output space if digit 0
__prev -= '0';
if not __prev {
output ' ';
} else {
// calculate correct character to output
cell ch;
__prev -= 2;
cell shift_flag = 6;
drain __prev {
// gets stuck in this loop
output 0;
output 0;
output 0;
output 0;
output 0;
output 0;
output 0;
output 0;
output 0;
shift_flag -= 1;
ch += 4;
if shift_flag {
ch -= 1;
}
}
ch += 'A' - 1;
drain run_length into ch;
output ch;
}
}
run_length = 0;
}
drain curr into prev;
output '\n';
output '\n';
output '\n';
output '\n';
output '\n';
}
input prev;
output '\n';
}
BF program generated:
+++++[<++++++++++>-]>>,<<<
[
>>>
[
<,<+>>
[->+>+>+>+<<<<]<[->>->>>>+<<<<<<]
>>>>>>[<<<<<<+>>>>>>-]
<<<<[
[-]
>>>>++++[<<<-------->>>-]
<<<[
[-]
>>>++++++[<-------->-]
>+<<[->+>>+<<<]
>>>[<<<+>>>-]
<<[[-]>[-]
>>++++++<<<<--[
>>>>>.........<-<++++
>[->+>+<<]>>[<<+>>-]
<[[-]<<->>]
<<<<<-
]
>>>>>++++++++[<<++++++++>>-]<<<<<<<<<<<[->>>>>>>>>+<<<<<<<<<]
>>>>>>>>>.
>[-]<[-]<<
]
>[[-]>++++[<<++++++++>>-]
<<.[-]>
]
<<<<-
]
<<<<[-]>>>-
]
<<[->+<]
>>>>>>++++++++++.[-]++++++++++.[-]++++++++++.[-]++++++++++.[-]++++++++++.[-]
<<<[-]>[-]>[-]<<<<
]
,>++++++++++.
[-]<<<<-
]Reactions are currently unavailable