internal static PkgdefRegistryKeyPathSegment ParseRegistryKeyPath(PkgdefTokenizer tokenizer, Action <PkgdefIssue> onIssue) { PreCondition.AssertNotNull(tokenizer, nameof(tokenizer)); PreCondition.AssertTrue(tokenizer.HasCurrent(), "tokenizer.HasCurrent()"); PreCondition.AssertEqual(tokenizer.GetCurrent().GetTokenType(), PkgdefTokenType.LeftSquareBracket, "tokenizer.GetCurrent().GetTokenType()"); PreCondition.AssertNotNull(onIssue, nameof(onIssue)); List <PkgdefToken> tokens = new List <PkgdefToken>() { tokenizer.TakeCurrent() }; while (tokenizer.HasCurrent()) { PkgdefTokenType tokenType = tokenizer.GetCurrent().GetTokenType(); if (tokenType == PkgdefTokenType.NewLine) { break; } else { tokens.Add(tokenizer.TakeCurrent()); if (tokenType == PkgdefTokenType.RightSquareBracket) { break; } } } PkgdefRegistryKeyPathSegment result = new PkgdefRegistryKeyPathSegment(tokens); if (result.GetRightSquareBracket() == null) { onIssue(new PkgdefIssue(result.GetStartIndex(), result.GetLength(), "Missing registry key path right square bracket (']').")); } return(result); }
public bool Equals(PkgdefRegistryKeyPathSegment rhs) { return(rhs != null && this.tokens.SequenceEqual(rhs.tokens)); }