예제 #1
0
        /* Function: GetTokensInSection
         * Returns the bounds of the first stretch of tokens of the specified type appearing within the passed section.
         */
        protected bool GetTokensInSection(SectionType sectionType, int sectionIndex, ClassPrototypeParsingType tokenType,
                                          out TokenIterator start, out TokenIterator end)
        {
            TokenIterator sectionStart, sectionEnd;

            GetSectionBounds(sectionType, sectionIndex, out sectionStart, out sectionEnd);

            start = sectionStart;

            while (start.IsInBounds &&
                   start < sectionEnd &&
                   start.ClassPrototypeParsingType != tokenType)
            {
                start.Next();
            }

            end = start;

            while (end < sectionEnd &&
                   end.ClassPrototypeParsingType == tokenType)
            {
                end.Next();
            }

            return(end > start);
        }
예제 #2
0
        /* Function: SetClassPrototypeParsingTypeBetween
         * Changes the <ClassPrototypeParsingType> of all the tokens between the two passed iterators.  The
         * token at the ending iterator will not be changed.
         */
        public void SetClassPrototypeParsingTypeBetween(TokenIterator startingIterator, TokenIterator endingIterator,
                                                        ClassPrototypeParsingType type)
        {
            if (startingIterator.Tokenizer != this || endingIterator.Tokenizer != this)
            {
                throw new InvalidOperationException();
            }

            SetClassPrototypeParsingTypeBetween(startingIterator.TokenIndex, endingIterator.TokenIndex, type);
        }
예제 #3
0
        /* Function: SetClassPrototypeParsingTypeAt
         * Changes the <ClassPrototypeParsingType> at the passed token index.
         */
        public void SetClassPrototypeParsingTypeAt(int tokenIndex, ClassPrototypeParsingType type)
        {
            if (classPrototypeParsingTypes == null)
            {
                classPrototypeParsingTypes = new ClassPrototypeParsingType[tokenLengths.Count];
            }

            if (tokenIndex < 0 || tokenIndex >= classPrototypeParsingTypes.Length)
            {
                throw new ArgumentOutOfRangeException();
            }

            classPrototypeParsingTypes[tokenIndex] = type;
        }
예제 #4
0
        /* Function: SetClassPrototypeParsingTypeBetween
         * Changes the <ClassPrototypeParsingType> of all the tokens between the two passed indexes.  The
         * token at the ending index will not be changed.
         */
        public void SetClassPrototypeParsingTypeBetween(int startingIndex, int endingIndex, ClassPrototypeParsingType type)
        {
            if (classPrototypeParsingTypes == null)
            {
                classPrototypeParsingTypes = new ClassPrototypeParsingType[tokenLengths.Count];
            }

            if (startingIndex < 0 || endingIndex > classPrototypeParsingTypes.Length)
            {
                throw new ArgumentOutOfRangeException();
            }
            if (startingIndex > endingIndex)
            {
                throw new InvalidOperationException();
            }

            for (int i = startingIndex; i < endingIndex; i++)
            {
                classPrototypeParsingTypes[i] = type;
            }
        }
예제 #5
0
        /* Function: SetClassPrototypeParsingTypeByCharacters
         *
         * Changes the <ClassPrototypeParsingType> of the tokens encompassed by the passed number of characters.
         *
         * This throws an exception if the number of characters does not evenly fall on a token boundary.  It
         * is assumed that this function will primarily be used after a positive result from <MatchesAcrossTokens()>
         * or <TokensInCharacters()> which would cause this to not be an issue.
         */
        public void SetClassPrototypeParsingTypeByCharacters(ClassPrototypeParsingType newType, int characters)
        {
            int tokenCount = TokensInCharacters(characters);

            if (tokenCount == -1)
            {
                throw new InvalidOperationException();
            }
            else if (tokenCount == 1)
            {
                ClassPrototypeParsingType = newType;
            }
            else
            {
                TokenIterator iterator = this;

                while (tokenCount > 0)
                {
                    iterator.ClassPrototypeParsingType = newType;
                    iterator.Next();
                    tokenCount--;
                }
            }
        }
예제 #6
0
 /* Function: SetClassPrototypeParsingTypeBetween
  * Changes the <ClassPrototypeParsingType> of all the tokens between the current position and the passed iterator.
  * The token the ending iterator is on will not be changed.
  */
 public void SetClassPrototypeParsingTypeBetween(TokenIterator end, ClassPrototypeParsingType type)
 {
     Tokenizer.SetClassPrototypeParsingTypeBetween(this, end, type);
 }