public override IEnumerable <IEntity> Execute(ExecutionOptions options) { var firstEvaluation = First.Execute(options); var secondEvaluation = Second.Execute(options); return(firstEvaluation.Union(secondEvaluation, EntityPathEqualityComparer.Default)); }
public override async Task <ICollection <T> > Execute <TId, T>(DataStore <TId, T> store) { var r1 = await First.Execute(store); var r2 = await Second.Execute(store); return(r1.Intersect(r2).ToArray()); }
public override IEnumerable <IEntity> Execute(ExecutionOptions options) { var firstEvaluation = First.Execute(options); foreach (var item in firstEvaluation) { if (!Second.Match(item)) { yield return(item); } } }
public override VarBase Execute() { if (ContextToExecute == null) { VarBase first = First.Execute(); VarBase second = Second.Execute(); return(Operations.FindBest(first.GetType(), second.GetType(), OperationString).Compile()(first, second)); } return(ContextToExecute.Execute()); }
public override IEnumerable <IEntity> Execute(ExecutionOptions options) { var visited = new HashSet <IEntity>(EntityPathEqualityComparer.Default); var firstEvaluation = First.Execute(options); foreach (var item in firstEvaluation) { visited.Add(item); if (Second.Match(item)) { yield return(item); } } var secondEvaluation = Second.Execute(options); foreach (var item in secondEvaluation) { if (!visited.Contains(item) && First.Match(item)) { yield return(item); } } }
public static void Menu() { bool exit = false; string line; string grammar = null; Translate tr = new Translate(); Console.WriteLine("Functions: "); Console.WriteLine("In order to set the grammar"); Console.WriteLine("> G <rules>"); Console.WriteLine("Ex: G S:(A,B). A:(B,'a';@). B:(C,'b';C). C:('c';@). EOGram!"); Console.WriteLine("In order to calculate FIRST"); Console.WriteLine("> first <k>"); Console.WriteLine("Example: first 2"); Console.WriteLine("In order to calcualte EFF"); Console.WriteLine("> eff <k>"); Console.WriteLine("Example: eff 3"); Console.WriteLine("In order to exit the program"); Console.WriteLine("> e - exit"); Console.Write("> "); while (!exit) { line = Console.ReadLine(); if (line.Length > 0) { if (line.Length == 1 && line[0] == 'e') exit = true; else { List<string> parts = line.Split(' ').Where(x => x != "").ToList(); string fun = parts[0]; switch (fun) { case "G": if (grammar == null) grammar = tr.ToMyForm(line, Translate.TYPE.GRAMMAR); else { Console.WriteLine("Rewrite? y/n: "); string answer = Console.ReadLine(); if (answer[0] == 'y') grammar = tr.ToMyForm(line, Translate.TYPE.GRAMMAR); } break; case "first": case "eff": if (grammar == null) Console.WriteLine("error: no grammar"); else { int k; IEnumerable<string> rules = grammar.Split(' '); List<Pair<char, string>> func_rules = new List<Pair<char, string>>(); if (!int.TryParse(parts[1], out k)) { Console.WriteLine("error: incorrect number of k: " + parts[1]); return; } else if (k <= 0) { Console.WriteLine("error: " + k + " must be greater than 0"); return; } foreach (string rule in rules) { IEnumerable<string> parts_of_rule = rule.Split('>'); if (parts_of_rule.Count() != 2) { Console.WriteLine("error: " + rule + " must have two parts"); return; } if (parts_of_rule.ElementAt(0).Length != 1) { Console.WriteLine("error: the left part of " + rule + " must be non-terminal"); return; } char left_part = parts_of_rule.ElementAt(0)[0]; foreach (string right_part in parts_of_rule.ElementAt(1).Split('|')) if (right_part == "") { Console.WriteLine("error: " + rule + " mustn\'t have the empty argument"); return; } else func_rules.Add(new Pair<char, string>(left_part, right_part)); } Console.WriteLine("Ex: S"); Console.WriteLine("Input sequence: "); Console.Write("> "); string sequence = tr.ToMyForm(Console.ReadLine(), Translate.TYPE.SEQUENCE); if (fun == "first") { First first = new First(k, Auxiliary.StrK('A', tr.Table.Count), tr.Terms.ToString(), func_rules); Console.WriteLine(first.Execute(sequence).ToString()); break; } else { Eff eff = new Eff(k, Auxiliary.StrK('A', tr.Table.Count), tr.Terms.ToString(), func_rules); Console.WriteLine(eff.Execute(sequence).ToString()); break; } } break; } } } else Console.WriteLine("Try again\n"); Console.Write("> "); } }