예제 #1
0
 void CheckSaturation(Option option)
 {
     bool minimalSaturation = option.ArgumentsCount >= option.Arity.MinimalOccurs;
     if (!minimalSaturation)
     {
         throw new RequiredArgumentIsMissingException(option.Switches.First());
     }
 }
예제 #2
0
        void ParseOption(Token token)
        {
            lastOption = GetOptionByToken(token);
            Token nextToken = tokens.NextToken();

            if (nextToken == null)
            {
                CheckSaturation(lastOption);
                lastOption.AddArgumentValue("true");
                ParsedOption.Add(lastOption);
            }
            else if (nextToken is OptionToken)
            {
                CheckSaturation(lastOption);
                lastOption.AddArgumentValue("true");
                ParsedOption.Add(lastOption);
                ParseOption(nextToken);
            }
            else if (nextToken is ArgumentToken)
            {
                if (IsFullSaturated(lastOption))
                {
                    ParseOptionArguments(nextToken);
                }
                else
                {
                    lastOption.AddArgumentValue("true");
                    ParsedOption.Add(lastOption);
                    ParseParameters(nextToken);
                }
            }
            else if (nextToken is TreatAsArgumentToken)
            {
                CheckSaturation(lastOption);
                lastOption.AddArgumentValue("true");
                ParsedOption.Add(lastOption);
                ParseParameters(tokens.NextToken());
            }
        }
예제 #3
0
 bool IsFullSaturated(Option option)
 {
     bool minimalSaturation = lastOption.ArgumentsCount >= lastOption.Arity.MinimalOccurs;
      bool maximalSaturation = lastOption.ArgumentsCount >= lastOption.Arity.MaximalOccurs;
      return (!minimalSaturation || (minimalSaturation && !maximalSaturation));
 }
예제 #4
0
 public void Option(Option option)
 {
     _options.Add(option);
 }