public static DfaMatchingState <TSetType> TakeTransition( SymbolicRegexMatcher <TSetType> matcher, DfaMatchingState <TSetType> currentStates, int mintermId, TSetType minterm) { if (currentStates.Node.Kind != SymbolicRegexKind.Or) { // Fall back to Brzozowski when the state is not a disjunction. return(BrzozowskiTransition.TakeTransition(matcher, currentStates, mintermId, minterm)); } SymbolicRegexBuilder <TSetType> builder = matcher._builder; Debug.Assert(builder._delta is not null); SymbolicRegexNode <TSetType> union = builder._nothing; uint kind = 0; // Produce the new list of states from the current list, considering transitions from members one at a time. Debug.Assert(currentStates.Node._alts is not null); foreach (SymbolicRegexNode <TSetType> oneState in currentStates.Node._alts) { DfaMatchingState <TSetType> nextStates = builder.MkState(oneState, currentStates.PrevCharKind); int offset = (nextStates.Id << builder._mintermsCount) | mintermId; DfaMatchingState <TSetType> p = Volatile.Read(ref builder._delta[offset]) ?? matcher.CreateNewTransition(nextStates, minterm, offset); // Observe that if p.Node is an Or it will be flattened. union = builder.MkOr2(union, p.Node); // kind is just the kind of the partition. kind = p.PrevCharKind; } return(builder.MkState(union, kind, true)); }
public static DfaMatchingState <TSetType> TakeTransition( SymbolicRegexMatcher <TSetType> matcher, DfaMatchingState <TSetType> currentState, int mintermId, TSetType minterm) { SymbolicRegexBuilder <TSetType> builder = matcher._builder; Debug.Assert(builder._delta is not null); int offset = (currentState.Id << builder._mintermsCount) | mintermId; return(Volatile.Read(ref builder._delta[offset]) ?? matcher.CreateNewTransition(currentState, minterm, offset)); }
internal string TestRegex_GenerateInput(SymbolicRegexBuilder <BV> builder, int nrOfMatches, int randomTextSizeLimit, SymbolicRegexNode <BV> sr) { if (nrOfMatches < 1) { throw new ArgumentOutOfRangeException(); } string str = sr.GenerateRandomMember(); for (int i = 1; i < nrOfMatches; i++) { if (randomTextSizeLimit > 0) { int k = rnd.Next(0, randomTextSizeLimit); string tmp = sr.GenerateRandomMember(); int j = rnd.Next(1, tmp.Length); str += tmp.Substring(0, j) + CreateRandomString(k) + tmp.Substring(j); } str += sr.GenerateRandomMember(); } return(str); }
internal void TestRegex_GenerateInputFile(SymbolicRegexBuilder <BV> builder, int nrOfMatches, int randomTextSizeLimit, SymbolicRegexNode <BV> sr, int id) { string str = TestRegex_GenerateInput(builder, nrOfMatches, randomTextSizeLimit, sr); File.WriteAllText(regexinputsPath + "input." + id + ".txt", str, System.Text.Encoding.Unicode); }