Ejemplo n.º 1
0
        public Condition <T> Parse(List <Token> tokens)
        {
            Contract.Requires(tokens != null && tokens.Count > 0);
            ConditionBuilder <T> builder = new ConditionBuilder <T>();

            for (int index = 0; index < tokens.Count; index++)
            {
                int delta = ProcessToken(index, tokens, builder);
                if (delta > 0)
                {
                    index += (delta - 1);
                }
            }

            return(builder.GetCondition());
        }
Ejemplo n.º 2
0
        private int ProcessToken(int index, List <Token> tokens, ConditionBuilder <T> builder)
        {
            Token token = tokens[index];

            if (TokenConstants.IsJoinOperator(token))
            {
                if (token.Value == TokenConstants.CONST_AND)
                {
                    builder.And();
                }
                else if (token.Value == TokenConstants.CONST_OR)
                {
                    builder.Or();
                }
            }
            return(0);
        }