Exemple #1
0
        public static IStringable Build(List <Token> tokens)
        {
            if (Brackets.ContainsIndependentBracketsPairs(tokens, BracketsType.Normal))
            {
                return(null);
            }

            List <Token> tokensCopy = tokens.Select(t => t.Clone()).ToList();

            string name = tokensCopy[0].GetContent().ToLower();

            tokensCopy.RemoveAt(tokensCopy.Count - 1);
            tokensCopy.RemoveAt(0);
            tokensCopy.RemoveAt(0);

            List <Argument> args = ArgumentsExtractor.GetArguments(tokensCopy);

            if (name.Equals("hex") || name.Equals("binary") || name.Equals("month") ||
                name.Equals("weekday"))
            {
                return(BuildNum(name, args));
            }
            else if (name.Equals("substring"))
            {
                return(BuildSubstring(name, args));
            }
            else if (name.Equals("upper") || name.Equals("lower") || name.Equals("tolower") || name.Equals("toupper") ||
                     name.Equals("digits") || name.Equals("letters") || name.Equals("trim") || name.Equals("name") ||
                     name.Equals("fullname") || name.Equals("extension"))
            {
                return(BuildStr(name, args));
            }
            else if (name.Equals("commonbeginning") || name.Equals("commonending") || name.Equals("concatenate") ||
                     name.Equals("concatenated"))
            {
                return(BuildLis(name, args));
            }
            else if (name.Equals("filled") || name.Equals("fill") || name.Equals("repeat") || name.Equals("repeated"))
            {
                return(BuildStrNum(name, args));
            }
            else if (name.Equals("beforetext") || name.Equals("aftertext") || name.Equals("textbefore") || name.Equals("textafter"))
            {
                return(BuildStrStr(name, args));
            }

            return(null);
        }
Exemple #2
0
        public static IBoolable Build(List <Token> tokens)
        {
            if (Brackets.ContainsIndependentBracketsPairs(tokens, BracketsType.Normal))
            {
                return(null);
            }

            List <Token> tokensCopy = tokens.Select(t => t.Clone()).ToList();

            string name = tokensCopy[0].GetContent().ToLower();

            tokensCopy.RemoveAt(tokensCopy.Count - 1);
            tokensCopy.RemoveAt(0);
            tokensCopy.RemoveAt(0);

            List <Argument> args = ArgumentsExtractor.GetArguments(tokensCopy);

            if (name.Equals("exist") || name.Equals("exists") || name.Equals("empty") ||
                name.Equals("emptydirectory") || name.Equals("iscorrect") ||
                name.Equals("isdirectory") || name.Equals("isfile") ||
                name.Equals("hidden") || name.Equals("readonly"))
            {
                return(BuildStr(name, args));
            }
            else if (name.Equals("existinside"))
            {
                return(BuildStrStr(name, args));
            }
            else if (name.Equals("emptylist") || name.Equals("listisempty"))
            {
                return(BuildLis(name, args));
            }
            else if (name.Equals("contain") || name.Equals("contains"))
            {
                return(BuildLisStr(name, args));
            }
            else if (name.Equals("samedate") || name.Equals("samedates") ||
                     name.Equals("thesamedate") || name.Equals("thesamedates") ||
                     name.Equals("sameclock") || name.Equals("sameclocks") ||
                     name.Equals("thesameclock") || name.Equals("thesameclocks"))
            {
                return(BuildTimTim(name, args));
            }

            return(null);
        }
Exemple #3
0
        public static ITimeable Build(List <Token> tokens)
        {
            if (Brackets.ContainsIndependentBracketsPairs(tokens, BracketsType.Normal))
            {
                return(null);
            }

            List <Token> tokensCopy = tokens.Select(t => t.Clone()).ToList();

            string name = tokensCopy[0].GetContent().ToLower();

            tokensCopy.RemoveAt(tokensCopy.Count - 1);
            tokensCopy.RemoveAt(0);
            tokensCopy.RemoveAt(0);

            List <Argument> args = ArgumentsExtractor.GetArguments(tokensCopy);

            if (name.Equals("date"))
            {
                return(BuildNumNumNum(name, args));
            }
            else if (name.Equals("newyear") || name.Equals("christmas") || name.Equals("easter"))
            {
                return(BuildNum(name, args));
            }
            else if (name.Equals("access") || name.Equals("creation") || name.Equals("modification"))
            {
                return(BuildStr(name, args));
            }
            else if (name.Equals("tomorrow") || name.Equals("yesterday") || name.Equals("today"))
            {
                return(BuildWithArgs023(name, args));
            }

            return(null);
        }
Exemple #4
0
        public static INumerable Build(List <Token> tokens)
        {
            if (Brackets.ContainsIndependentBracketsPairs(tokens, BracketsType.Normal))
            {
                return(null);
            }

            List <Token> tokensCopy = tokens.Select(t => t.Clone()).ToList();

            string name = tokensCopy[0].GetContent().ToLower();

            tokensCopy.RemoveAt(tokensCopy.Count - 1);
            tokensCopy.RemoveAt(0);
            tokensCopy.RemoveAt(0);

            List <Argument> args = ArgumentsExtractor.GetArguments(tokensCopy);

            if (name.Equals("round") || name.Equals("floor") || name.Equals("ceil") || name.Equals("ceiling") ||
                name.Equals("sqrt") || name.Equals("ln") || name.Equals("log") ||
                name.Equals("log10") || name.Equals("kb") || name.Equals("mb") ||
                name.Equals("gb") || name.Equals("tb") || name.Equals("pb") || name.Equals("k") ||
                name.Equals("kk") || name.Equals("factorial"))
            {
                return(BuildNum(name, args));
            }
            else if (name.Equals("power") || name.Equals("pow"))
            {
                return(BuildNumNum(name, args));
            }
            else if (name.Equals("pi") || name.Equals("e") || name.Equals("goldenratio"))
            {
                return(BuildEmpty(name, args));
            }
            else if (name.Equals("number") || name.Equals("length") || name.Equals("year") || name.Equals("size"))
            {
                return(BuildStr(name, args));
            }
            else if (name.Equals("min") || name.Equals("max") || name.Equals("average") || name.Equals("avg") ||
                     name.Equals("mean") || name.Equals("sum") || name.Equals("product"))
            {
                return(BuildNums(name, args));
            }
            else if (name.Equals("lengthofshortest") || name.Equals("lengthoflongest"))
            {
                return(BuildLis(name, args));
            }
            else if (name.Equals("indexof"))
            {
                return(BuildStrStr(name, args));
            }
            else if (name.Equals("yearday") || name.Equals("dayofyear"))
            {
                return(BuildTim(name, args));
            }
            else if (name.Equals("yearsbetween") || name.Equals("monthsbetween") || name.Equals("daysbetween") ||
                     name.Equals("hoursbetween") || name.Equals("minutesbetween") || name.Equals("secondsbetween"))
            {
                return(BuildTimTim(name, args));
            }

            return(null);
        }