public string GeneratePredicate(BDD pred) { if (!pred.IsLeaf && pred.Ordinal > 31) { throw new AutomataException(AutomataExceptionKind.OrdinalIsTooLarge); } string res; if (!predicate_cache.TryGetValue(pred, out res)) { if (OptimzeForASCIIinput) { var predascii = pred.And(ascii); var predascii_ranges = predascii.ToRanges(); var prednonascii = pred.Diff(ascii); if (prednonascii.IsEmpty) { res = RangesToCode(predascii_ranges); } else { var asciiCase = RangesToCode(predascii_ranges); var nonasciiCase = GeneratePredicateHelper(prednonascii); res = string.Format("(x <= 0x7F ? {0} : {1})", asciiCase, nonasciiCase); } } else { res = GeneratePredicateHelper(pred); } predicate_cache[pred] = res; } return(res); }
public string GeneratePredicate(BDD pred) { if (!pred.IsLeaf && pred.Ordinal > 31) throw new AutomataException(AutomataExceptionKind.OrdinalIsTooLarge); string res; if (!predicate_cache.TryGetValue(pred, out res)) { if (OptimzeForASCIIinput) { var predascii = pred.And(ascii); var predascii_ranges = predascii.ToRanges(); var prednonascii = pred.Diff(ascii); if (prednonascii.IsEmpty) { res = RangesToCode(predascii_ranges); } else { var asciiCase = RangesToCode(predascii_ranges); var nonasciiCase = GeneratePredicateHelper(prednonascii); res = string.Format("(c <= 0x7F ? {0} : {1})", asciiCase, nonasciiCase); } } else res = GeneratePredicateHelper(pred); predicate_cache[pred] = res; } return res; }