# python 3.4.3
# convert BF shorthand code to standard BF code
# this program can process 1+ or 2>>, but bf_l2s.py will not generate that shorthand
prevch=""
nextch=""
counter=1
error_count=0
command_set="<>+-[].,"
num=""
file = open(input(("bf file: "), 'r')
print()
while True:
nextch=file.read(1)
if(not nextch):
file.close()
break
if(nextch.isnumeric()):
num = num + nextch
elif(nextch not in command_set):
error_count += 1
elif(num == ""):
print(nextch,end="")
else:
print(nextch * int(num), end="")
num=""
print()
print()
"""
Sample input BF code, Hello World implementations in the Esoteric Programming Language Wiki
++++++++++[>+++++++>++++++++++>+++>+<
<<<-]>++.>+.+++++++..+++.>++.<<++++++
+++++++++.>.+++.------.--------.>+.>.
bf_l2s.py returns:
10+[>7+>10+>3+>+4<-]>++.>+.7+..3+.>++.<<15+.>.3+.6-.8-.>+.>.
111 Commands
bf_s2l.py returns the original program (without formatting), and it runs too!
"""
Comments