# ksh93 brainfuck compiler typeset -T countcache_t=( typeset op="" integer count=0 function flush { printf "${_.op}\n" "${_.count}" (( _.count=0 )) _.op="" return 0 } function write_op { typeset wop="$1" if [[ "${wop}" != "${_.op}" ]] ; then _.flush fi (( _.count++ )) _.op="${wop}" return 0 } ) function write_bf_head { cat <') cc.write_op "(( p+=%d ))" ;; '<') cc.write_op "(( p-=%d ))" ;; '+') cc.write_op "(( t[p]+=%d ))" ;; '-') cc.write_op "(( t[p]-=%d ))" ;; '.') cc.flush ; print 'pc t[p]' ;; ',') cc.flush ; print 'gc t[p]' ;; '[') cc.flush ; print 'while (( t[p] != 0 )) ; do' ;; ']') cc.flush ; print 'done' ;; esac done print "exit 0" exit 0