for(l in readLines("stdin")){j=1 a=c() for(i in 80:1){s=substr(l,i,i) if(s=="(")j=j-1 if(length(a)<j)a[j]=paste(rep(" ",i),sep="",collapse="") substr(a[j],i,i)=s if(s==")")j=j+1} write(a,1)}
Note that non-ascii characters in the above source code will be escaped (such as \x9f).