Exemplo n.º 1
0
        internal static PkgdefRegistryKeyPathSegment ParseRegistryKeyPath(int startIndex, string text)
        {
            PreCondition.AssertGreaterThanOrEqualTo(startIndex, 0, nameof(startIndex));
            PreCondition.AssertNotNullAndNotEmpty(text, nameof(text));
            PreCondition.AssertEqual(text[0], '[', "text[0]");

            Action <PkgdefIssue> onIssue   = PkgdefDocument.IgnoreIssue;
            PkgdefTokenizer      tokenizer = PkgdefTokenizer.Create(startIndex, text, onIssue);

            tokenizer.Next();
            return(PkgdefDocument.ParseRegistryKeyPath(tokenizer, onIssue));
        }
Exemplo n.º 2
0
        private static PkgdefSegment ParseSegment(PkgdefTokenizer tokenizer, Action <PkgdefIssue> onIssue)
        {
            PreCondition.AssertNotNull(tokenizer, nameof(tokenizer));
            PreCondition.AssertTrue(tokenizer.HasCurrent(), "tokenizer.HasCurrent()");
            PreCondition.AssertNotNull(onIssue, nameof(onIssue));

            PkgdefSegment result;

            switch (tokenizer.GetCurrent().GetTokenType())
            {
            case PkgdefTokenType.Whitespace:
                result = PkgdefSegment.Whitespace(tokenizer.GetCurrent().GetStartIndex(), tokenizer.GetCurrent().GetText());
                tokenizer.Next();
                break;

            case PkgdefTokenType.NewLine:
                result = PkgdefSegment.NewLine(tokenizer.GetCurrent().GetStartIndex(), tokenizer.GetCurrent().GetText());
                tokenizer.Next();
                break;

            case PkgdefTokenType.ForwardSlash:
                result = PkgdefDocument.ParseLineComment(tokenizer, onIssue);
                break;

            case PkgdefTokenType.LeftSquareBracket:
                result = PkgdefDocument.ParseRegistryKeyPath(tokenizer, onIssue);
                break;

            case PkgdefTokenType.AtSign:
            case PkgdefTokenType.DoubleQuote:
                result = PkgdefDocument.ParseRegistryKeyDataItem(tokenizer, onIssue);
                break;

            default:
                result = PkgdefSegment.Unrecognized(tokenizer.GetCurrent().GetStartIndex(), tokenizer.GetCurrent().GetText());
                tokenizer.Next();
                break;
            }

            return(result);
        }
Exemplo n.º 3
0
 public static PkgdefRegistryKeyPathSegment RegistryKeyPath(int startIndex, string text)
 {
     return(PkgdefDocument.ParseRegistryKeyPath(startIndex, text));
 }