Search

vendredi 24 mars 2017

Unbounded integers

Context

After 16-bit integers, we can try to implement 32-bit, 64-bit, ... but the principles are the same.
Instead, let's define unbounded integer, in  other word one single integer that has no limit (in other words, an integer that can execute +[+] without never ending).
We will focus on one single integer, because it is far more simple. Actually, any implementation we can imagine will rely on arrays with dynamic sizes. The array can be resized, meaning that the data before and / or after will have to be moved. This is not impossible, but extending one array then means extend one array + move next integer + move integer after this one + move integer after this one + ...
This will be definitely too long (not impossible anyway), so let's just implement one single number like this.

The data structure:

  • A number N will be encoded in an array of cells
  • Encoding will be in base 255
    • Note: not 256. This allows to have values from 1 to 255. Therefore, there won't be any null cell, so no need to have a 2-cells array to browse it. This divides the memory used by 2.
  • Operator overrides will be defined below. However, we will need 2 different overrides for LEFT and RIGHT: one from the number N and one to number N.
  • Data representation:

memory_before [0 0 0 0 D1 D2 D3 .... Dx 0] memory_after
  • By default, cursor will be on first base-255 digit D1.

Process

  • Print: simply print D1. However, the values are between 1 and 255. So
    • Decrease D1
    • Print D1
    • Increase D1
  • Read: idem
    • Reset all digits (set to 1)
    • Read to D1
    • Increase D1
  • Inc:
    • Set loop flag.
    • Start with digit D1 and loop
      • if current digit is null, set to 1
      • increase current digit
      • move before loop flag
      • if not null, reset loop flag
      • otherwise, set to 1 (equivalent to null in our representation)
      • process next digit if loop flag is on
    • Move back values to their position
  • Dec: idem
    • Set loop flag
    • Start with digit D1 and loop
      • if current digit is null, set to 1
      • decrease current digit
      • move before loop flag
      • if not null, reset loop flag
      • otherwise, set to 255
      • process next digit if loop flag is on
    • Move back values to their position
  • While:
    • Our structure is [R 0 0 0 D1 D2 D3 .... Dx 0]
    • We want to check if at least one of the digits is not 1 and store into R
    • Set loop flag
    • Start with D1 and loop
      • Reset loop flag
      • if current digit is not null
        • Set loop flag
        • if digit is not 1 (decrease then while)
          • Set R to 1
          • Reset loop flag
          • Move digit before loop flag
        • increase moved digit to recover initial value (see 4 lines above)
      • process with next digit if loop flag is on
    • Move back values to their position
    • Move to result
    • If not null: enter while, reset result, go to D1
  • Loop
    • Same as while to compute result
    • Move to result
    • If not null: loop
    • Go back to D1
  • Left (from N)
    • 5 cells on the left
  • Left (to N). Note: with unbounded array, it is not recommended to have things after the array
    • 2 cells on left for last digit then go to D1
  • Right (to N)
    • 5 cells on the right
  • Right (from N). Note: again, with unbounded array, going after array in memory is not recommended
    • Go to last digit then 2 cells on the right

Code - print

-.+

Code - read

Go to last integer
[>]<
Set all digits to 1 up to first
[[-]+<]
Read value and increase
>,+

Code - inc

Set loop flag
<+
Loop
[
  Go to current digit
  >
  If current digit is null then initialize to 1
    reset loop flag as else bit
    [<-]
    go to else bit or 0 and if else bit then set digit to 1 and go to 0
    <[->+<<]
    go back to digit and reset loop flag
    >+>
  Increase current digit and move before loop flag
  +[-<<+>>]
  Go to current digit
  <<
  If not null reset loop flag and set to 1 otherwise
  [>-]>[<+>>]
  Move loop flag to left and go to loop flag then loop
  <[->+<]>
]
Go to last moved digit
<<
Move back all digits
[[->>+<<]<]>>>

Code - dec

Set loop flag
<+
Loop
[
  Go to current digit
  >
  If current is null then initialize to 1
    reset loop flag as else bit
    [<-]
    go to else bit or 0 and if else bit then set digit to 1 and go to 0
    <[->+<<]
    go back to digit and reset loop flag
    >+>
  Decrease current digit and move before loop flag
  -[-<<+>>]
  Go to current digit
  <<
  If not null reset loop flag and set to 255 otherwise
  [>-]>[<->>]
  Move loop flag to left and go to loop flag then loop
  <[->+<]>
]
Go to last moved digit
<<
Move back all digits
[[->>+<<]<]>>>

Code - while

Set loop flag
<+
Loop
[
  Reset loop flag and go to current digit
  ->
  If not null: still in the number
  [
    Set loop flat to 1
    <+
    If current digit is not 1
    >-[
      set result to 1
      <<<[<]<+
      reset loop flag
      >>[>]>-
      move digit before flag
      >[-<<+>>]
    ]
    Add 1 to digit copy and go back to location
    <<+>>
  ]
  Move loop flag
  <[->+<]
  Go to loop flag and loop
  >
]
Go to last moved digit (can be 2 or 3 cells on the left)
<<[>]<
Move back all digits
[[->>+<<]<]
Go to result and start while
<[
  Reset result and move back to first digit
  ->>>>

Code - loop

Set loop flag
<+
Loop
[
  Reset loop flag and go to current digit
  ->
  If not null: still in the number
  [
    Set loop flat to 1
    <+
    If current digit is not 1
    >-[
      set result to 1
      <<<[<]<+
      reset loop flag
      >>[>]>-
      move digit before flag
      >[-<<+>>]
    ]
    Add 1 to digit copy and go back to location
    <<+>>
  ]
  Move loop flag
  <[->+<]
  Go to loop flag and loop
  >
]
Go to last moved digit (can be 2 or 3 cells on the left)
<<[>]<
Move back all digits
[[->>+<<]<]
Go to result and loop if needed
<]
Move back to initial position
>>>>

Code - left from N

<<<<<

Code - left to N

<<[<]>

Code - right to N

>>>>>

Code - right from N

[>]>

Example - try it

This code is equivalent to +[.+] with unbounded integers

>>>>++<+[->[<+>-[<<<[<]<+>>[>]>->[-<<+>>]]<<+>>]<[->+<]>]<<[>]<[[->>+<<]<]<[->>>>-.+<+[>[<-]<[->+<<]>+>+[-<<+>>]<<[>-]>[<+>>]<[->+<]>]<<[[->>+<<]<]>>><+[->[<+>-[<<<[<]<+>>[>]>->[-<<+>>]]<<+>>]<[->+<]>]<<[>]<[[->>+<<]<]<]>>>>

mercredi 22 mars 2017

16-bit values: be smart (5)

Context

We now have conversion operators to handle 16-bit integers. We also created a piece of code to display 16-bit integers as decimal numbers.
The code was quite verbose however. Using those operators, one should really be careful regarding the "type" used. Do not use 16-bit integers when it's not needed.

Here, for example, we have


  • One integer N (16-bit)
  • divided by ten
    • divisor is always 10: 8-bit
    • remainder is always less than ten: 8-bit
    • quotient may be more than 256: 16-bit
    • else flag used by division: 8-bit
  • Take remainder and add 48 to have a char
    • 48 can be added using 6x8, all of them (including remainder) are always less than 256: 8-bit
  • Clear remaining part of divisor: 8-bit
  • Move quotient and start again: 16-bit
There is a huge place to improve code here.

The best way is probably to write BF instructions for 8-bit and plain text instructions for 16-bit, and finally replace plain text, to avoid mistakes.

Example:
WHILE
    RIGHT
    >>>++++++++++<<<
    LEFT
    WHILE
        MINUS
        RIGHT
        +>>+>-[-<]<[> RIGHT PLUS LEFT <-<<[->>>+<<<]>]<
        LEFT
    LOOP
    RIGHT
    <++++++[->++++++++<]>>>>[-]
......
LOOP
[.[-] <<< LEFT]

Then, replace WHILE, RIGHT, ... (and you can also remove all '< >' or '> <')

Minified code to print 2056 - 75% smaller - try it

>>>++++++++>++++++++[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<[[-]>>>>>>>>++++++++++<<<<<<[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<[[-]+>[<-]<[->>-<<<]>>->>>>+>>+>-[<-]<[->>>>>+<+>[<-]<[->>+<<<]><<<<<<[->>>+<<<]>]<<<<[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<]>>>>++++++[->++++++++<]>>>>[-]>>>>>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<[[-]+>[<-]<[->>-<<<]>>-<<<<+<+>[<-]<[->>+<<<]>>>>>>>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<]<<[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<]<<[.[-]<<<<<<<]

mardi 21 mars 2017

16-bit values: summary and application (4)

Context

Here is a summary of our structures, and operations implemented to handle the basic 8 ones

Structure 1 - "4 cells"

A, B, C, D to represent integer N; with
  • A = 0
  • B = 0
  • C and D so that N = D * 256 + C
Cursor on C

Structure 2 - "3 cells"

A, B, C to represent integer N; with
  • A and B so that N = B * 256 + A
  • C = 0
Cursor on A



Operation"4 cells""3 cells"
,(read) ,>[-]< ,>[-]<
.(print) . .
<(move left) <<<< <<<
>(move right) >>>> >>>
+(inc) +<+>[<-]<[->>+<<<]>> +[-<+>>>+<<]<[->+<]+>>>[[-]<<<->>>]<<<[->>+<<]>
-(dec) <+>[<-]<[->>-<<<]>>- [-<+>>>+<<]<[->+<]+>>>[[-]<<<->>>]<<<[->>-<<]>-
[(while) >[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<[[-]> >[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<[[-]>
](loop) >[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<]> >[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<]>

Application

Let's reuse our previous "decimal printing" algorithm, and replace each instruction by its new implementation, to print a large number (let's say 2056)

Code - 4 cells structure - try it

generate 2056 using 4 cells structure
>>>>>>++++++++>++++++++<
decimal print algorithm rewritten using instruction replacements
>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<[[-]>>>>>>>>>>>>>>>>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>><<<<<<<<<<<<<<<<>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<[[-]><+>[<-]<[->>-<<<]>>->>>>+<+>[<-]<[->>+<<<]>>>>>>>>>>+<+>[<-]<[->>+<<<]>>>>>><+>[<-]<[->>-<<<]>>->[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<[[-]><<<<<+>[<-]<[->>-<<<]>>->[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<]><<<<>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<[[-]><+>[<-]<[->>-<<<]>>->>>>>>>>+<+>[<-]<[->>+<<<]>><<<<<<<<<<<<<<<<>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<[[-]><+>[<-]<[->>-<<<]>>->>>>>>>>>>>>+<+>[<-]<[->>+<<<]>><<<<<<<<<<<<>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<]>>>>>>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<]><<<<<<<<>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<]>>>>>+<+>[<-]<[->>+<<<]>>>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<[[-]><+>[<-]<[->>-<<<]>>-<<<<+<+>[<-]<[->>+<<<]>>>>>>>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<]>>>>>>>>>>>>>>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<[[-]><+>[<-]<[->>-<<<]>>->[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<]>>>>>>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<[[-]><+>[<-]<[->>-<<<]>>-<<<<<<<<<<<<<<<<+<+>[<-]<[->>+<<<]>>>>>>>>>>>>>>>>>>>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<]><<<<<<<<<<<<<<<<>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<]><<<<>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<[[-]>>>>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<[[-]><<<<+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>+<+>[<-]<[->>+<<<]>>>>>><+>[<-]<[->>-<<<]>>->[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<]><<<<<+>[<-]<[->>-<<<]>>-.>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<[[-]><+>[<-]<[->>-<<<]>>->[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<]><<<<>[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<]>
Note: 3 cells version's code is about 50% longer, but it's also 3 times longer to execute...

16-bit values: jumps (3)

Context

Note: read first and second part .
As a reminder, we have 2 different structures, named "4 cells" and "3 cells" to represent 16-bit integers.
Let's now redefine instructions + and - on those 2 structures.

Structure 1 - "4 cells"

A, B, C, D to represent integer N; with
  • A = 0
  • B = 0
  • C and D so that N = D * 256 + C
Cursor on C

Structure 2 - "3 cells"

A, B, C to represent integer N; with
  • A and B so that N = B * 256 + A
  • C = 0
Cursor on A

We can see that these structures mean that we divided N by 256 and stored both quotient and remainder.

While [

What we need to do is to start execution of a piece of code if and only if at least one of {quotient, remainder} is not null.

Using 4 cells structure (reminder: like the 3 cells structure, we can leverage the next cell X, after D...)
  • If D is not null, move it to X and increase B
  • If C is not null, move it to D and increase B
  • Move D back to C and X back to D
  • Go to B. If not null, enter while (and reset B, and back to C to keep system consistent)
  • Note: if B is null, or after while, we'll have to move back to C as well
Using 3 cells structure (reminder: cell X before A is null as well, as it's the C from previous block, and same applies to Y cell in the next block):
  • If B is not null, move it to C and increase X
  • If A is not null, move it to B and increase X
  • Move B back to A and C back to B
  • Go to X. If not null, enter while (and reset X, and back to A to keep system consistent)
  • Note: if X is null, or after while, we'll have to move back to A as well
Note: actually, code is the same for both structures.

Loop ]

To loop (note: we are on the remainder, but loop started one cell before). We need to evaluate if both quotient and remainder are null or not as before, store the result at the exact same place than before, and loop if not null. Then

  • If not null, the current cell will be reset after looping, thanks to our previous reset at the beginning. And it can't be done before looping. Otherwise, there won't be any loop
  • If null, then there is nothing to reset, but let's just go back on remainder


Using 4 cells structure:
  • If D is not null, move it to X and increase B
  • If C is not null, move it to D and increase B
  • Move D back to C and X back to D
  • Go to B. If not null, loop (no reset needed, nor back to C, as it's done by while)
Using 3 cells structure:
  • If B is not null, move it to C and increase X
  • If A is not null, move it to B and increase X
  • Move B back to A and C back to B
  • Go to X. If not null, enter while (and reset X, and back to A to keep system consistent)
  • Note: if X is null, or after while, we'll have to move back to A as well
Note: again, code is the same for both structures.


Operation"4 cells""3 cells"
[(while) >[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<[[-]> >[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<[[-]>
](loop) >[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<]> >[[->+<]<<+>>]<[[->+<]<+>]>[-<+>]>[-<+>]<<<]>


16-bit values: add / remove 1 (2)

Context

Note: read first part here.
As a reminder, we have 2 different structures, named "4 cells" and "3 cells" to represent 16-bit integers.
Let's now redefine instructions + and - on those 2 structures.

Structure 1 - "4 cells"

A, B, C, D to represent integer N; with
  • A = 0
  • B = 0
  • C and D so that N = D * 256 + C
Cursor on C

Structure 2 - "3 cells"

A, B, C to represent integer N; with
  • A and B so that N = B * 256 + A
  • C = 0
Cursor on A

We can see that these structures mean that we divided N by 256 and stored both quotient and remainder.

Add

To add 1, we need to increase remainder. And if null (if remainder was equal to 255), we just need to update the quotient as well.

Using 4 cells structure:
  • Increment C and set else bit in B
  • If C is not null, reset else bit in B
  • Move left (in A if C is not null, or B otherwise)
  • If current is not null (so, on B, with C = 0), then reset B, increment D, and back to A
  • Current position is A in all cases, move back to C
Using 3 cells structure (reminder: cell X before A is null as well, as it's the C from previous block):
  • Increment A
  • Copy A to C (using cell X on the left to restore A)
  • Set X to 1
  • If C is not null, reset C and X (and back to C)
  • If X is not null (so C was null, so A was null), reset X and increase B (and back to X)
  • Current position is X, move back to A

Remove

To remove 1, we need to decrease remainder. But before that, if it is null, then decrease quotient as well.

Using 4 cells structure:
  • Set else bit in B
  • If C is not null, reset else bit in B
  • Move left (in A if C is not null, or B otherwise)
  • If current is not null (so, on B, with C = 0), then reset B, decrease D, and back to A
  • Current position is A in all cases, move back to C and decrease.
Using 3 cells structure:
  • Copy A to C (using cell X on the left to restore A)
  • Set X to 1
  • If C is not null, reset C and X (and back to C)
  • If X is not null (so C was null, so A was null), reset X and decrease B (and back to X)
  • Current position is X, move back to A and decrease

Operation"4 cells""3 cells"
+(inc) +<+>[<-]<[->>+<<<]>> +[-<+>>>+<<]<[->+<]+>>>[[-]<<<->>>]<<<[->>+<<]>
-(dec) <+>[<-]<[->>-<<<]>>- [-<+>>>+<<]<[->+<]+>>>[[-]<<<->>>]<<<[->>-<<]>-

As mentioned initially, the 4 cells structure implements new instructions in a more compact way (but uses more cells)

16-bit values: concept, structures, IO and moves (1)

Context

What may be annoying using Brainfuck is the size of the cell. You can't (in theory) have integers greater than 255. Of course, this is the case for most of the programming languages, where integers are encoded using either 32 or 64 bits, but the limit is far higher in those cases.
Obviously, the 'cheating' solution would be to use another BF interpreter implementation that supports 16-, 32- or 64-bit integers. But how to use, let's say, 16-bit integers (up to 65,535) using regular Brainfuck?
Our only option would be to

  1. Define a new data structure
  2. Re-define all the 8 operators using this new data structure
    What does '+' means ? Add 1. So, how to modify our data that represents an integer N to represents integer 'N+1' instead, and same for - , . < > [ ]

Structure(s)

Actually, I found 2 different data structures, one that uses more memory cells but with faster overrides of operators, and one using less cells but with longer processes.
Actually, both needs 4 cells, but when you have multiple integers in memory, first one uses 4 cells per integer, while second one can use only 3 cells (reusing a cell from previous integer)
In this post and all the coming ones, we'll define the 2 structures and all their operators.

Structure 1 - "4 cells"

Let's have 4 cells A, B, C, D to represent integer N; with
  • A = 0
  • B = 0
  • C and D so that N = D * 256 + C
A and B are used for logical branching that will occur in our future code.
Using this structure, "having on a value" means having cursor on C

Structure 2 - "3 cells"

Let's have 4 cells A, B, C to represent integer N; with
  • A and B so that N = B * 256 + A
  • C = 0
Again, C is used for logical branching, but also "D", which is the "C" from the previous integer.
Using this structure, "having on a value" means having cursor on A

IO

Using those 2 structures, let's define how to read or print a value. Read means reinitialize the "quotient" (D, or B, according to the structure) and read value in "remainder" (C, or A)


Operation"4 cells""3 cells"
,(read) ,>[-]< ,>[-]<
.(print) . .

Moves

Now, let's do the same wit


Operation"4 cells""3 cells"
<(move left) <<<< <<<
>(move right) >>>> >>>

lundi 20 mars 2017

Multiquine: final (4)

Context
Previous post  already presented the CS code template.
Now, here is the JS one
/*BOOTSTRAP*/
(function(language){
 var quote = String.fromCharCode(34), backslash = String.fromCharCode(92), newline = backslash + String.fromCharCode(114) + backslash + String.fromCharCode(110);
 var data =
 {
/*DATA*/
  cs: "CS_CODE_PLACEHOLDER",
  js: "JS_CODE_PLACEHOLDER",
  bf: "BF_CODE_PLACEHOLDER",
/*CODE*/
 };

 if(!language) language = 'js';
 var code = data[language];
 var bootstraps =
 {
   js: 'JS_BOOTSTRAP_PLACEHOLDER',
   cs: 'CS_BOOTSTRAP_PLACEHOLDER',
   bf: 'BF_BOOTSTRAP_PLACEHOLDER',
 }
 var res = bootstraps[language]
 switch(language)
 {
  case 'js':
   for(var i in data) res += ' ' + i + ': ' + quote + data[i].replace(new RegExp('\\\\', 'g'), backslash + backslash).replace(new RegExp(quote, 'g'), backslash + quote).replace(new RegExp(newline, 'g'), backslash + 'r' + backslash + 'n') + quote + ',\r\n';
   break;
  case 'cs':
   for(var i in data) res += ' data.Add(' + quote + i + quote + ', ' + quote + data[i].replace(new RegExp('\\\\', 'g'), backslash + backslash).replace(new RegExp(quote, 'g'), backslash + quote).replace(new RegExp(newline, 'g'), backslash + 'r' + backslash + 'n') + quote + ');\r\n';
   break;
  case 'bf':
   for(var i in data)
   {
     for (var j = 0; j < i.length; j++) { if (i.charCodeAt(j) == 13) continue; res += "+".repeat(i.charCodeAt(j)); res += '>'; }
res += '>';
for (var j = 0; j < data[i].length; j++) { if (data[i].charCodeAt(j) == 13) continue; res += "+".repeat(data[i].charCodeAt(j)); res += '>'; }
res += '>';
   }
   res += '\r\n';
 }
 res += code;
 console.log(res);
})()

Not really different from the C# version... Now, here is the BF one:
/*BOOTSTRAP*/
>>>>
/*DATA*/
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>CS_CODE_PLACEHOLDER>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>JS_CODE_PLACEHOLDER>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>BF_CODE_PLACEHOLDER>
/*CODE*/
,>+<[>+++++++++[-<---------->]+<+[[-]>-<JS_BOOTSTRAP_PLACEHOLDER<<<[[<]<]>>[<++++++++[-<++++>]<..>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]+++[-<++++++++++++++++>]<++++++++++.--------------------------.++.[-]>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]++[-<++++++++++++++++>]<++.++++++++++.[-]++++++++++.[-]>>]<<<<[[<]<]>>[>]>[>]>[>]>[.>]>[>]>[>]>>>]>[-CS_BOOTSTRAP_PLACEHOLDER<<<[[<]<]>>[<++[-<++++++++++++++++>]<............[-]>++++++[-<++++++++++++++++>]<++++.---.+++++++++++++++++++.-------------------.[-]>++[-<++++++++++++++++>]<++++++++++++++.+++++++++++++++++++.+++++++++++++++++++++++++++++++++++..[-]>++[-<++++++++++++++++>]<++++++++.------.[-]>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]++[-<++++++++++++++++>]<++.++++++++++.------------.++.[-]>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]++[-<++++++++++++++++>]<++.+++++++.++++++++++++++++++.[-]++++++++++.[-]>>]<<<<[[<]<]>>[>]>[.>]>[[>]>]>>>]<]>[-<<<[[<]<]+++[-<+++++++>]<[->++>+++<<]>+>-....<<++++++++++.[-]>>>[[[[-<<.<+>>>]<.[->+<]<[->+<]>>>]<.[->+<]<[->+<]>>>]]<<<<<[<]++++++++++.[-]>[.>]]
 

Hum. Hum. Sigh...
Ok. Let's analyze.

  • Bootstrap: leave some free space.
  • Data: write "cs", leave a cell, write CS DATA (placeholder), then write "js", leave a cell, write JS DATA (placeholder), and finally write "bf", leave a cell, write BF DATA (... ?)
  • Code: read input
      • No entry : that's BF. Write BF bootstrap (>>>>), then go the the first data cell, copy data declaration (leave a cell when needed), go to BF part of the data and print as text
      • Input = "c" : that's CS. Write CS bootstrap, then go the first data cell, write '      data.Add("', then language name, then '", "', then language code (from data), by replacing " by \", \ by \\ and line breaks by \r\n. Finally, go to CS part of the data and print as text (change line breaks to real line breaks)
      • Otherwise: that's JS (and globally same as CS...)
The final part to our quine implementation would be to create a generation tool (that read templates, and inject bootstraps / code into each template to create final codes).
That's what I did, but it's clearly out of scope for this post.

Code - CS

using System;
using System.Collections.Generic;
using System.Text;

namespace Multiquine
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<string, string> data = new Dictionary<string, string>();
            data.Add("cs", " string language = args.Length == 0 ? \"cs\" : args[0];\r\n string code = data[language];\r\n Dictionary<string, string> bootstraps = new Dictionary<string, string>();\r\n bootstraps.Add(\"cs\", \"using System;\\r\\nusing System.Collections.Generic;\\r\\nusing System.Text;\\r\\n\\r\\nnamespace Multiquine\\r\\n{\\r\\n class Program\\r\\n {\\r\\n static void Main(string[] args)\\r\\n {\\r\\n Dictionary<string, string> data = new Dictionary<string, string>();\\r\\n\");\r\n bootstraps.Add(\"js\", \"(function(language){\\r\\n var quote = String.fromCharCode(34), backslash = String.fromCharCode(92), newline = backslash + String.fromCharCode(114) + backslash + String.fromCharCode(110);\\r\\n var data = \\r\\n {\\r\\n\");\r\n bootstraps.Add(\"bf\", \">>>>\\r\\n\");\r\n Dictionary<string, string> dataAdd = new Dictionary<string, string>();\r\n dataAdd.Add(\"cs\", \" data.Add(\\\"{0}\\\", \\\"{1}\\\");\" + Environment.NewLine);\r\n dataAdd.Add(\"js\", \" {0}: \\\"{1}\\\",\" + Environment.NewLine);\r\n string res = bootstraps[language];\r\n if (language == \"bf\")\r\n {\r\n StringBuilder sb = new StringBuilder();\r\n foreach (string key in data.Keys)\r\n {\r\n foreach (char c in key)\r\n {\r\n if (c == '\\n') continue;\r\n if (c == '\\r')\r\n {\r\n sb.Append(\"++++++++++>\");\r\n continue;\r\n }\r\n sb.Append(new string('+', (int)c) + \">\");\r\n }\r\n sb.Append(\">\");\r\n foreach (char c in data[key])\r\n {\r\n if (c == '\\n') continue;\r\n if (c == '\\r')\r\n {\r\n sb.Append(\"++++++++++>\");\r\n continue;\r\n }\r\n sb.Append(new string('+', (int)c) + \">\");\r\n }\r\n sb.Append(\">\");\r\n }\r\n res += sb.ToString() + Environment.NewLine;\r\n }\r\n else\r\n {\r\n foreach (string key in data.Keys)\r\n res += String.Format(dataAdd[language], key, data[key].Replace(\"\\\\\", \"\\\\\\\\\").Replace(\"\\\"\", \"\\\\\\\"\").Replace(Environment.NewLine, @\"\\r\\n\"));\r\n }\r\n res += code;\r\n Console.Write(res);\r\n }\r\n }\r\n}");
            data.Add("js", " };\r\n\r\n if(!language) language = 'js';\r\n var code = data[language];\r\n var bootstraps = \r\n {\r\n js: '(function(language){\\r\\n var quote = String.fromCharCode(34), backslash = String.fromCharCode(92), newline = backslash + String.fromCharCode(114) + backslash + String.fromCharCode(110);\\r\\n var data = \\r\\n {\\r\\n',\r\n cs: 'using System;\\r\\nusing System.Collections.Generic;\\r\\nusing System.Text;\\r\\n\\r\\nnamespace Multiquine\\r\\n{\\r\\n class Program\\r\\n {\\r\\n static void Main(string[] args)\\r\\n {\\r\\n Dictionary<string, string> data = new Dictionary<string, string>();\\r\\n',\r\n bf: '>>>>\\r\\n',\r\n }\r\n var res = bootstraps[language]\r\n switch(language)\r\n {\r\n case 'js':\r\n for(var i in data) res += ' ' + i + ': ' + quote + data[i].replace(new RegExp('\\\\\\\\', 'g'), backslash + backslash).replace(new RegExp(quote, 'g'), backslash + quote).replace(new RegExp(newline, 'g'), backslash + 'r' + backslash + 'n') + quote + ',\\r\\n';\r\n break;\r\n case 'cs':\r\n for(var i in data) res += ' data.Add(' + quote + i + quote + ', ' + quote + data[i].replace(new RegExp('\\\\\\\\', 'g'), backslash + backslash).replace(new RegExp(quote, 'g'), backslash + quote).replace(new RegExp(newline, 'g'), backslash + 'r' + backslash + 'n') + quote + ');\\r\\n';\r\n break;\r\n case 'bf':\r\n for(var i in data)\r\n {\r\n for (var j = 0; j < i.length; j++) { if (i.charCodeAt(j) == 13) continue; res += \"+\".repeat(i.charCodeAt(j)); res += '>'; }\r\n res += '>';\r\n for (var j = 0; j < data[i].length; j++) { if (data[i].charCodeAt(j) == 13) continue; res += \"+\".repeat(data[i].charCodeAt(j)); res += '>'; }\r\n res += '>';\r\n }\r\n res += '\\r\\n';\r\n }\r\n res += code;\r\n console.log(res);\r\n})()");
            data.Add("bf", ",>+<[>+++++++++[-<---------->]+<+[[-]>-<[-]>++[-<++++++++++++++++>]<++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.+++++++++++++++.-------.-----------.+++++++++++++++++.-----------.++++++.-.[-]>++[-<++++++++++++++++>]<++++++++.[-]>++++++[-<++++++++++++++++>]<++++++++++++.-----------.+++++++++++++.-------.++++++++++++++.--------------------.++++++.--.[-]>++[-<++++++++++++++++>]<+++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.++++++++++++++++++++++.[-]>+++++++[-<++++++++++++++++>]<++++++.---------------------.+++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>+++++++[-<++++++++++++++++>]<+.++++.------.+++++.---------------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.++++++++++++.---.--.[-]>++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++++++.-------.+++++++++++++++++.[-]>++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++++++++.-----------.+.[-]>++[-<++++++++++++++++>]<++++++++.+++++++++++.+.-----------.+++.------------.[-]>++++++[-<++++++++++++++++>]<++.-.++.++++++++.++++++++.-------.-----------.++++++++++++++++++.-----------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.++++++++++++.---.--.[-]>++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++++++.-------.+++++++++++++++++.[-]>++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++++++++.-----------.+.[-]>++[-<++++++++++++++++>]<++++++++.+++++++++++++++++.-------.---------.+++.------------.[-]>++++++[-<++++++++++++++++>]<++++++++++++++.---------.++++++++++++++++++.-----------.---.+++++.---------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<++.-.++.++++++++.++++++++.-------.-----------.++++++++++++++++++.-----------.[-]>++[-<++++++++++++++++>]<.+++++++++++.-----------.[-]>+++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.++++++++++++.---.--.[-]>++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++++++.-------.+++++++++++++++++.[-]>++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++++++++.-----------.+.[-]>++[-<++++++++++++++++>]<++++++++.+++++++++..+++.-----------.---------.+++++++++++.-----------.[-]>++++++[-<++++++++++++++++>]<++.-.++.++++++++.++++++++.-------.-----------.++++++++++++++++++.-----------.[-]>++[-<++++++++++++++++>]<.+++++++++++.-----------.[-]>+++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.++++++++++++.---.--.[-]>++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++++++.-------.+++++++++++++++++.[-]>++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++++++++.-----------.+.[-]>++[-<++++++++++++++++>]<++++++++.+++++++++..-.-------.++++++++++++++++++.[-]++++++++++.++++++++++++++++++++++.[-]>+++++++[-<++++++++++++++++>]<++++++.---------------------.+++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<++++.---.+++++++++++++++++++.-------------------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]++++++++++.++++++++++++++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.[-]<<<[[<]<]>>[<++++++++[-<++++>]<..>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]+++[-<++++++++++++++++>]<++++++++++.--------------------------.++.[-]>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]++[-<++++++++++++++++>]<++.++++++++++.[-]++++++++++.[-]>>]<<<<[[<]<]>>[>]>[>]>[>]>[.>]>[>]>[>]>>>]>[-[-]>+++++++[-<++++++++++++++++>]<+++++.--.----------.+++++.-------.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++.------.+.---------------.++++++++.[-]>+++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++.--.----------.+++++.-------.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++.------.+.---------------.++++++++.[-]>++[-<++++++++++++++++>]<++++++++++++++.+++++++++++++++++++++.++++++++++++++++++++++++++++++++++++++++++++.---..-------.--.+++++++++++++++++.-----------.++++++.-.+++++.[-]>++[-<++++++++++++++++>]<++++++++++++++.+++++++++++++++++++++++++.++++++++++++++++++++++++++++++.+++++++++.---------.+++++++++++++.---------.------.[-]>+++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++.--.----------.+++++.-------.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++.------.+.---------------.++++++++.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>+++++[-<++++++++++++++++>]<++++.+++++++++++++++++.+++++++++++++++++++.----.[-]>+++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.[-]++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++++++++++.-------------.++++++++++++.--------.++++++++++++++.---.---------------.++.++.[-]>++[-<++++++++++++++++>]<.[-]>++++[-<++++++++++++++++>]<+++++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++.---------.++++++++.-----------.++++++++.++++.------------.+++++.---------.[-]++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.++++++++++++++++++++++....[-]>++++++[-<++++++++++++++++>]<+++.+++++++++.-----------.++++++++++++++++++..[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<.++++++++++++++++++++++++++++++++++.---.--------.+++++++++++.-----------------.++++++++++++.[-]++++++++++.++++++++++++++++++++++....[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.++++++++++++++++++++++........[-]>+++++++[-<++++++++++++++++>]<+++.+.-------------------.+++++++++++++++++++.-----------.------.[-]>++[-<++++++++++++++++>]<.[-]>+++++++[-<++++++++++++++++>]<++++++.-------.------.-----.[-]>++[-<++++++++++++++++>]<.[-]>++++[-<++++++++++++++++>]<+++++++++++++.++++++++++++++++++++.++++++++.+++++.[-]>++[-<++++++++++++++++>]<++++++++.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.------------.++.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<+.+++++++++++++++++.-----------.++++++++++++.[-]>++[-<++++++++++++++++>]<+++++++++.[-]++++++++++.++++++++++++++++++++++........[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.++++++++++++++++++++++............[-]>++++[-<++++++++++++++++>]<++++.+++++++++++++++++++++++++++++++++++++.------.+++++++++++++++++.-----------.++++++.-.-------------.+++++++++++++++++.+++++++.[-]>+++[-<++++++++++++++++>]<++++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++.------------.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.-----------------------------------------.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<++++.---.+++++++++++++++++++.-------------------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<++++++++++++++.---------.++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>++++[-<++++++++++++++++>]<++++.+++++++++++++++++++++++++++++++++++++.------.+++++++++++++++++.-----------.++++++.-.-------------.+++++++++++++++++.+++++++.[-]>+++[-<++++++++++++++++>]<++++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++.------------.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.-----------------------------------------.----------------------.+.++++++++++++++++++.[-]++++++++++.[-]<<<[[<]<]>>[<++[-<++++++++++++++++>]<............[-]>++++++[-<++++++++++++++++>]<++++.---.+++++++++++++++++++.-------------------.[-]>++[-<++++++++++++++++>]<++++++++++++++.+++++++++++++++++++.+++++++++++++++++++++++++++++++++++..[-]>++[-<++++++++++++++++>]<++++++++.------.[-]>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]++[-<++++++++++++++++>]<++.++++++++++.------------.++.[-]>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]++[-<++++++++++++++++>]<++.+++++++.++++++++++++++++++.[-]++++++++++.[-]>>]<<<<[[<]<]>>[>]>[.>]>[[>]>]>>>]<]>[-<<<[[<]<]+++[-<+++++++>]<[->++>+++<<]>+>-....<<++++++++++.[-]>>>[[[[-<<.<+>>>]<.[->+<]<[->+<]>>>]<.[->+<]<[->+<]>>>]]<<<<<[<]++++++++++.[-]>[.>]]");
            string language = args.Length == 0 ? "cs" : args[0];
            string code = data[language];
            Dictionary<string, string> bootstraps = new Dictionary<string, string>();
            bootstraps.Add("cs", "using System;\r\nusing System.Collections.Generic;\r\nusing System.Text;\r\n\r\nnamespace Multiquine\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n Dictionary<string, string> data = new Dictionary<string, string>();\r\n");
            bootstraps.Add("js", "(function(language){\r\n var quote = String.fromCharCode(34), backslash = String.fromCharCode(92), newline = backslash + String.fromCharCode(114) + backslash + String.fromCharCode(110);\r\n var data = \r\n {\r\n");
            bootstraps.Add("bf", ">>>>\r\n");
            Dictionary<string, string> dataAdd = new Dictionary<string, string>();
            dataAdd.Add("cs", " data.Add(\"{0}\", \"{1}\");" + Environment.NewLine);
            dataAdd.Add("js", " {0}: \"{1}\"," + Environment.NewLine);
            string res = bootstraps[language];
            if (language == "bf")
            {
                StringBuilder sb = new StringBuilder();
                foreach (string key in data.Keys)
                {
                    foreach (char c in key)
                    {
                        if (c == '\n') continue;
                        if (c == '\r')
                        {
                            sb.Append("++++++++++>");
                            continue;
                        }
                        sb.Append(new string('+', (int)c) + ">");
                    }
                    sb.Append(">");
                    foreach (char c in data[key])
                    {
                        if (c == '\n') continue;
                        if (c == '\r')
                        {
                            sb.Append("++++++++++>");
                            continue;
                        }
                        sb.Append(new string('+', (int)c) + ">");
                    }
                    sb.Append(">");
                }
                res += sb.ToString() + Environment.NewLine;
            }
            else
            {
                foreach (string key in data.Keys)
                    res += String.Format(dataAdd[language], key, data[key].Replace("\\", "\\\\").Replace("\"", "\\\"").Replace(Environment.NewLine, @"\r\n"));
            }
            res += code;
            Console.Write(res);
        }
    }
}

Code - JS

(function(language){
 var quote = String.fromCharCode(34), backslash = String.fromCharCode(92), newline = backslash + String.fromCharCode(114) + backslash + String.fromCharCode(110);
 var data =
 {
 cs: " string language = args.Length == 0 ? \"cs\" : args[0];\r\n string code = data[language];\r\n Dictionary<string, string> bootstraps = new Dictionary<string, string>();\r\n bootstraps.Add(\"cs\", \"using System;\\r\\nusing System.Collections.Generic;\\r\\nusing System.Text;\\r\\n\\r\\nnamespace Multiquine\\r\\n{\\r\\n class Program\\r\\n {\\r\\n static void Main(string[] args)\\r\\n {\\r\\n Dictionary<string, string> data = new Dictionary<string, string>();\\r\\n\");\r\n bootstraps.Add(\"js\", \"(function(language){\\r\\n var quote = String.fromCharCode(34), backslash = String.fromCharCode(92), newline = backslash + String.fromCharCode(114) + backslash + String.fromCharCode(110);\\r\\n var data = \\r\\n {\\r\\n\");\r\n bootstraps.Add(\"bf\", \">>>>\\r\\n\");\r\n Dictionary<string, string> dataAdd = new Dictionary<string, string>();\r\n dataAdd.Add(\"cs\", \" data.Add(\\\"{0}\\\", \\\"{1}\\\");\" + Environment.NewLine);\r\n dataAdd.Add(\"js\", \" {0}: \\\"{1}\\\",\" + Environment.NewLine);\r\n string res = bootstraps[language];\r\n if (language == \"bf\")\r\n {\r\n StringBuilder sb = new StringBuilder();\r\n foreach (string key in data.Keys)\r\n {\r\n foreach (char c in key)\r\n {\r\n if (c == '\\n') continue;\r\n if (c == '\\r')\r\n {\r\n sb.Append(\"++++++++++>\");\r\n continue;\r\n }\r\n sb.Append(new string('+', (int)c) + \">\");\r\n }\r\n sb.Append(\">\");\r\n foreach (char c in data[key])\r\n {\r\n if (c == '\\n') continue;\r\n if (c == '\\r')\r\n {\r\n sb.Append(\"++++++++++>\");\r\n continue;\r\n }\r\n sb.Append(new string('+', (int)c) + \">\");\r\n }\r\n sb.Append(\">\");\r\n }\r\n res += sb.ToString() + Environment.NewLine;\r\n }\r\n else\r\n {\r\n foreach (string key in data.Keys)\r\n res += String.Format(dataAdd[language], key, data[key].Replace(\"\\\\\", \"\\\\\\\\\").Replace(\"\\\"\", \"\\\\\\\"\").Replace(Environment.NewLine, @\"\\r\\n\"));\r\n }\r\n res += code;\r\n Console.Write(res);\r\n }\r\n }\r\n}",
 js: " };\r\n\r\n if(!language) language = 'js';\r\n var code = data[language];\r\n var bootstraps = \r\n {\r\n js: '(function(language){\\r\\n var quote = String.fromCharCode(34), backslash = String.fromCharCode(92), newline = backslash + String.fromCharCode(114) + backslash + String.fromCharCode(110);\\r\\n var data = \\r\\n {\\r\\n',\r\n cs: 'using System;\\r\\nusing System.Collections.Generic;\\r\\nusing System.Text;\\r\\n\\r\\nnamespace Multiquine\\r\\n{\\r\\n class Program\\r\\n {\\r\\n static void Main(string[] args)\\r\\n {\\r\\n Dictionary<string, string> data = new Dictionary<string, string>();\\r\\n',\r\n bf: '>>>>\\r\\n',\r\n }\r\n var res = bootstraps[language]\r\n switch(language)\r\n {\r\n case 'js':\r\n for(var i in data) res += ' ' + i + ': ' + quote + data[i].replace(new RegExp('\\\\\\\\', 'g'), backslash + backslash).replace(new RegExp(quote, 'g'), backslash + quote).replace(new RegExp(newline, 'g'), backslash + 'r' + backslash + 'n') + quote + ',\\r\\n';\r\n break;\r\n case 'cs':\r\n for(var i in data) res += ' data.Add(' + quote + i + quote + ', ' + quote + data[i].replace(new RegExp('\\\\\\\\', 'g'), backslash + backslash).replace(new RegExp(quote, 'g'), backslash + quote).replace(new RegExp(newline, 'g'), backslash + 'r' + backslash + 'n') + quote + ');\\r\\n';\r\n break;\r\n case 'bf':\r\n for(var i in data)\r\n {\r\n for (var j = 0; j < i.length; j++) { if (i.charCodeAt(j) == 13) continue; res += \"+\".repeat(i.charCodeAt(j)); res += '>'; }\r\n res += '>';\r\n for (var j = 0; j < data[i].length; j++) { if (data[i].charCodeAt(j) == 13) continue; res += \"+\".repeat(data[i].charCodeAt(j)); res += '>'; }\r\n res += '>';\r\n }\r\n res += '\\r\\n';\r\n }\r\n res += code;\r\n console.log(res);\r\n})()",
 bf: ",>+<[>+++++++++[-<---------->]+<+[[-]>-<[-]>++[-<++++++++++++++++>]<++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.+++++++++++++++.-------.-----------.+++++++++++++++++.-----------.++++++.-.[-]>++[-<++++++++++++++++>]<++++++++.[-]>++++++[-<++++++++++++++++>]<++++++++++++.-----------.+++++++++++++.-------.++++++++++++++.--------------------.++++++.--.[-]>++[-<++++++++++++++++>]<+++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.++++++++++++++++++++++.[-]>+++++++[-<++++++++++++++++>]<++++++.---------------------.+++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>+++++++[-<++++++++++++++++>]<+.++++.------.+++++.---------------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.++++++++++++.---.--.[-]>++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++++++.-------.+++++++++++++++++.[-]>++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++++++++.-----------.+.[-]>++[-<++++++++++++++++>]<++++++++.+++++++++++.+.-----------.+++.------------.[-]>++++++[-<++++++++++++++++>]<++.-.++.++++++++.++++++++.-------.-----------.++++++++++++++++++.-----------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.++++++++++++.---.--.[-]>++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++++++.-------.+++++++++++++++++.[-]>++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++++++++.-----------.+.[-]>++[-<++++++++++++++++>]<++++++++.+++++++++++++++++.-------.---------.+++.------------.[-]>++++++[-<++++++++++++++++>]<++++++++++++++.---------.++++++++++++++++++.-----------.---.+++++.---------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<++.-.++.++++++++.++++++++.-------.-----------.++++++++++++++++++.-----------.[-]>++[-<++++++++++++++++>]<.+++++++++++.-----------.[-]>+++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.++++++++++++.---.--.[-]>++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++++++.-------.+++++++++++++++++.[-]>++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++++++++.-----------.+.[-]>++[-<++++++++++++++++>]<++++++++.+++++++++..+++.-----------.---------.+++++++++++.-----------.[-]>++++++[-<++++++++++++++++>]<++.-.++.++++++++.++++++++.-------.-----------.++++++++++++++++++.-----------.[-]>++[-<++++++++++++++++>]<.+++++++++++.-----------.[-]>+++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++.++++++++++++.---.--.[-]>++++[-<++++++++++++++++>]<+++.+++++++++++++++++++++++++++++++++++++.-------.+++++++++++++++++.[-]>++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++++++++.-----------.+.[-]>++[-<++++++++++++++++>]<++++++++.+++++++++..-.-------.++++++++++++++++++.[-]++++++++++.++++++++++++++++++++++.[-]>+++++++[-<++++++++++++++++>]<++++++.---------------------.+++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<++++.---.+++++++++++++++++++.-------------------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]++++++++++.++++++++++++++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.[-]<<<[[<]<]>>[<++++++++[-<++++>]<..>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]+++[-<++++++++++++++++>]<++++++++++.--------------------------.++.[-]>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]++[-<++++++++++++++++>]<++.++++++++++.[-]++++++++++.[-]>>]<<<<[[<]<]>>[>]>[>]>[>]>[.>]>[>]>[>]>>>]>[-[-]>+++++++[-<++++++++++++++++>]<+++++.--.----------.+++++.-------.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++.------.+.---------------.++++++++.[-]>+++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++.--.----------.+++++.-------.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++.------.+.---------------.++++++++.[-]>++[-<++++++++++++++++>]<++++++++++++++.+++++++++++++++++++++.++++++++++++++++++++++++++++++++++++++++++++.---..-------.--.+++++++++++++++++.-----------.++++++.-.+++++.[-]>++[-<++++++++++++++++>]<++++++++++++++.+++++++++++++++++++++++++.++++++++++++++++++++++++++++++.+++++++++.---------.+++++++++++++.---------.------.[-]>+++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++.--.----------.+++++.-------.[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<+++.++++++++++++++++++++++++++++++++++++++.------.+.---------------.++++++++.[-]>++[-<++++++++++++++++>]<++++++++++++++.[-]>+++++[-<++++++++++++++++>]<++++.+++++++++++++++++.+++++++++++++++++++.----.[-]>+++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.[-]++++++++++.[-]>++++++[-<++++++++++++++++>]<++++++++++++++.-------------.++++++++++++.--------.++++++++++++++.---.---------------.++.++.[-]>++[-<++++++++++++++++>]<.[-]>++++[-<++++++++++++++++>]<+++++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++.---------.++++++++.-----------.++++++++.++++.------------.+++++.---------.[-]++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.++++++++++++++++++++++....[-]>++++++[-<++++++++++++++++>]<+++.+++++++++.-----------.++++++++++++++++++..[-]>++[-<++++++++++++++++>]<.[-]>+++++[-<++++++++++++++++>]<.++++++++++++++++++++++++++++++++++.---.--------.+++++++++++.-----------------.++++++++++++.[-]++++++++++.++++++++++++++++++++++....[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.++++++++++++++++++++++........[-]>+++++++[-<++++++++++++++++>]<+++.+.-------------------.+++++++++++++++++++.-----------.------.[-]>++[-<++++++++++++++++>]<.[-]>+++++++[-<++++++++++++++++>]<++++++.-------.------.-----.[-]>++[-<++++++++++++++++>]<.[-]>++++[-<++++++++++++++++>]<+++++++++++++.++++++++++++++++++++.++++++++.+++++.[-]>++[-<++++++++++++++++>]<++++++++.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.------------.++.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<+.+++++++++++++++++.-----------.++++++++++++.[-]>++[-<++++++++++++++++>]<+++++++++.[-]++++++++++.++++++++++++++++++++++........[-]>+++++++[-<++++++++++++++++>]<+++++++++++.[-]++++++++++.++++++++++++++++++++++............[-]>++++[-<++++++++++++++++>]<++++.+++++++++++++++++++++++++++++++++++++.------.+++++++++++++++++.-----------.++++++.-.-------------.+++++++++++++++++.+++++++.[-]>+++[-<++++++++++++++++>]<++++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++.------------.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.-----------------------------------------.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<++++.---.+++++++++++++++++++.-------------------.[-]>++[-<++++++++++++++++>]<.+++++++++++++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>++++++[-<++++++++++++++++>]<++++++++++++++.---------.++++++++++++++++++.[-]>++[-<++++++++++++++++>]<.[-]>++++[-<++++++++++++++++>]<++++.+++++++++++++++++++++++++++++++++++++.------.+++++++++++++++++.-----------.++++++.-.-------------.+++++++++++++++++.+++++++.[-]>+++[-<++++++++++++++++>]<++++++++++++.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.[-]>++[-<++++++++++++++++>]<++++++++++++.------------.[-]>+++++++[-<++++++++++++++++>]<+++.+.--.---------.+++++.-------.-----------------------------------------.----------------------.+.++++++++++++++++++.[-]++++++++++.[-]<<<[[<]<]>>[<++[-<++++++++++++++++>]<............[-]>++++++[-<++++++++++++++++>]<++++.---.+++++++++++++++++++.-------------------.[-]>++[-<++++++++++++++++>]<++++++++++++++.+++++++++++++++++++.+++++++++++++++++++++++++++++++++++..[-]>++[-<++++++++++++++++>]<++++++++.------.[-]>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]++[-<++++++++++++++++>]<++.++++++++++.------------.++.[-]>>[<+>----------[------------------------[<++++++++++++++[->----<]+>++[<++++++++++++[->+++++++<]>+.[-<<+>>]]<[++++++++++++[-<+++++++>]<+..>]>]<[++++++++++++[->+++++++<]>+.[-]<<++++++++++++++++++++++++++++++++++.>]>]<[->+++++[-<++++++++++++++++>]<++++++++++++.++++++++++++++++++++++.----------------------.++++++++++++++++++.[-]<++++++++++>]>>]++[-<++++++++++++++++>]<++.+++++++.++++++++++++++++++.[-]++++++++++.[-]>>]<<<<[[<]<]>>[>]>[.>]>[[>]>]>>>]<]>[-<<<[[<]<]+++[-<+++++++>]<[->++>+++<<]>+>-....<<++++++++++.[-]>>>[[[[-<<.<+>>>]<.[->+<]<[->+<]>>>]<.[->+<]<[->+<]>>>]]<<<<<[<]++++++++++.[-]>[.>]]",
 };

 if(!language) language = 'js';
 var code = data[language];
 var bootstraps =
 {
 js: '(function(language){\r\n var quote = String.fromCharCode(34), backslash = String.fromCharCode(92), newline = backslash + String.fromCharCode(114) + backslash + String.fromCharCode(110);\r\n var data = \r\n {\r\n',
 cs: 'using System;\r\nusing System.Collections.Generic;\r\nusing System.Text;\r\n\r\nnamespace Multiquine\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n Dictionary<string, string> data = new Dictionary<string, string>();\r\n',
 bf: '>>>>\r\n',
 }
 var res = bootstraps[language]
 switch(language)
 {
 case 'js':
 for(var i in data) res += ' ' + i + ': ' + quote + data[i].replace(new RegExp('\\\\', 'g'), backslash + backslash).replace(new RegExp(quote, 'g'), backslash + quote).replace(new RegExp(newline, 'g'), backslash + 'r' + backslash + 'n') + quote + ',\r\n';
 break;
 case 'cs':
 for(var i in data) res += ' data.Add(' + quote + i + quote + ', ' + quote + data[i].replace(new RegExp('\\\\', 'g'), backslash + backslash).replace(new RegExp(quote, 'g'), backslash + quote).replace(new RegExp(newline, 'g'), backslash + 'r' + backslash + 'n') + quote + ');\r\n';
 break;
 case 'bf':
 for(var i in data)
 {
 for (var j = 0; j < i.length; j++) { if (i.charCodeAt(j) == 13) continue; res += "+".repeat(i.charCodeAt(j)); res += '>'; }
res += '>';
for (var j = 0; j < data[i].length; j++) { if (data[i].charCodeAt(j) == 13) continue; res += "+".repeat(data[i].charCodeAt(j)); res += '>'; }
res += '>';
 }
 res += '\r\n';
 }
 res += code;
 console.log(res);
})()

Code - BF

This one is really long... So, please generate it from either JS or CS code :)

Note

I strongly suggest NOT TO USE the online interpreter (nor any interpreter actually) to try the BF code. I yo're using Ubuntu, you can use the BF package (if you're on any other Linux distribution, you can use the same package by building the source - it even works on Mac OSX).

And if you're using Windows, then you can download Cydia, and compile the BF sources as well