Exemplo n.º 1
0
        private static DfaNode merge(IEnumerable <DfaNode> nodes)
        {
            var result = new DfaNode(nodes.Select(it => it.nodes).Flatten().Distinct().ToArray());

            result.connectionsTo.SetAcceptingValues(nodes.Select(it => it.AcceptingValues).Flatten());
            return(result);
        }
Exemplo n.º 2
0
 internal IEnumerable <Link> ComputeLinks()
 {
     return(nodes
            .Select(it => it.Connections.To)
            .Flatten()
            .Where(it => !it.Item1.IsEmpty) // get only real connections
            .GroupBy(it => it.Item1)        // group by edge range
            // create links per each edge value (not range)
            .Select(it => Link.CreateMany(this, it.Key, new DfaNode(it.Select(x => x.Item2).ToArray())))
            .Flatten()
            .GroupBy(it => it.Edge) // group by edge value
            // create final links with merged nodes
            .Select(it => new Link(this, it.Key, DfaNode.merge(it.Select(x => x.Target)))));
 }
Exemplo n.º 3
0
 internal static IEnumerable <Link> CreateMany(DfaNode source, Nfa.NfaEdge.Fiber fiber, DfaNode target)
 {
     return(Enumerable.Range(fiber.Min, fiber.Max - fiber.Min + 1)
            .Select(it => new Link(source, it, target)));
 }
Exemplo n.º 4
0
 internal Link(DfaNode source, int edge, DfaNode target)
 {
     this.Source = source;
     this.Edge   = edge;
     this.Target = target;
 }
Exemplo n.º 5
0
 internal bool SameNfaCore(DfaNode compNode)
 {
     return(nodes.SetEquals(compNode.nodes));
 }
Exemplo n.º 6
0
 internal void ConnectTo(int edge, DfaNode target)
 {
     connectionsTo.AddTransition(edge, target);
 }