Пример #1
0
            /// <summary>
            /// Find the end of the sequence and return the index.
            /// </summary>
            /// <returns>The index of the sequence end.</returns>
            public int IndexOf(out NameTokenType tokenType)
            {
                tokenType = Position == 0 && Current == Separator ? NameTokenType.Self : NameTokenType.Field;
                if (tokenType == NameTokenType.Self)
                {
                    return(Position);
                }

                while (Position < Last)
                {
                    Position++;
                    Current = Name[Position];

                    if (inQuote)
                    {
                        if (Current == Quoted)
                        {
                            inQuote = false;
                            return(Position - 1);
                        }
                    }
                    else if (Current == Separator)
                    {
                        return(Position - 1);
                    }
                    else if (inIndex)
                    {
                        if (Current == CloseIndex)
                        {
                            tokenType = NameTokenType.Index;
                            inIndex   = false;
                            return(Position - 1);
                        }
                    }
                    else if (Current == OpenIndex)
                    {
                        // Next token will be an Index
                        inIndex = true;

                        // Return end of token
                        return(Position - 1);
                    }
                }
                return(Position);
            }
Пример #2
0
        private Token Step(int character, NameState newState, NameTokenType newNameTokenType, bool create = false)
        {
            Token res = null;

            if (create)
            {
                res = new Token((int)_nameTokenType, Text.ToString());
                Text.Clear();
            }

            if (character != IgnoreChar)
            {
                Text.Append((char)character);
            }

            CurrentState   = newState;
            _nameTokenType = newNameTokenType;

            return(res);
        }