ShaderTools.Hlsl.Parser.HlslLexer.ReadInt64 C# (CSharp) Method

ReadInt64() private method

private ReadInt64 ( string text, bool hasHexModifier, bool hasOctalPrefix ) : long
text string
hasHexModifier bool
hasOctalPrefix bool
return long
        private long ReadInt64(string text, bool hasHexModifier, bool hasOctalPrefix)
        {
            if (hasHexModifier)
            {
                try
                {
                    return Convert.ToInt64(text, 16);
                }
                catch (OverflowException)
                {
                    _diagnostics.ReportNumberTooLarge(CurrentSpan, text);
                }
                catch (FormatException)
                {
                    _diagnostics.ReportInvalidHex(CurrentSpan, text);
                }

                return 0;
            }

            if (hasOctalPrefix)
            {
                try
                {
                    return Convert.ToInt64(text, 8);
                }
                catch (OverflowException)
                {
                    _diagnostics.ReportNumberTooLarge(CurrentSpan, text);
                }
                catch (FormatException)
                {
                    _diagnostics.ReportInvalidHex(CurrentSpan, text);
                }

                return 0;
            }

            try
            {
                return long.Parse(text, CultureInfo.InvariantCulture);
            }
            catch (OverflowException)
            {
                _diagnostics.ReportNumberTooLarge(CurrentSpan, text);
            }
            catch (FormatException)
            {
                _diagnostics.ReportInvalidInteger(CurrentSpan, text);
            }

            return 0;
        }