/ Brainfuck intepreter written in Marmelade
/ by @txlyre
/ usage: m -f b <input> 
/ ..or just m -f b to read input from stdin

:[(len _a)=4
   p:,/get `$(_a@3)
   p:,/get `"stdin"
]

p:{"+-<>[].,"?x}'p
p@:&~8=p

bm:(len p)#0
ls:()
i:0
do[len p
  c:p@i
  if[c=4
    ls,:i
  ]
  if[c=5
    e:*-1#ls
    ls::-1_ ls
    bm[i]:e
    bm[e]:i
  ]
  i+:1
]

pc:0
t:,0
tp:0

oi:{t[tp]+:1}                      / +
od:{t[tp]-:1}                      / -
of:{tp-:1}                         / <
ob:{tp+:1;if[tp=len t;t,:0]}       / >
ol:{if[t[tp]=0;pc::bm@pc]}         / [
or:{if[~t[tp]=0;pc::bm@pc]}        / ]
op:{say chr t@tp}                  / .
og:{t[tp]:(ord getch[])}           / ,

ops:(oi;od;of;ob;ol;or;op;og)
while[pc<len p
  ops[p@pc][]
  pc+:1
]