Write a grammar for selection logic