public String getTokenTypeAsTargetLabel(Grammar g, int ttype) {
	    String name = this.escapeIfNeeded(g.getTokenName(ttype));
		// If name is not valid, return the token type instead
		if ( Grammar.INVALID_TOKEN_NAME.equals(name) ) {
			return String.valueOf(ttype);
		}

		return name;
	}
Get a meaningful name for a token type useful during code generation.
 Literals without associated names are converted to the string equivalent
 of their integer values. Used to generate x==ID and x==34 type comparisons
 etc...  Essentially we are looking for the most obvious way to refer
 to a token type in the generated code.
tool/src/org/antlr/v4/codegen/Target.java