fork(5) download
  1. import sys,re
  2. def v(s):
  3. if s[:1]=='(':l,s=e(s[1:]);return l,s[1:]
  4. m=re.match(r"\d+\.?\d*|\.\d+",s)
  5. if m:return[m.group()],s[m.end():]
  6. def b(s,f,*O):
  7. l,s=f(s)
  8. while s[:1]in O:
  9. o=s[0]
  10. r,s=f(s[1:])
  11. if len(r)>1:l,r=r,l
  12. l+=[o]+r
  13. return l,s
  14. m=lambda s:b(s,v,'*','/')
  15. e=a=lambda s:b(s,m,'+','-')
  16. print(' '.join(e(sys.argv[1])[0]))
Runtime error #stdin #stdout #stderr 0.04s 9984KB
stdin
1+(5*7)*7
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 16, in <module>
IndexError: list index out of range