Esempio n. 1
0
        private ExpressionNode ParseNumberLiteral()
        {
            string text = _token.Text;

            bool hasHexModifier         = text.EndsWith("h", StringComparison.OrdinalIgnoreCase);
            bool hasExponentialModifier = text.IndexOfAny(new char[] { '.', 'E', 'e' }) != -1;

            if (hasExponentialModifier && !hasHexModifier)
            {
                return(LiteralExpression.FromDouble(ParseReal()));
            }

            long integer = ParseInteger();

            // If the integer can be represented as Int32 we return
            // an Int32 literal. Otherwise we return an Int64.

            try
            {
                checked
                {
                    return(LiteralExpression.FromInt32((int)integer));
                }
            }
            catch (OverflowException)
            {
                return(LiteralExpression.FromInt64(integer));
            }
        }