Implement grammar parser.