Simple parser for formal logic language in Python