working out type decleration in the grammar