Simple logical formula parser written in Python