Example #1
0
        /// <summary>
        /// Determines whether the specified character is an assignment character for the <see cref="OptionStyles"/>
        /// currently being parsed.
        /// </summary>
        /// <param name="ch">The character to check.</param>
        /// <returns>
        ///     <c>true</c> if the specified character is an assignment character for the <see cref="OptionStyles"/>
        /// currently being parsed; otherwise, <c>false</c>.
        /// </returns>
        private bool IsAssignmentCharacter(int ch)
        {
            OptionStyles optionStyle;

            return(mAssignmentCharacters.Find((char)ch, out optionStyle) && OptionStyleManager.IsAnyEnabled(optionStyle, EnabledOptionStyles) &&
                   OptionStyleManager.IsAnyEnabled(optionStyle, mCurrentOptionStyle));
        }
Example #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());
        }