コード例 #1
0
 internal static TemplateException ArgumentCannotContainOptions(string template, TemplateToken token)
 {
     return(TemplateExceptionFactory.Create(
                template, token,
                "Arguments can not contain options.",
                "Not permitted."));
 }
コード例 #2
0
 internal static TemplateException UnterminatedValueName(string template, TemplateToken token)
 {
     return(TemplateExceptionFactory.Create(
                template, token,
                $"Encountered unterminated value name '{token.Value}'.",
                "Unterminated value name."));
 }
コード例 #3
0
 internal static TemplateException UnexpectedCharacter(string template, int position, char character)
 {
     return(TemplateExceptionFactory.Create(
                template,
                new TemplateToken(TemplateToken.Kind.Unknown, position, $"{character}", $"{character}"),
                $"Encountered unexpected character '{character}'.",
                "Unexpected character."));
 }
コード例 #4
0
        internal static TemplateException LongOptionMustHaveMoreThanOneCharacter(string template, TemplateToken token)
        {
            // Rewrite the token to point to the option name instead of the whole option.
            token = new TemplateToken(token.TokenKind, token.Position + 2, token.Value, token.Value);

            return(TemplateExceptionFactory.Create(template, token,
                                                   "Long option names must consist of more than one character.",
                                                   "Invalid option name."));
        }
コード例 #5
0
        internal static TemplateException ShortOptionMustOnlyBeOneCharacter(string template, TemplateToken token)
        {
            // Rewrite the token to point to the option name instead of the whole option.
            token = new TemplateToken(token.TokenKind, token.Position + 1, token.Value, token.Value);

            return(TemplateExceptionFactory.Create(template, token,
                                                   "Short option names can not be longer than one character.",
                                                   "Invalid option name."));
        }
コード例 #6
0
        internal static TemplateException InvalidCharacterInOptionName(string template, TemplateToken token, char character)
        {
            // Rewrite the token to point to the invalid character instead of the whole value.
            token = new TemplateToken(
                token.TokenKind,
                (token.TokenKind == TemplateToken.Kind.ShortName ? token.Position + 1 : token.Position + 2) + token.Value.IndexOf(character),
                token.Value, character.ToString(CultureInfo.InvariantCulture));

            return(TemplateExceptionFactory.Create(template, token,
                                                   $"Encountered invalid character '{character}' in option name.",
                                                   "Invalid character."));
        }
コード例 #7
0
        internal static TemplateException OptionNamesCannotStartWithDigit(string template, TemplateToken token)
        {
            // Rewrite the token to point to the option name instead of the whole string.
            token = new TemplateToken(
                token.TokenKind,
                token.TokenKind == TemplateToken.Kind.ShortName ? token.Position + 1 : token.Position + 2,
                token.Value, token.Value);

            return(TemplateExceptionFactory.Create(template, token,
                                                   "Option names cannot start with a digit.",
                                                   "Invalid option name."));
        }
コード例 #8
0
 internal static TemplateException OptionsMustHaveName(string template, TemplateToken token)
 {
     return(TemplateExceptionFactory.Create(template, token,
                                            "Options without name are not allowed.",
                                            "Missing option name."));
 }
コード例 #9
0
 internal static TemplateException MultipleValuesAreNotSupported(string template, TemplateToken token)
 {
     return(TemplateExceptionFactory.Create(template, token,
                                            "Multiple values are not supported.",
                                            "Too many values."));
 }
コード例 #10
0
 internal static TemplateException ArgumentsMustHaveValueName(string template)
 {
     return(TemplateExceptionFactory.Create(template, null,
                                            "Arguments must have a value name.",
                                            "Missing value name."));
 }
コード例 #11
0
 internal static TemplateException MissingLongAndShortName(string template, TemplateToken?token)
 {
     return(TemplateExceptionFactory.Create(template, token,
                                            "No long or short name for option has been specified.",
                                            "Missing option. Was this meant to be an argument?"));
 }
コード例 #12
0
 internal static TemplateException MultipleShortOptionNamesNotAllowed(string template, TemplateToken token)
 {
     return(TemplateExceptionFactory.Create(template, token,
                                            "Multiple short option names are not supported.",
                                            "Too many short options."));
 }