Adding while loop to grammar