public static ITokenMatching Has(this ITokenMatching self, IMaker pattern) { if (!(self is IMatchedTokenMatching)) { return(self); } return(pattern.TryMake(self)); }
public static ITokenMatching <T1, T2> Has <T1, T2>(this ITokenMatching <T1> self, IMaker <T2> pattern) where T1 : class where T2 : class { if (self is IMatchedTokenMatching <T1> firstMatched) { var res = pattern.TryMake(firstMatched); if (res is IMatchedTokenMatching <T2> matched) { return(TokenMatching <T1, T2> .MakeMatch(firstMatched, firstMatched.Value, matched.Value, matched.EndIndex)); } } return(TokenMatching <T1, T2> .MakeNotMatch(self.Context)); }
public static ITokenMatching OptionalHas(this ITokenMatching self, IMaker pattern) { if (!(self is IMatchedTokenMatching)) { return(self); } var next = pattern.TryMake(self); if (next is IMatchedTokenMatching) { return(next); } return(self); }
public static ITokenMatching <T> Has <T>(this ITokenMatching <T> self, IMaker pattern) { if (!(self is IMatchedTokenMatching <T> matchedTokenMatching)) { return(self); } var patternMatch = pattern.TryMake(self); if (!(patternMatch is IMatchedTokenMatching matchedPattern)) { return(TokenMatching <T> .MakeNotMatch(patternMatch.Context)); } return(TokenMatching <T> .MakeMatch(matchedPattern.Tokens, matchedPattern.Context, matchedTokenMatching.Value)); }
public static ITokenMatching <T> Has <T>(this ITokenMatching self, IMaker <T> pattern, out T t) { t = default; if (!(self is IMatchedTokenMatching firstMatched)) { return(TokenMatching <T> .MakeNotMatch(self.Context)); } var res = pattern.TryMake(firstMatched); if (res is IMatchedTokenMatching <T> matched) { t = matched.Value; } return(res); }
public static ITokenMatching <T> Has <T>(this ITokenMatching self, IMaker <T> pattern) where T : class { if (!(self is IMatchedTokenMatching firstMatched)) { return(TokenMatching <T> .MakeNotMatch(self.Context)); } var res = pattern.TryMake(firstMatched); if (res is IMatchedTokenMatching <T> matched) { return(matched); } return(res); }
public static ITokenMatching OptionalHas <T>(this ITokenMatching self, IMaker <T> pattern, out T t) where T : class { if (!(self is IMatchedTokenMatching matchedTokenMatching)) { t = default; return(self); } var res = pattern.TryMake(matchedTokenMatching); if (res is IMatchedTokenMatching <T> matched) { t = matched.Value; return(res); } t = default; return(self); }
public static ITokenMatching <T> Has <T>(this ITokenMatching self, IMaker <T> pattern, out T t) { if (!(self is IMatchedTokenMatching firstMatched)) { #pragma warning disable CS8601 // Possible null reference assignment. t = default; #pragma warning restore CS8601 // Possible null reference assignment. return(TokenMatching <T> .MakeNotMatch(self.Context)); } var res = pattern.TryMake(firstMatched); if (res is IMatchedTokenMatching <T> matched) { t = matched.Value; return(res); } #pragma warning disable CS8601 // Possible null reference assignment. t = default; #pragma warning restore CS8601 // Possible null reference assignment. return(res); }