Ejemplo n.º 1
0
        /// <summary>
        /// Adds the <see cref="OptionToken"/> to the tokens and sets the context of the tokenizer.
        /// </summary>
        /// <param name="tokens">The tokens where the argument will be add.</param>
        /// <param name="option">The option to add.</param>
        /// <param name="options">The options and their arities.</param>
        /// <param name="treatMode">The treat mode.</param>
        /// <param name="argumentCount">The argument count of the last option.</param>
        /// <param name="optionArity">The option arity.</param>
        void AddOption(List<Token> tokens, string option, IDictionary<string, OptionArity> options,
            ref TreatMode treatMode, ref uint argumentCount, ref OptionArity? optionArity)
        {
            if (options.ContainsKey(option))
            {
                AddOption(tokens, option);

                OptionArity arity = options[option];
                if (arity.MinimalOccurs > 0)
                {
                    treatMode = TreatMode.OptionArgument;
                    argumentCount = 0;
                    optionArity = arity;
                }
            }
            else
            {
                AddOption(tokens, option);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the <see cref="ArgumentToken"/> to the tokens and sets the context of the tokenizer.
        /// </summary>
        /// <param name="tokens">The tokens where the argument will be add.</param>
        /// <param name="argument">The argument to add.</param>
        /// <param name="treatMode">The treat mode.</param>
        /// <param name="argumentCount">The argument count of the last option.</param>
        /// <param name="optionArity">The option arity.</param>
        void AddArgument(List<Token> tokens, string argument, ref TreatMode treatMode, ref uint argumentCount, ref OptionArity? optionArity)
        {
            Debug.Assert(optionArity.HasValue && argumentCount < optionArity.Value.MaximalOccurs, "unexpected option arity");

            AddArgument(tokens, argument);

            argumentCount++;
            if (argumentCount >= optionArity.Value.MinimalOccurs)
            {
                treatMode = TreatMode.None;
            }

            if (argumentCount == optionArity.Value.MaximalOccurs)
            {
                optionArity = null;
                argumentCount = uint.MaxValue;
            }
        }