Implemented most of the grammar