Example #1
0
        private ExpressionTokens GetSetTokens(IList <ExpressionToken> Tokens)
        {
            ExpressionTokens result = null;

            if (Tokens.Count >= 2)
            {
                if (Linq2.Any(Tokens, t => t.TokenType == TokenType.EQUAL_OPERATOR))
                {
                    for (var i = 0; i < Tokens.Count; i++)
                    {
                        ExpressionToken token = Tokens[i];

                        if (token.TokenType == TokenType.EQUAL_OPERATOR)
                        {
                            break;
                        }

                        if (result == null)
                        {
                            result = new ExpressionTokens();
                        }
                        result.Add(token);
                    }
                }
            }
            return(result);
        }
Example #2
0
        //////////////////////////////////////////////////

        public Int32 IndexOfSequence(IEnumerable <ExpressionToken> Sequence)
        {
            Int32 index = -1;

#if !NET20
            if (Sequence.Any())
#else
            if (Linq2.Any(Sequence))
#endif

            {
#if !NET20
                index = this.IndexOf(Sequence.First());
#else
                index = this.IndexOf(Linq2.FirstOrDefault(Sequence));
#endif
                if (index >= 0)
                {
                    Int32 nextIndex = index;
                    foreach (ExpressionToken item in Sequence)
                    {
                        if (this.IndexOf(item) != nextIndex)
                        {
                            return(-1);
                        }
                        nextIndex++;
                    }
                }
            }

            return(index);
        }
Example #3
0
        private ExpressionTokens TakeSetTokens(IList <ExpressionToken> Tokens, Boolean RemoveTakenTokens)
        {
            ExpressionTokens result = null;

            if (Tokens.Count >= 2)
            {
                if (Linq2.Any(Tokens, t => t.TokenType == TokenType.EQUAL_OPERATOR))
                {
                    for (var i = 0; i < Tokens.Count; i++)
                    {
                        ExpressionToken token = Tokens[i];

                        if (token.TokenType == TokenType.EQUAL_OPERATOR)
                        {
                            if (RemoveTakenTokens)
                            {
                                Tokens.RemoveAt(i);
                            }
                            break;
                        }

                        if (result == null)
                        {
                            result = new ExpressionTokens();
                        }
                        result.Add(token.Clone());

                        if (RemoveTakenTokens)
                        {
                            Tokens.RemoveAt(i);
                            i--;
                        }
                    }
                }
            }
            return(result);
        }