printGrammar method added.