Ejemplo n.º 1
0
        public override Node ExitReal(Token node)
        {
            var image   = node.Image;
            var element = RealLiteralElement.Create(image, this.myServices);

            node.AddValue(element);
            return(node);
        }
Ejemplo n.º 2
0
        public static LiteralElement Create(string image, bool isHex, bool negated, IServiceProvider services)
        {
            var            comparison = StringComparison.OrdinalIgnoreCase;
            var            flag       = !isHex;
            LiteralElement Create;

            if (flag)
            {
                var realElement = RealLiteralElement.CreateFromInteger(image, services);
                var flag2       = realElement != null;
                if (flag2)
                {
                    Create = realElement;
                    return(Create);
                }
            }
            var hasUSuffix  = image.EndsWith("u", comparison) & !image.EndsWith("lu", comparison);
            var hasLSuffix  = image.EndsWith("l", comparison) & !image.EndsWith("ul", comparison);
            var hasULSuffix = image.EndsWith("ul", comparison) | image.EndsWith("lu", comparison);
            var hasSuffix   = hasUSuffix | hasLSuffix | hasULSuffix;
            var numStyles   = NumberStyles.Integer;

            if (isHex)
            {
                numStyles = NumberStyles.AllowHexSpecifier;
                image     = image.Remove(0, 2);
            }
            var flag3 = !hasSuffix;

            if (flag3)
            {
                LiteralElement constant = Int32LiteralElement.TryCreate(image, isHex, negated);
                var            flag4    = constant != null;
                if (flag4)
                {
                    Create = constant;
                }
                else
                {
                    constant = UInt32LiteralElement.TryCreate(image, numStyles);
                    var flag5 = constant != null;
                    if (flag5)
                    {
                        Create = constant;
                    }
                    else
                    {
                        constant = Int64LiteralElement.TryCreate(image, isHex, negated);
                        var flag6 = constant != null;
                        if (flag6)
                        {
                            Create = constant;
                        }
                        else
                        {
                            Create = new UInt64LiteralElement(image, numStyles);
                        }
                    }
                }
            }
            else
            {
                var flag7 = hasUSuffix;
                if (flag7)
                {
                    image = image.Remove(image.Length - 1);
                    LiteralElement constant = UInt32LiteralElement.TryCreate(image, numStyles);
                    var            flag8    = constant != null;
                    if (flag8)
                    {
                        Create = constant;
                    }
                    else
                    {
                        Create = new UInt64LiteralElement(image, numStyles);
                    }
                }
                else
                {
                    var flag9 = hasLSuffix;
                    if (flag9)
                    {
                        image = image.Remove(image.Length - 1);
                        LiteralElement constant = Int64LiteralElement.TryCreate(image, isHex, negated);
                        var            flag10   = constant != null;
                        if (flag10)
                        {
                            Create = constant;
                        }
                        else
                        {
                            Create = new UInt64LiteralElement(image, numStyles);
                        }
                    }
                    else
                    {
                        Debug.Assert(hasULSuffix, "expecting ul suffix");
                        image  = image.Remove(image.Length - 2);
                        Create = new UInt64LiteralElement(image, numStyles);
                    }
                }
            }
            return(Create);
        }