Пример #1
0
        public object Parse(IEnumerable <IArgumentToken> tokens)
        {
            builder = builderFactory();

            var argumentsQueue = new Queue <IArgumentToken>(tokens);

            while (argumentsQueue.Any())
            {
                IArgumentToken current = argumentsQueue.Dequeue();
                switch (current)
                {
                case OptionsGroupToken optionsGroup:
                    HandleOptionsGroup(optionsGroup);
                    break;

                case AssignedValueToken assignedValueToken:
                    HandleAssignedValue(assignedValueToken);
                    break;

                case IOptionToken option:
                    HandleOption(option);
                    break;

                case IValueToken value:
                    HandleValue(value);
                    break;
                }
            }

            EnsureLastOptionSet();
            return(builder.Parse());
        }