pass grammar into functions so referencing nested selectors is correct