Brainf*** to tinyBF converter

Extended BrainFuck 276 bytes

(not counting uneccesary linefeeds)

{a<<]>&c}{b<<-]<[->}{c]<]>[>[}{d 4+[-<}3>4->3->5->-->>&d 4+>]<[-<
4+<3+<4+<8+4>]<[<]<<,[>3+&d 6->]+<-[-[-[-[14-[--[>&d 6->]+<+[--[[
-]>[-&c>.&b>>.<.<+&a->>.<.&b>.<&a->>.>>.3<&b 4>.4<&a 4>.3<&b+>>.>
>.6<]>]<]>[-3>..3<&c 3>.<<&b+>>.>.3<&a>>.<.>.<.&b+>.>.<.<&a->>.>.
<<&b 3>.5<]>]<,]

How to compile and run:

beef ebf.bf < tinybf.ebf > tinybf.bf
beef tinybf.bf < source.bf > source.tbf

It will work with any wrapping BF interpreter that uses/support 0 as EOF. Actual EBF source before golfing:

:i:f:o:p:e:a:g
$p ~"|=+>"<[<]@o
$i,( $f+++++++(-$i------)+$i-; +
     ($i-; ,
       ($i-; -
         ($i-; .
           ($i--------------; <
             ($i--; >
               ($f++++(-$i------)+$i+; [
                 ($i--; ]
                   ((-) $f(-) )
                      $f ( $o[$p.$f-]<[@f-$e.$p.$o+$i] ) ; ]
                  ) $f ( $o[-$e.$p.$f-]<[@f-$p.$i] ) ; [
                ) $f ( $o[-$e.$g.$f-]<[@f-$g.$i] ) ; >
              ) $f ( $o[$g.$f-]<[@f-$o+$e.$g.$i] ) ; <
            ) $f (- $e.. ) ; .
          ) $f ( $o[$a.$f-]<[@f-$o+$e.$a.$i] ) ; -
        ) $f ( $o[$e.$p.$e.$p.$f-]<[@f-$o+$p.$e.$p.$i] ) ; ,
     ) $f ( $o[-$e.$a.$f-]<[@f-$a.$i] ) ; +
$i,)

BrainFuck 404 bytes

This is the trimmed output of the compiled EBF.

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

CJam, 50 bytes

l{"..+-><[],"#2mdT2$@T?:T=L'=?"== + > | |=|"S/@=}/

Try one example or all of them online.

Explanation

The magic is in the mapping! Looking up each operator's index in a carefully ordered yet simple string produces three useful pieces of information at once: whether the operator is directionless (index == 0), the direction the operator requires (index mod 2), and the index of the output operator (index / 2).

Using that handy mapping, it's a simple case of looping through each input operator and producing a direction swap operator if the direction needs to be changed, updating the direction, and producing the output operator.

l                   "Read a line of input.";
{                   "For each character of input:";
  "..+-><[],"#        "Map the character:
                        '.' -> 0  |
                        '+' -> 2  |  '-' -> 3
                        '>' -> 4  |  '<' -> 5
                        '[' -> 6  |  ']' -> 7
                        ',' -> 8  |            ";
  2md                 "Calculate the quotient and remainder of the mapping
                       divided by 2.";
  T2$@T?:T            "If the the mapping is nonzero (not '.'), set the
                       direction after this operator to the remainder above.
                       Otherwise ('.'), don't change the direction.";
  =L'=?               "If the direction before this operator is equal to the
                       direction after, produce an empty string. Otherwise,
                       produce the direction switch operator, '='.";
  "== + > | |=|"S/@=  "Map the previous mapping divided by 2 to an operator:
                         0 ('.')      -> '=='
                         1 ('+', '-') -> '+'
                         2 ('>', '<') -> '>'
                         3 ('[', ']') -> '|'
                         4 (',')      -> '|=|' ";
}/