private TokenId ParseFromDigit() { TokenId integerLiteral; char ch = this.ch; this.NextChar(); if (((ch == '0') && (this.ch == 'x')) || (this.ch == 'X')) { integerLiteral = TokenId.BinaryLiteral; do { this.NextChar(); }while (WebConvert.IsCharHexDigit(this.ch)); return(integerLiteral); } integerLiteral = TokenId.IntegerLiteral; while (char.IsDigit(this.ch)) { this.NextChar(); } if (this.ch == '.') { integerLiteral = TokenId.DoubleLiteral; this.NextChar(); this.ValidateDigit(); do { this.NextChar(); }while (char.IsDigit(this.ch)); } if ((this.ch == 'E') || (this.ch == 'e')) { integerLiteral = TokenId.DoubleLiteral; this.NextChar(); if ((this.ch == '+') || (this.ch == '-')) { this.NextChar(); } this.ValidateDigit(); do { this.NextChar(); }while (char.IsDigit(this.ch)); } if ((this.ch == 'M') || (this.ch == 'm')) { integerLiteral = TokenId.DecimalLiteral; this.NextChar(); return(integerLiteral); } if ((this.ch == 'd') || (this.ch == 'D')) { integerLiteral = TokenId.DoubleLiteral; this.NextChar(); return(integerLiteral); } if ((this.ch == 'L') || (this.ch == 'l')) { integerLiteral = TokenId.Int64Literal; this.NextChar(); return(integerLiteral); } if ((this.ch == 'f') || (this.ch == 'F')) { integerLiteral = TokenId.SingleLiteral; this.NextChar(); } return(integerLiteral); }
/// <summary>Parses a token that starts with a digit.</summary> /// <returns>The kind of token recognized.</returns> private TokenId ParseFromDigit() { Debug.Assert(Char.IsDigit(this.ch), "Char.IsDigit(this.ch)"); TokenId result; char startChar = this.ch; this.NextChar(); if (startChar == '0' && this.ch == 'x' || this.ch == 'X') { result = TokenId.BinaryLiteral; do { this.NextChar(); }while (WebConvert.IsCharHexDigit(this.ch)); } else { result = TokenId.IntegerLiteral; while (Char.IsDigit(this.ch)) { this.NextChar(); } if (this.ch == '.') { result = TokenId.DoubleLiteral; this.NextChar(); this.ValidateDigit(); do { this.NextChar(); }while (Char.IsDigit(this.ch)); } if (this.ch == 'E' || this.ch == 'e') { result = TokenId.DoubleLiteral; this.NextChar(); if (this.ch == '+' || this.ch == '-') { this.NextChar(); } this.ValidateDigit(); do { this.NextChar(); }while (Char.IsDigit(this.ch)); } if (this.ch == 'M' || this.ch == 'm') { result = TokenId.DecimalLiteral; this.NextChar(); } else if (this.ch == 'd' || this.ch == 'D') { result = TokenId.DoubleLiteral; this.NextChar(); } else if (this.ch == 'L' || this.ch == 'l') { result = TokenId.Int64Literal; this.NextChar(); } else if (this.ch == 'f' || this.ch == 'F') { result = TokenId.SingleLiteral; this.NextChar(); } } return(result); }