breaking out the grammar a bit for a future refactoring