support #pattern# replacement of grammar