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 HelperPredicates(CharSetSolver solver, bool OptimzeForAsciiInput) { this.solver = solver; helper_predicates = new List<string>(); predicate_cache = new Dictionary<BDD, string>(); ascii = solver.MkRangeConstraint('\0', '\x7F'); this.OptimzeForASCIIinput = OptimzeForAsciiInput; }
private static BDD BDDOf(IEnumerable <char> alphabet, CharSetSolver solver) { bool fst = true; BDD safeCharCond = null; foreach (var c in alphabet) { if (fst) { fst = false; safeCharCond = solver.MkCharConstraint(false, c); } else { safeCharCond = solver.MkOr(safeCharCond, solver.MkCharConstraint(false, c)); } } return(safeCharCond); }
public async Task <ActionResult> Contact(Email model) { if (ModelState.IsValid) { try { Email e = new Email(); var fromE = e.FromEmail; BDD b = new BDD(); var body = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>"; var message = new System.Net.Mail.MailMessage(); message.From = new MailAddress(fromE); // replace with valid value message.To.Add(new MailAddress("*****@*****.**")); // replace with valid value message.Subject = "Your email subject"; message.Body = string.Format(body, model.FromName, model.FromEmail, model.Message); message.IsBodyHtml = true; using (var smtp = new SmtpClient()) { var credential = new NetworkCredential { UserName = "******", // replace with valid value Password = b.PassMail() // replace with valid value }; smtp.Credentials = credential; smtp.Host = "smtp.ionos.fr"; smtp.Port = 587; smtp.EnableSsl = false; await smtp.SendMailAsync(message); return(RedirectToAction("Sent")); } } catch (Exception ex) { var msgEx = ex.Message; return(RedirectToAction("SentNOK")); } } return(View(model)); }
static void Main(string[] args) { string answer; byte quit = 0; do { IndexView.menu(); answer = Console.ReadLine(); switch (answer) { case "1": Console.Clear(); BDD.albumList(); Console.WriteLine("---------------------------------------------------------------------"); BDD.bookList(); break; case "2": break; case "3": break; case "4": break; case "5": break; case "6": quit = 1; break; default: BDD.albumList(); break; } } while (quit == 0); Console.WriteLine("Au revoir"); Console.ReadLine(); }
/** * Convert a BDD that to a list of indices of this domain. * Same as getVarIndices(BDD), except only 'max' indices * are extracted. * * @param bdd bdd that is the disjunction of domain indices * @param max maximum number of entries to be returned * * @see #ithVar(long) */ public BigInteger[] getVarIndices(BDD bdd, int max) { BDD myvarset = set(); // can't use var here, must respect subclass a factory may provide int n = (int)bdd.satCount(myvarset); if (max != -1 && n > max) { n = max; } BigInteger[] res = new BigInteger[n]; Iterator it = bdd.iterator(myvarset); for (int i = 0; i < n; i++) { BDD bi = (BDD)it.next(); res[i] = bi.scanVar(this); } myvarset.free(); return(res); }
private static void WriteIgnoreCaseBDD(StreamWriter sw) { sw.WriteLine(" /// <summary>Serialized BDD for mapping characters to their case-ignoring equivalence classes in the default (en-US) culture.</summary>"); var solver = new CharSetSolver(); List <EquivalenceClass> ignoreCaseEquivalenceClasses = ComputeIgnoreCaseEquivalenceClasses(solver, new CultureInfo(DefaultCultureName)); BDD ignorecase = solver.False; foreach (EquivalenceClass ec in ignoreCaseEquivalenceClasses) { // Create the Cartesian product of ec._set with itself BDD crossproduct = solver.And(solver.ShiftLeft(ec._set, 16), ec._set); // Add the product into the overall lookup table ignorecase = solver.Or(ignorecase, crossproduct); } sw.Write(" public static readonly byte[] IgnoreCaseEnUsSerializedBDD = "); GeneratorHelper.WriteByteArrayInitSyntax(sw, ignorecase.SerializeToBytes()); sw.WriteLine(";"); }
// Envoie la liste de tous les clients public static List <ClientBOL> GetClients() { List <Client> liste = BDD.AfficheListeClient(); List <ClientBOL> listeBOL = new List <ClientBOL>(); foreach (Client c in liste) { ClientBOL client1 = new ClientBOL(); client1.Id = c.Id; client1.Nom = c.Nom; client1.Prenom = c.Prenom; client1.CarteFidelite = c.CarteFidelite; client1.Societe = c.Societe; client1.Civilite = c.Civilite; listeBOL.Add(client1); } return(listeBOL); }
internal static Automaton <BDD> computeDFA(List <string> variables, BDD alphabet, CharSetSolver solver, string set) { int setbit = variables.IndexOf(set); Dictionary <Pair <int, int>, Automaton <BDD> > dic; if (!hashedDfa.ContainsKey(alphabet)) { hashedDfa[alphabet] = new Dictionary <Pair <int, int>, Automaton <BDD> >(); } dic = hashedDfa[alphabet]; var hash = new Pair <int, int>(variables.Count, setbit); if (dic.ContainsKey(hash)) { return(dic[hash]); } //Create conditions that bit in pos1 is smaller than pos2 var trueBv = solver.MkSetFromRange(0, (uint)(Math.Pow(2, variables.Count + 16) - 1), variables.Count + 16 - 1); var posIs1 = solver.MkAnd(trueBv, solver.MkSetWithBitTrue(setbit)); var posIs0 = solver.MkAnd(trueBv, solver.MkSetWithBitFalse(setbit)); //Create automaton for condition var moves = new Move <BDD>[] { new Move <BDD>(0, 0, posIs0), new Move <BDD>(0, 1, posIs1), new Move <BDD>(1, 1, posIs0) }; //Generate the dfa correpsonding to regexp var dfa = Automaton <BDD> .Create(0, new int[] { 1 }, moves); if (hashing) { dic[hash] = dfa; } return(dfa); }
public void TestIgnoreCaseTransformer_SimpleCases() { CharSetSolver solver = new CharSetSolver(); int t = System.Environment.TickCount; IgnoreCaseTransformer ic = new IgnoreCaseTransformer(solver); //simple test first: BDD a2c = solver.MkRangeConstraint('a', 'c'); BDD a2cA2C = ic.Apply(a2c); BDD a2cA2C_expected = a2c.Or(solver.MkRangeConstraint('A', 'C')); Assert.AreEqual <BDD>(a2cA2C, a2cA2C_expected); //digits are not changed BDD ascii_digits = solver.MkRangeConstraint('0', '9'); BDD ascii_digits1 = ic.Apply(ascii_digits); Assert.AreEqual <BDD>(ascii_digits1, ascii_digits); var tt = ic.Apply(solver.True); var tt_compl = solver.MkNot(tt); Assert.AreEqual <BDD>(ic.Apply(solver.True), solver.True); }
public JsonResult AsignarVisto(int id) { try { var deuda = BDD.TBL_DEUDA.FirstOrDefault(o => o.DEU_ID == id); deuda.DEU_CHECK = true; BDD.TBL_DEUDA.Attach(deuda); BDD.Entry(deuda).State = System.Data.Entity.EntityState.Modified; BDD.SaveChanges(); return(JsonExito()); } catch (Exception ex) { Logger(ex); return(JsonError("Hubo un error al realizar esta acción, consulte con el administrador del sistema.")); } }
private IgnoreCaseRelation CreateIgnoreCaseRelationInvariant() { EnsureDefault(); // Compute the invariant table based off of default. // In the default (en-US) culture: Turkish_I_withDot = i = I // In the invariant culture: i = I, while Turkish_I_withDot is case-insensitive BDD tr_I_withdot_BDD = _solver.CharConstraint(Turkish_I_WithDot); // Since Turkish_I_withDot is case-insensitive in invariant culture, remove it from the default (en-US culture) table. BDD inv_table = _solver.And(_relationDefault.Instance, _solver.Not(tr_I_withdot_BDD)); // Next, remove Turkish_I_withDot from the RHS of the relation. // This also effectively removes Turkish_I_withDot from the equivalence sets of 'i' and 'I'. BDD instance = _solver.And(inv_table, _solver.Not(_solver.ShiftLeft(tr_I_withdot_BDD, 16))); // Remove Turkish_I_withDot from the domain of casesensitive characters in the default case BDD instanceDomain = _solver.And(instance, _solver.Not(tr_I_withdot_BDD)); _relationInvariant = new IgnoreCaseRelation(instance, instanceDomain); return(_relationInvariant); }
/// <summary> /// For all letters in the bdd add their lower and upper case equivalents. /// This operation depends on culture for i, I, '\u0130', and '\u0131'; /// culture="" means InvariantCulture while culture=null means to use the current culture. /// </summary> public BDD Apply(BDD bdd, string?culture = null) { // First get the culture specific relation IgnoreCaseRelation relation = GetIgnoreCaseRelation(culture); if (_solver.And(relation.InstanceDomain, bdd).IsEmpty) { // No elements need to be added return(bdd); } // Compute the set of all characters that are equivalent to some element in bdd. // restr is the relation restricted to the relevant characters in bdd. // This conjunction works because bdd is unspecified for bits > 15. BDD restr = _solver.And(bdd, relation.Instance); // ShiftRight essentially produces the LHS of the relation (char X char) that restr represents. BDD ignorecase = _solver.ShiftRight(restr, 16); // The final set is the union of all the characters. return(_solver.Or(ignorecase, bdd)); }
/// <summary> /// Returns an automaton where transitions between states are collapsed to a single one /// </summary> /// <param name="automaton"></param> /// <param name="solver"></param> /// <returns></returns> public static Automaton <BDD> normalizeMoves(Automaton <BDD> automaton, CharSetSolver solver) { List <Move <BDD> > normMoves = new List <Move <BDD> >(); foreach (var sourceState in automaton.States) { Dictionary <int, BDD> moveConditions = new Dictionary <int, BDD>(); foreach (var moveFromSourceState in automaton.GetMovesFrom(sourceState)) { var target = moveFromSourceState.TargetState; BDD oldCondition = null; if (moveConditions.ContainsKey(target)) { oldCondition = moveConditions[target]; } else { oldCondition = solver.False; } if (!moveFromSourceState.IsEpsilon) { moveConditions[target] = solver.MkOr(oldCondition, moveFromSourceState.Label); } else { normMoves.Add(moveFromSourceState); } } foreach (var targetState in moveConditions.Keys) { normMoves.Add(new Move <BDD>(sourceState, targetState, moveConditions[targetState])); } } return(Automaton <BDD> .Create(automaton.InitialState, automaton.GetFinalStates(), normMoves)); }
public void TestRanges2() { BitWidth enc = BitWidth.BV7; CharSetSolver solver = new CharSetSolver(enc); BDD cond = solver.MkCharSetFromRegexCharClass(@"\w"); int nodes = cond.CountNodes(); Pair <uint, uint>[] ranges = solver.ToRanges(cond); BDD cond2 = solver.MkCharSetFromRanges(ranges); Assert.AreSame(cond, cond2); int nodes2 = cond2.CountNodes(); Assert.AreEqual <uint>((uint)'0', ranges[0].First); Assert.AreEqual <uint>((uint)'9', ranges[0].Second); Assert.AreEqual <uint>((uint)'A', ranges[1].First); Assert.AreEqual <uint>((uint)'Z', ranges[1].Second); Assert.AreEqual <uint>((uint)'_', ranges[2].First); Assert.AreEqual <uint>((uint)'_', ranges[2].Second); Assert.AreEqual <uint>((uint)'a', ranges[3].First); Assert.AreEqual <uint>((uint)'z', ranges[3].Second); Assert.AreEqual <int>(4, ranges.Length); }
public void TestRanges2b() { BitWidth enc = BitWidth.BV16; CharSetSolver solver = new CharSetSolver(enc); BDD cond = solver.MkCharSetFromRegexCharClass(@"\w"); var ranges1 = solver.ToRanges(cond); var cond1 = solver.MkCharSetFromRanges(ranges1); Tuple <uint, uint>[] ranges = solver.ToRanges(cond1); var cond2 = solver.MkCharSetFromRanges(ranges); Assert.AreSame(cond1, cond2); Assert.AreSame(cond, cond1); //cond.ToDot("cond.dot"); Assert.AreEqual <uint>((uint)'0', ranges[0].Item1); Assert.AreEqual <uint>((uint)'9', ranges[0].Item2); Assert.AreEqual <uint>((uint)'A', ranges[1].Item1); Assert.AreEqual <uint>((uint)'Z', ranges[1].Item2); Assert.AreEqual <uint>((uint)'_', ranges[2].Item1); Assert.AreEqual <uint>((uint)'_', ranges[2].Item2); Assert.AreEqual <uint>((uint)'a', ranges[3].Item1); Assert.AreEqual <uint>((uint)'z', ranges[3].Item2); }
/** * Builds a BDD which is true for all the possible assignments to the * variable blocks that makes the blocks equal. * * Compare to fdd_equals/fdd_equ. * * @param that * @return BDD */ public BDD buildEquals(BDDDomain that) { if (!this.size().equals(that.size())) { throw new BDDException("Size of " + this + " != size of that " + that + "( " + this.size() + " vs " + that.size() + ")"); } BDDFactory factory = getFactory(); BDD e = factory.one(); int[] this_ivar = this.vars(); int[] that_ivar = that.vars(); for (int n = 0; n < this.varNum(); n++) { BDD a = factory.ithVar(this_ivar[n]); BDD b = factory.ithVar(that_ivar[n]); a.biimpWith(b); e.andWith(a); } return(e); }
internal override Automaton <BDD> getDFA(List <string> variables, BDD alphabet, CharSetSolver solver) { //Automaton<BDD> for formula var varCopy = new List <string>(variables); varCopy.Insert(0, variable); var autPhi = phi.getDFA(varCopy, alphabet, solver); //Remove first bit from each move var newMoves = new List <Move <BDD> >(); foreach (var move in autPhi.GetMoves()) { var newCond = solver.LShiftRight(move.Label); newMoves.Add(new Move <BDD>(move.SourceState, move.TargetState, newCond)); } var dfanew = Automaton <BDD> .Create(autPhi.InitialState, autPhi.GetFinalStates(), newMoves).Determinize(solver); var dfamin = dfanew.Minimize(solver); return(dfamin); }
private void Rechercher_Percage() { Bdd = new BDD(); Predicate <Component2> Test = c => { if (!c.IsHidden(true) && (c.TypeDoc() == eTypeDoc.Piece)) { Bdd.Decompter(c); } return(false); }; if (MdlBase.TypeDoc() == eTypeDoc.Piece) { Test(MdlBase.eComposantRacine()); } else { MdlBase.eRecParcourirComposants(Test); } }
/** * <p>Returns what corresponds to a disjunction of all possible values of this * domain. This is more efficient than doing ithVar(0) OR ithVar(1) ... * explicitly for all values in the domain.</p> * * <p>Compare to fdd_domain.</p> */ public BDD domain() { BDDFactory factory = getFactory(); /* Encode V<=X-1. V is the variables in 'var' and X is the domain size */ BigInteger val = size().subtract(BigInteger.ONE); BDD d = factory.one(); int[] ivar = vars(); for (int n = 0; n < this.varNum(); n++) { if (val.testBit(0)) { d.orWith(factory.nithVar(ivar[n])); } else { d.andWith(factory.nithVar(ivar[n])); } val = val.shiftRight(1); } return(d); }
internal override Automaton <BDD> getDFA(List <string> variables, BDD alphabet, CharSetSolver solver) { int varbit = variables.IndexOf(var1); Dictionary <Pair <int, int>, Automaton <BDD> > dic; if (!hashedDfa.ContainsKey(alphabet)) { hashedDfa[alphabet] = new Dictionary <Pair <int, int>, Automaton <BDD> >(); } dic = hashedDfa[alphabet]; var hash = new Pair <int, int>(variables.Count, varbit); if (dic.ContainsKey(hash)) { return(dic[hash]); } //Create conditions var trueBv = solver.MkSetFromRange(0, (uint)(Math.Pow(2, variables.Count + 7) - 1), variables.Count + 7 - 1); var posis1 = solver.MkAnd(trueBv, solver.MkSetWithBitTrue(varbit)); var posis0 = solver.MkAnd(trueBv, solver.MkSetWithBitFalse(varbit)); //Create automaton for condition var moves = new Move <BDD>[] { new Move <BDD>(0, 1, posis1), new Move <BDD>(1, 1, posis0) }; var dfa = Automaton <BDD> .Create(0, new int[] { 1 }, moves).Determinize(solver).Minimize(solver); dic[hash] = dfa; return(dfa); }
public ActionResult Index(AguaPotablePuquereo.Models.SQL.TBL_PAGINAS_ADMINISTRABLES model) { try { var padm = BDD.TBL_PAGINAS_ADMINISTRABLES.FirstOrDefault(o => o.PADM_ID == model.PADM_ID); padm.PADM_HTML_TEXT = model.PADM_HTML_TEXT; BDD.TBL_PAGINAS_ADMINISTRABLES.Attach(padm); BDD.Entry(padm).State = System.Data.Entity.EntityState.Modified; BDD.SaveChanges(); ViewBag.Exito = true; return(View(model)); } catch (Exception ex) { ViewBag.Exito = false; Logger(ex); } return(View(model)); }
private void MkExprPred(BDD moveCond, out Expr chExpr, out Expr chPred) { if (css.ComputeDomainSize(moveCond) == 1) { var ch = (char)css.Choose(moveCond); chExpr = stb.Solver.MkCharExpr(ch); chPred = stb.Solver.MkCharConstraint(ch); } else if (css.ComputeDomainSize(css.MkNot(moveCond)) == 1) { var ch = (char)css.Choose(css.MkNot(moveCond)); chExpr = stb.MkInputVariable(stb.Solver.CharSort); chPred = stb.Solver.MkNot(stb.Solver.MkCharConstraint(ch)); } else if (css.ComputeDomainSize(moveCond) == 2) { var ch1 = (char)css.GetMin(moveCond); var ch2 = css.GetMax(moveCond); chExpr = stb.MkInputVariable(stb.Solver.CharSort); chPred = stb.Solver.MkOr(stb.Solver.MkCharConstraint(ch1), stb.Solver.MkCharConstraint(ch2)); } else if (css.ComputeDomainSize(css.MkNot(moveCond)) == 2) { var ch1 = (char)css.GetMin(css.MkNot(moveCond)); var ch2 = css.GetMax(css.MkNot(moveCond)); chExpr = stb.MkInputVariable(stb.Solver.CharSort); chPred = stb.Solver.MkAnd(stb.Solver.MkNot(stb.Solver.MkCharConstraint(ch1)), stb.Solver.MkNot(stb.Solver.MkCharConstraint(ch2))); } else { var ranges = css.ToRanges(moveCond); chPred = stb.Solver.MkRangesConstraint(false, Array.ConvertAll(ranges, r => new char[] { (char)r.Item1, (char)r.Item2 })); chExpr = stb.MkInputVariable(stb.Solver.CharSort); } }
public JsonResult EliminarCliente(int id) { try { var cliente = BDD.TBL_CLIENTE.FirstOrDefault(o => o.CLI_ID == id); foreach (var item in cliente.TBL_DEUDA) { if (item.PAG_ID != null) { var pago = BDD.TBL_PAGOS.FirstOrDefault(o => o.PAG_ID == item.PAG_ID); pago.PAG_VIGENCIA = false; BDD.TBL_PAGOS.Attach(pago); BDD.Entry(pago).State = System.Data.Entity.EntityState.Modified; BDD.SaveChanges(); } } BDD.Database.ExecuteSqlCommand("DELETE FROM TBL_DEUDA WHERE CLI_ID = " + id); BDD.Database.ExecuteSqlCommand("DELETE FROM TBL_PAGOS WHERE CLI_ID = " + id); BDD.TBL_CLIENTE.Remove(cliente); BDD.Entry(cliente).State = System.Data.Entity.EntityState.Deleted; BDD.SaveChanges(); return(JsonExito("Cliente eliminado con éxito")); } catch (Exception ex) { Logger(ex); return(JsonError("No se ha podido eliminar al cliente")); } }
public string Describe(BDD label) { return converter.Describe(label); }
internal override Automaton <BDD> getDFA(List <string> variables, BDD alphabet, CharSetSolver solver) { //Build DFA corresponding to regexp return(computeDFA(variables, alphabet, solver, set1, set2)); }
public IgnoreCaseTransformer(CharSetSolver charSetSolver) { this.solver = charSetSolver; IgnoreCaseRel = charSetSolver.Deserialize(Microsoft.Automata.Internal.Generated.IgnoreCaseRelation.ignorecase); domain = IgnoreCaseRel.ShiftRight(16); }
internal override Automaton <BDD> getDFA(List <string> variables, BDD alphabet, CharSetSolver solver) { return(computeDFA(variables, alphabet, solver, set, pred)); }
internal static Automaton <BDD> computeDFA(List <string> variables, BDD alphabet, CharSetSolver solver, string set, BDD pred) { int setbit = variables.IndexOf(set); //Compute predicates for pos-th bit is 0 or 1 var trueBv = solver.MkSetFromRange(0, (uint)(Math.Pow(2, variables.Count + 16) - 1), variables.Count + 16 - 1); var posIs1 = solver.MkAnd(new BDD[] { trueBv, solver.MkSetWithBitTrue(setbit), solver.ShiftLeft(pred, variables.Count) }); var posIs0 = solver.MkAnd(trueBv, solver.MkSetWithBitFalse(setbit)); //Create automaton for condition var moves = new Move <BDD>[] { new Move <BDD>(0, 0, posIs0), new Move <BDD>(0, 0, posIs1) }; var dfa = Automaton <BDD> .Create(0, new int[] { 0 }, moves); return(dfa); }
public WS1SUnaryPred(string set, BDD pred) { this.set = set; this.pred = pred; }
internal override Automaton <BDD> getDFA(List <string> variables, BDD alphabet, CharSetSolver solver) { return(WS1SSingleton.computeDFA(variables, alphabet, solver, this.set)); }
private string GeneratePredicateHelper(BDD pred) { string res; //generate a predicate depending on how complex the condition is if (!predicate_cache.TryGetValue(pred, out res)) { if (pred.IsLeaf) { if (pred.IsEmpty) res = "false"; else if (pred.IsFull) res = "true"; else throw new AutomataException(AutomataExceptionKind.UnexpectedMTBDDTerminal); } else { //if there is a single node in the BDD then //just inline the corresponding bit mask operation if (pred.One.IsLeaf && pred.Zero.IsLeaf) res = string.Format("c & 0x{0:X} {1} 0", 1 << pred.Ordinal, (pred.One.IsFull ? "!=" : "==")); else { var ranges = pred.ToRanges(); if (ranges.Length <= 3) { res = RangesToCode(ranges); } else { //generate a method for checking this condition StringBuilder helper_method = new StringBuilder(); //create a new method for this predicate int methid = helper_predicates.Count; helper_method.Append(String.Format(@" static bool P{0}(int c) {{ return ", methid)); helper_method.Append(RangesToCode(ranges)); helper_method.Append(@"; }"); helper_predicates.Add(helper_method.ToString()); res = string.Format("P{0}(c)", methid); } } } predicate_cache[pred] = res; } return res; }
private static void WriteRangeFields(BitWidth encoding, StreamWriter sw, string field) { int bits = (int)encoding; int maxChar = (1 << bits) - 1; var catMap = new Dictionary<UnicodeCategory, Ranges>(); for (int c = 0; c < 30; c++) catMap[(UnicodeCategory)c] = new Ranges(); Ranges whitespace = new Ranges(); Ranges wordcharacter = new Ranges(); for (int i = 0; i <= maxChar; i++) { char ch = (char)i; if (char.IsWhiteSpace(ch)) whitespace.Add(i); UnicodeCategory cat = char.GetUnicodeCategory(ch); catMap[cat].Add(i); int catCode = (int)cat; //in .NET 3.5 if (bits == 7) if (catCode == 0 || catCode == 1 || catCode == 2 || catCode == 3 || catCode == 4 || catCode == 5 || catCode == 8 || catCode == 18) wordcharacter.Add(i); } //generate bdd reprs for each of the category ranges BDD[] catBDDs = new BDD[30]; CharSetSolver bddb = new CharSetSolver(encoding); for (int c = 0; c < 30; c++) catBDDs[c] = bddb.MkBddForIntRanges(catMap[(UnicodeCategory)c].ranges); BDD whitespaceBdd = bddb.MkBddForIntRanges(whitespace.ranges); //in .NET 3.5 category 5 was NOT a word character //union of categories 0,1,2,3,4,8,18 BDD wordCharBdd = bddb.MkOr(catBDDs[0], bddb.MkOr(catBDDs[1], bddb.MkOr(catBDDs[2], bddb.MkOr(catBDDs[3], bddb.MkOr(catBDDs[4], bddb.MkOr(catBDDs[5], bddb.MkOr(catBDDs[8], catBDDs[18]))))))); if (bits == 7) { sw.WriteLine(@"/// <summary> /// Array of 30 UnicodeCategory ranges. Each entry is a pair of integers. /// corresponding to the lower and upper bounds of the unicodes of the characters /// that have the given UnicodeCategory code (between 0 and 29). /// </summary>"); sw.WriteLine("public static int[][][] " + field + " = new int[][][]{"); foreach (UnicodeCategory c in catMap.Keys) { sw.WriteLine("//{0}({1}):", c, (int)c); if (catMap[c].Count == 0) sw.WriteLine("null,"); else { sw.WriteLine("new int[][]{"); foreach (int[] range in catMap[c].ranges) sw.WriteLine(" new int[]{" + string.Format("{0},{1}", range[0], range[1]) + "},"); sw.WriteLine("},"); } } sw.WriteLine("};"); } sw.WriteLine(@"/// <summary> /// Compact BDD encodings of the categories. /// </summary>"); sw.WriteLine("public static int[][] " + field + "Bdd = new int[][]{"); foreach (UnicodeCategory c in catMap.Keys) { sw.WriteLine("//{0}({1}):", c, (int)c); BDD catBdd = catBDDs[(int)c]; if (catBdd == null || catBdd.IsEmpty) sw.WriteLine("null, //false"); else if (catBdd.IsFull) sw.WriteLine("new int[]{0,0}, //true"); else { sw.WriteLine("new int[]{"); foreach (var arc in bddb.SerializeCompact(catBdd)) sw.WriteLine("{0},", arc); sw.WriteLine("},"); } } sw.WriteLine("};"); if (bits == 7) { sw.WriteLine(@"/// <summary> /// Whitespace character ranges. /// </summary>"); sw.WriteLine("public static int[][] " + field + "Whitespace = new int[][]{"); foreach (int[] range in whitespace.ranges) sw.WriteLine(" new int[]{" + string.Format("{0},{1}", range[0], range[1]) + "},"); sw.WriteLine("};"); sw.WriteLine(@"/// <summary> /// Word character ranges. /// </summary>"); sw.WriteLine("public static int[][] " + field + "WordCharacter = new int[][]{"); foreach (int[] range in wordcharacter.ranges) sw.WriteLine(" new int[]{" + string.Format("{0},{1}", range[0], range[1]) + "},"); sw.WriteLine("};"); } sw.WriteLine(@"/// <summary> /// Compact BDD encoding of the whitespace characters. /// </summary>"); sw.WriteLine("public static int[] " + field + "WhitespaceBdd = new int[]{"); foreach (var arc in bddb.SerializeCompact(whitespaceBdd)) sw.WriteLine("{0},", arc); sw.WriteLine("};"); sw.WriteLine(@"/// <summary> /// Compact BDD encoding of word characters /// </summary>"); sw.WriteLine("public static int[] " + field + "WordCharacterBdd = new int[]{"); foreach (var arc in bddb.SerializeCompact(wordCharBdd)) sw.WriteLine("{0},", arc); sw.WriteLine("};"); }
internal override Automaton <BDD> getDFA(List <string> variables, BDD alphabet, CharSetSolver solver) { return(Automaton <BDD> .Empty); }
internal abstract Automaton <BDD> getDFA(List <string> variables, BDD alphabet, CharSetSolver solver);
public Etage AjouterEtage(string nom) { return(BDD?.AjouterEtage(nom)); }
// private static void GenerateCodeForBDD(StringBuilder code, BDD pred, string methid) // { // Dictionary<BDD, int> idMap = new Dictionary<BDD, int>(); // int nextLabelId = 0; // Func<BDD, int> GetId = bdd => // { // int bddid; // if (!idMap.TryGetValue(bdd, out bddid)) // { // bddid = nextLabelId++; // idMap[bdd] = bddid; // } // return bddid; // }; // HashSet<BDD> done = new HashSet<BDD>(); // SimpleStack<BDD> todo = new SimpleStack<BDD>(); // todo.Push(pred); // done.Add(pred); // StringBuilder leaves = new StringBuilder(); // while (todo.IsNonempty) // { // var bdd = todo.Pop(); // if (bdd.IsLeaf) // leaves.Append(String.Format(@" // P{0}_{1}: return {2};", methid, GetId(bdd), bdd.IsEmpty ? "false" : "true")); // else // { // if (bdd == pred) //skip the label // code.Append(String.Format(@" // if ((c & 0x{1:X}) == 0) goto P{0}_{2}; else goto P{0}_{3};", methid, 1 << bdd.Ordinal, GetId(bdd.Zero), GetId(bdd.One))); // else // code.Append(String.Format(@" // P{0}_{1}: if ((c & 0x{2:X}) == 0) goto P{0}_{3}; else goto P{0}_{4};", methid, GetId(bdd), 1 << bdd.Ordinal, GetId(bdd.Zero), GetId(bdd.One))); // if (done.Add(bdd.Zero)) // todo.Push(bdd.Zero); // if (done.Add(bdd.One)) // todo.Push(bdd.One); // } // } // code.Append(leaves.ToString()); // } private static void GenerateCodeForBDD(StringBuilder code, BDD pred, string methid) { code.Append(string.Format("return {0};", RangesToCode(pred.ToRanges()))); }