Exemple #1
0
        public static Tuple <ICollection <IEnumerable <Variable> >, ICollection <Token> > GetParamVariables(IEnumerable <Token> tokens, string flag, int i)
        {
            ICollection <Token> subTokens = new List <Token>();

            CollectionTokens(tokens, subTokens, i + 1, Strings.StartFlag1, Strings.EndFlag1, true);

            var len = subTokens.Count();
            ICollection <IEnumerable <Variable> > variables = new List <IEnumerable <Variable> >();
            ICollection <Variable> subVariables             = new List <Variable>();

            for (var si = 0; si < len; si++)
            {
                var token = subTokens.ElementAt(si);
                if (token.Flag == Strings.ParamSplit)
                {
                    variables.Add(subVariables.ToArray());
                    subVariables.Clear();
                    continue;
                }

                var handler = VariableHandleFactory.Create(token.Flag);
                si = handler.TryAddVariable(subTokens, token, subVariables, si);
            }

            if (subVariables.Any())
            {
                variables.Add(subVariables);
            }

            return(Tuple.Create(variables, subTokens));
        }
Exemple #2
0
        internal static IEnumerable <Variable> Parser(CodePiece codePiece)
        {
            var tokens = codePiece.Tokens;
            var len    = tokens.Count();
            ICollection <Variable> variables = new List <Variable>();

            for (var i = 0; i < len; i++)
            {
                var token   = tokens.ElementAt(i);
                var handler = VariableHandleFactory.Create(token.Flag);
                i = handler.TryAddVariable(tokens, token, variables, i);
            }

            return(variables);
        }