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;
}