예제 #1
0
        /// <summary>
        /// Matches an option name (or names depending on the option styles enabled) preceeded by the '+' sign.
        /// </summary>
        /// <returns>An <see cref="OptionNameToken"/> representing the name (and style) of the first option
        /// in the sequence read.</returns>
        /// <remarks>This method calls <see cref="MatchGroupedOptionNames"/> if the <see cref="OptionStyles.Group"/>
        /// style is enabled, otherwise <see cref="MatchLongOptionName"/>.</remarks>
        private Token MatchPlusOption()
        {
            Debug.Assert(LA(1) == '+');
            SkipCharacters(1);

            mCurrentOptionStyle = OptionStyles.Plus;

            if (OptionStyleManager.IsAllEnabled(EnabledOptionStyles, OptionStyles.Group))
            {
                return(MatchGroupedOptionNames());
            }
            else
            {
                return(MatchLongOptionName());
            }
        }
예제 #2
0
        /// <summary>
        /// Gets the next token from the input.
        /// </summary>
        /// <returns>the next token from the input or a null reference if no more tokens are available.</returns>
        public Token GetNextToken()
        {
            if (!mTokenQueue.IsEmpty)
            {
                return(mTokenQueue.Dequeue());
            }

            // Cache LA(1), it will be used a lot
            int la1;

            // Skip any whitespace
            while ((la1 = LA(1)) != -1 && IsWhiteSpace(la1))
            {
                ReadCharacter();
            }

            if (la1 == -1)    // No more tokens (or characters) to read
            {
                return(null);
            }

            if (la1 == '-' && OptionStyleManager.IsAnyEnabled(EnabledOptionStyles, OptionStyles.Unix))
            {
                if (LA(2) == '-')
                {
                    if (IsWhiteSpace(LA(3)))
                    {
                        return(MatchEndOption());
                    }
                    else if (OptionStyleManager.IsAllEnabled(EnabledOptionStyles, OptionStyles.LongUnix))
                    {
                        return(MatchLongUnixOption());
                    }
                }

                if (OptionStyleManager.IsAllEnabled(EnabledOptionStyles, OptionStyles.ShortUnix))
                {
                    return(MatchShortUnixOption());
                }
            }

            if (la1 == '/' && OptionStyleManager.IsAllEnabled(EnabledOptionStyles, OptionStyles.Windows))
            {
                return(MatchWindowsOption());
            }

            if (la1 == '+' && OptionStyleManager.IsAllEnabled(EnabledOptionStyles, OptionStyles.Plus))
            {
                return(MatchPlusOption());
            }

            if (la1 == '@' && OptionStyleManager.IsAllEnabled(EnabledOptionStyles, OptionStyles.File))
            {
                return(MatchFileOption());
            }

            if (IsAssignmentCharacter(la1))
            {
                return(MatchAssignmentCharacter());
            }

            return(MatchValue());
        }