replace grammar function with Grammar class