/// <summary> /// Lex an optional integer suffix (U and/or L). /// </summary> private IntLitKind LexIntSuffix() { IntLitKind ilk = IntLitKind.None; for (; ;) { if (ChCur == 'U' || ChCur == 'u') { if ((ilk & IntLitKind.Uns) != 0) { break; } ilk |= IntLitKind.Uns; } else if (ChCur == 'L' || ChCur == 'l') { if ((ilk & IntLitKind.Lng) != 0) { break; } ilk |= IntLitKind.Lng; } else { break; } ChNext(); } return(ilk); }
/// <summary> /// Lex a decimal integer literal. The digits must be in _sb. /// </summary> private Token LexDecInt(IntLitKind ilk) { // Digits are in _sb. Contracts.Assert(_sb.Length > 0); ulong u = 0; try { for (int ich = 0; ich < _sb.Length; ich++) { u = checked (u * 10 + (ulong)LexCharUtils.GetDecVal(_sb[ich])); } } catch (System.OverflowException) { ReportError(ErrId.IntOverflow); u = ulong.MaxValue; } return(new IntLitToken(GetSpan(), u, ilk)); }
public readonly IntLitKind IntKind; // The kind specified by suffixes. public IntLitToken(TextSpan span, ulong val, IntLitKind ilk) : base(span, TokKind.IntLit) { Value = val; IntKind = ilk; }