BNF in python