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); }
/// <summary> /// For all letters in the bdd add their lower and upper case equivalents. /// </summary> public BDD Apply(BDD bdd) { if (domain.And(bdd).IsEmpty) return bdd; else return bdd.And(IgnoreCaseRel).ShiftRight(16); }
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; }
/// <summary> /// For all letters in the bdd add their lower and upper case equivalents. /// </summary> public BDD Apply(BDD bdd) { if (domain.And(bdd).IsEmpty) { return(bdd); } else { return(bdd.And(IgnoreCaseRel).ShiftRight(16)); } }
public bool IsInDomain(char c) { BDD c_bdd = solver.MkCharConstraint(c); if (c_bdd.And(domain).IsEmpty) { return(false); } else { return(true); } }
/// <summary> /// For all letters in the bdd add their lower and upper case equivalents. /// </summary> public BDD Apply(BDD bdd) { if (domain.And(bdd).IsEmpty) { return(bdd); } else { var ignorecase = bdd.And(IgnoreCaseRel).ShiftRight(16); var res = ignorecase.Or(bdd); return(res); } }