Implementing most of grammar input