++++++++++++++++[->+++>+++>++++>++++>++++++>++++++<<<<<<]>----->--->---->-->----->--->+<<<.....<<.>>....<<.>>.<<..>...>>>>[>+>,->[-]++++[-<-------->]+<[>>]>[<<-<-<<<..>.<.....>>.<<<.....>>.<<<<.>>..>>.<<<.>>>>.<<<...>>>.<<.<<<..>>>>.<<<..>>.....<<<..>>>>>.<<<<<.>>>>.<<<.>.....<<.>>>>>.<<<<.>>..>>>>>>>>]<<<-------------[>>]>[<<-<<<<..<<.>..>>.<<<.>.<<.>>>....<<<.>>>>.<<<.>.....<<.>>>>>.<<<<<.>>>>.<<<..>>.....<<<..>>>>>.<<<<..>..<<.>>>..<<<.>>>>.<<<.>.....<<.>>>>>.<<<<.>.<<..>>>>.<<<..>>.....<<<..>>>>>.<<<<..>..>>>.<<<.>>.<<<.>>.<<<.>>.>>>.<<....<<<.>>>>.<<<.>.....<<.>>>>>.<<<<<.>>>>.<<<..>>.....<<<..>>>>>.<<.....<<.>>>.<<<.>.....<<.>>>>>.<<<<.>.<<..>>>>.<<<..>>.....<<<..>>>>>.<<<<.>..>>>>>>>>>]<<<--------------[>>]>[<<-<<<<<...>>.<<<<.>>>>>.<<<<.>..>>>>>>>>>]<<<--[>>]>[<<-<<<<.......>.<<<<.>>>>>.<<<<.>..>>>>>>>>>]<<<<[+++++++[->++++++++<]>--.<]<]>>,[<+>>++++[-<--------->]+<+[>>]>[<<-<<<.<<<.>>>>.<<..<<.>>.>.<.....>>.<<<<<.>>>>.<<<.>.....<<.>>>>>.<<<<.>>...>.<<<.>...>>.<<.....>>>.<<....<<<.>>>>.<<<.>>.....<<<.>>>>>.<<<<.>..<<.>>>...>.<.....>>.<<<<<.>>>>.<<<.>.....<<.>>>>>.<<<<.>>...>>.<<..<<.>>>.<<.....>>>.<<....<<<.>>>>.<<<.>>.....<<<.>>>>>.<<<..>>>>>>>>>]<<<----------------[>>]>[<<-<<<<<.....>>>>>>>>>]<<<--[>>]>[<<-<<<<.....>>>>>>>>]<<<<[+++++++[->++++++++<]>--.<]>,]
Try it online!
Here it is! The brainfuck code that composes two brainfuck codes. Use a "!" to separate the two input code snippets. For example snippet A: >,[>,]<[.<]
, snippet B: ,[...,]
. Input for my program: >,[>,]<[.<]!,[...,]
. It will not terminate if no "!" is found.
This does essentially the same as my VBA Version. The code that is generated is the same as in the VBA version (note that the examples in the VBA post were made before the latest change in the brainfuck snippets).
Explanation
This is my source code:
[
Tape: "+"(43) "-"(45) "<"(60) ">"(62) "["(91) "]"(93) readA(1) printInput(0) input else exitIf exitElse
]
++++ ++++ ++++ ++++ [->+++>+++>++++>++++>++++++>++++++<<<<<<]>----->--->---->-->----->--->+
<<<.....<<.>>....<<.>>.<<..>... print init routine
>>>>[ while readA
>+ set printInput = true
>, read character
->[-]++++[-<-------->] decrease input by 33 to check for "!"
+ set else flag
# A check for "!"
<[ if input not "!"
>> go to exitIf
]
>[ else
<<- set printInput = false
<- set readA = false
<<<..>.<.....>>.<<<.....>>.<<<< print routine between A and B
.>>..>>.<<<.>>>>.<<<...>>>.<<.<
<<..>>>>.<<<..>>.....<<<..>>>>>
.<<<<<.>>>>.<<<.>.....<<.>>>>>.
<<<<.>>..>>>
>>>>> go to exitElse
]
# A check for "dot"
<<<----- ----- --- decrease input by 13 (total 46) to check for dot
[ if input not dot
>> go to exitIf
]
>[ else
<<- set printInput = false
<<<<..<<.>..>>.<<<.>.<<.>>>.... print list storing routine
<<<.>>>>.<<<.>.....<<.>>>>>.<<<
<<.>>>>.<<<..>>.....<<<..>>>>>.
<<<<..>..<<.>>>..<<<.>>>>.<<<.>
.....<<.>>>>>.<<<<.>.<<..>>>>.<
<<..>>.....<<<..>>>>>.<<<<..>..
>>>.<<<.>>.<<<.>>.<<<.>>.>>>.<<
....<<<.>>>>.<<<.>.....<<.>>>>>
.<<<<<.>>>>.<<<..>>.....<<<..>>
>>>.<<.....<<.>>>.<<<.>.....<<.
>>>>>.<<<<.>.<<..>>>>.<<<..>>..
...<<<..>>>>>.<<<<.>..>>>>>
>>>> go to exitElse
]
# A check for "less than"
<<<----- ----- ---- decrease input by 14 (total 60) to check for "less than"
[ if input not "less than"
>> go to exitIf
]
>[ else
<<- set printInput = false
<<<<<...>>.<<<<.>>>>>.<<<<.>..>>>>> print A move left routine
>>>> go to exitElse
]
# A check for "greater than"
<<<-- decrease input by 2 (total 62) to check for "greater than"
[ if input not "greater than"
>> go to exitIf
]
>[ else
<<- set printInput = false
<<<<.......>.<<<<.>>>>>.<<<<.>..>>>>> print A move right routine
>>>> go to exitElse
]
# print remaining character
<<<<[ if printInput
+++++++[->++++++++<]>--.< print original character
]
< go to readA
]
>>, read next character
[ while input
<+ set printInput = true
# B check for comma
>>++++[-<----- ---->]+<+ decrement input by 44 to check for comma
[ if input not comma
>> go to exitIf
]
>[ else
<<- set printInput = false
<<<.<<<.>>>>.<<..<<.>>.>.<..... print B list reading routine
>>.<<<<<.>>>>.<<<.>.....<<.>>>>
>.<<<<.>>...>.<<<.>...>>.<<....
.>>>.<<....<<<.>>>>.<<<.>>.....
<<<.>>>>>.<<<<.>..<<.>>>...>.<.
....>>.<<<<<.>>>>.<<<.>.....<<.
>>>>>.<<<<.>>...>>.<<..<<.>>>.<
<.....>>>.<<....<<<.>>>>.<<<.>>
.....<<<.>>>>>.<<<..>>>>>
>>>> go to exitElse
]
# B check for "less than"
<<<----- ----- ----- - decrease input by 16 (total 60) to check for "less than"
[ if input not "less than"
>> go to exitIf
]
>[ else
<<- set printInput = false
<<<<<.....>>>>> print B move left routine
>>>> go to exitElse
]
# B check for "greater than"
<<<-- decrease input by 2 (total 62) to check for "greater than"
[ if input not "greater than"
>> go to exitIf
]
>[ else
<<- set printInput = false
<<<<.....>>>> print B move right routine
>>>> go to exitElse
]
# print remaining character
<<<<[ if printInput
+++++++[->++++++++<]>--.< print original character
]
>, input next character
]