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); }
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); } }
// 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); }
public Token(TokenType type, string content, SizeSufix sizeUnit) { this.type = type; this.content = content; this.sizeSufix = sizeUnit; }
public Token(TokenType type, SizeSufix sizeUnit) { this.type = type; this.content = ""; this.sizeSufix = sizeUnit; }
public Token(TokenType type, string content) { this.type = type; this.content = content; this.sizeSufix = SizeSufix.None; }
public Token(TokenType type) { this.type = type; this.content = ""; this.sizeSufix = SizeSufix.None; }
public Func__SizeUnit(INumerable arg0, SizeSufix sizeSufix) { this.arg0 = arg0; this.sizeSufix = sizeSufix; }