public String getTokenName(int ttype) {
		// inside any target's char range and is lexer grammar?
		if ( isLexer() &&
			 ttype >= Lexer.MIN_CHAR_VALUE && ttype <= Lexer.MAX_CHAR_VALUE )
		{
			return CharSupport.getANTLRCharLiteralForChar(ttype);
		}

		if ( ttype==Token.EOF ) {
			return "EOF";
		}

		if (ttype >= 0 && ttype < typeToTokenList.size() && typeToTokenList.get(ttype) != null) {
			return typeToTokenList.get(ttype);
		}

		return INVALID_TOKEN_NAME;
	}
Gets the name by which a token can be referenced in the generated code.
For tokens defined in a {@code tokens{}} block or via a lexer rule, this
is the declared name of the token. For token types generated by the use
of a string literal within a parser rule of a combined grammar, this is
the automatically generated token type which includes the
{@link #AUTO_GENERATED_TOKEN_NAME_PREFIX} prefix. For types which are not
associated with a defined token, this method returns
{@link #INVALID_TOKEN_NAME}.

@param ttype The token type.
@return The name of the token with the specified type.
tool/src/org/antlr/v4/tool/Grammar.java