revised convert_grammar2