コード例 #1
0
        public IParseTreeValue CreateDeclaredType(string expression, string declaredTypeName)
        {
            if (expression is null || declaredTypeName is null)
            {
                throw new ArgumentNullException();
            }

            if (ParseTreeValue.TryGetNonPrintingControlCharCompareToken(expression, out string comparableToken))
            {
                var charConversion = new TypeTokenPair(Tokens.String, comparableToken);
                return(ParseTreeValue.CreateValueType(charConversion));
            }

            var goalTypeTokenPair = new TypeTokenPair(declaredTypeName, null);
            var typeToken         = TypeTokenPair.ConformToType(declaredTypeName, expression);

            if (typeToken.HasValue)
            {
                if (LetCoerce.ExceedsValueTypeRange(typeToken.ValueType, typeToken.Token))
                {
                    return(ParseTreeValue.CreateOverflowExpression(expression, declaredTypeName));
                }
                return(ParseTreeValue.CreateValueType(typeToken));
            }
            return(ParseTreeValue.CreateExpression(new TypeTokenPair(declaredTypeName, expression)));
        }
コード例 #2
0
        public static IParseTreeValue CreateValueType(TypeTokenPair value)
        {
            if (value.ValueType.Equals(Tokens.Date) || value.ValueType.Equals(Tokens.String))
            {
                return(new ParseTreeValue(value));
            }

            var ptValue = new ParseTreeValue()
            {
                _typeTokenPair        = value,
                ParsesToConstantValue = true,
                IsOverflowExpression  = LetCoerce.ExceedsValueTypeRange(value.ValueType, value.Token),
            };

            return(ptValue);
        }