Added finalize method to Grammar with support for context free languages