private static String getGrammarName(String grammarDeclLine) {
		int gi = grammarDeclLine.indexOf("grammar ");
		if ( gi<0 ) {
			return "<unknown grammar name>";
		}
		gi += "grammar ".length();
		int gsemi = grammarDeclLine.indexOf(';');
		return grammarDeclLine.substring(gi, gsemi);
	}
Get A, B, or C from:
"lexer grammar A;" "grammar B;" "parser grammar C;"
runtime-testsuite/test/org/antlr/v4/test/runtime/RuntimeTestDescriptorParser.java