Antlr4.Automata.LexerATNFactory.GetTokenConstantValue C# (CSharp) Method

GetTokenConstantValue() private method

private GetTokenConstantValue ( [ tokenName, [ token ) : int?
tokenName [
token [
return int?
        private int? GetTokenConstantValue([Nullable] string tokenName, [Nullable] IToken token)
        {
            if (tokenName == null)
            {
                return null;
            }

            if (tokenName.Equals("EOF"))
            {
                return Lexer.Eof;
            }
            if (COMMON_CONSTANTS.ContainsKey(tokenName))
            {
                g.tool.errMgr.GrammarError(ErrorType.TOKEN_CONFLICTS_WITH_COMMON_CONSTANTS, g.fileName, token, token.Text);
                return null;
            }

            int tokenType = g.GetTokenType(tokenName);
            if (tokenType != Antlr4.Runtime.TokenConstants.InvalidType)
            {
                return tokenType;
            }

            int result;
            if (int.TryParse(tokenName, out result))
                return result;

            g.tool.errMgr.GrammarError(ErrorType.CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_TOKEN_NAME, g.fileName, token, token.Text);
            return null;
        }