Example #1
0
        public static decimal GetMultiplier(SizeSufix sufix)
        {
            //here are the constants
            switch (sufix)
            {
            case SizeSufix.None:
                return(1M);

            case SizeSufix.KB:
                return(1024M);

            case SizeSufix.MB:
                return(1048576M);

            case SizeSufix.GB:
                return(1073741824M);

            case SizeSufix.TB:
                return(1125899906842624M);

            case SizeSufix.PB:
                return(1152921504606846976M);

            case SizeSufix.K:
                return(1000M);

            case SizeSufix.KK:
                return(1000000M);
            }
            return(1M);
        }
Example #2
0
 public void SetToNumericConstant(SizeSufix sizeU)
 {
     this.sizeSufix = sizeU;
     type           = TokenType.NumericConstant;
     content        = content.Replace('.', ',');
     if (sizeU.Equals(SizeSufix.K))
     {
         content = content.Substring(0, content.Length - 1);
     }
     else
     {
         content = content.Substring(0, content.Length - 2);
     }
 }
Example #3
0
        // for declaration -> go down


        public static List <Token> VariablesToNumeric(List <Token> tokens)
        {
            foreach (Token t in tokens)
            {
                if (t.GetTokenType() == TokenType.Variable)
                {
                    if (ParsableToNumber(t.GetContent()))
                    {
                        t.SetToNumericConstant();
                    }
                    else
                    {
                        string content = t.GetContent();
                        if (content.Length > 2)
                        {
                            SizeSufix ssfx = GetSizeSufix(content.Substring(content.Length - 2));

                            if (ssfx != SizeSufix.None)
                            {
                                string mainPart = content.Substring(0, content.Length - 2);
                                if (ParsableToNumber(mainPart))
                                {
                                    t.SetToNumericConstant(ssfx);
                                }
                            }
                        }
                        if (content.Length > 1)
                        {
                            char s = content[content.Length - 1];

                            if (s.Equals('k') || s.Equals('K'))
                            {
                                string mainPart = content.Substring(0, content.Length - 1);
                                if (ParsableToNumber(mainPart))
                                {
                                    t.SetToNumericConstant(SizeSufix.K);
                                }
                            }
                        }
                    }
                }
            }
            return(tokens);
        }
Example #4
0
 public Token(TokenType type, string content, SizeSufix sizeUnit)
 {
     this.type      = type;
     this.content   = content;
     this.sizeSufix = sizeUnit;
 }
Example #5
0
 public Token(TokenType type, SizeSufix sizeUnit)
 {
     this.type      = type;
     this.content   = "";
     this.sizeSufix = sizeUnit;
 }
Example #6
0
 public Token(TokenType type, string content)
 {
     this.type      = type;
     this.content   = content;
     this.sizeSufix = SizeSufix.None;
 }
Example #7
0
 public Token(TokenType type)
 {
     this.type      = type;
     this.content   = "";
     this.sizeSufix = SizeSufix.None;
 }
Example #8
0
 public Func__SizeUnit(INumerable arg0, SizeSufix sizeSufix)
 {
     this.arg0      = arg0;
     this.sizeSufix = sizeSufix;
 }