Exemplo n.º 1
0
    internal FA SynthesizeOneOrNone(FA synth)
    {
        FA tempFA = new FA();

        //2.Merge graph
        CGraph.CMergeGraphOperation merged = tempFA.Merge(synth, CGraph.CMergeGraphOperation.MergeOptions.MO_DEFAULT);
        merged.MergeGraphInfo(synth, GraphElementType.ET_EDGE, FA.m_FAINFOKEY);
        merged.MergeGraphInfo(synth, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY);
        merged.MergeGraphInfo(synth, GraphElementType.ET_NODE, FA.m_FAINFOKEY);


        CGraphNode il = tempFA.CreateGraphNode <CGraphNode>();

        tempFA.AddGraphEdge <CGraphEdge, CGraphNode>(il, merged.GetMirrorNode(synth.M_Initial), GraphType.GT_DIRECTED);
        CGraphNode fl = tempFA.CreateGraphNode <CGraphNode>();

        tempFA.AddGraphEdge <CGraphEdge, CGraphNode>(merged.GetMirrorNode(synth.GetFinalStates()[0]), fl, GraphType.GT_DIRECTED);

        //4.Create the initial and the final node
        tempFA.M_Initial = il;
        tempFA.SetFinalState(fl);
        tempFA.UpdateAlphabet();

        tempFA.AddGraphEdge <CGraphEdge, CGraphNode>(il, fl, GraphType.GT_DIRECTED);

        //7.Return result
        return(tempFA);
    }
Exemplo n.º 2
0
    internal FA Synthesize(FA l, FA r)
    {
        FA tempFA = new FA();

        //2.Merge left graph
        CGraph.CMergeGraphOperation lmerge = tempFA.Merge(l, CGraph.CMergeGraphOperation.MergeOptions.MO_DEFAULT);
        lmerge.MergeGraphInfo(l, GraphElementType.ET_EDGE, FA.m_FAINFOKEY);
        lmerge.MergeGraphInfo(l, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY);
        lmerge.MergeGraphInfo(l, GraphElementType.ET_NODE, FA.m_FAINFOKEY);

        CGraphNode il = lmerge.GetMirrorNode(l.M_Initial);
        CGraphNode fl = lmerge.GetMirrorNode(l.GetFinalStates()[0]);

        //3.Merge right graph
        CGraph.CMergeGraphOperation rmerge = tempFA.Merge(r, CGraph.CMergeGraphOperation.MergeOptions.MO_DEFAULT);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_EDGE, FA.m_FAINFOKEY);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_NODE, FA.m_FAINFOKEY);

        CGraphNode ir = rmerge.GetMirrorNode(r.M_Initial);
        CGraphNode fr = rmerge.GetMirrorNode(r.GetFinalStates()[0]);

        //4.Create the initial and the final node
        tempFA.M_Initial = il;
        tempFA.SetFinalState(fr);

        tempFA.AddGraphEdge <CGraphEdge, CGraphNode>(fl, ir, GraphType.GT_DIRECTED);

        //7.Return result
        return(tempFA);
    }
Exemplo n.º 3
0
    internal FA Sythesize(FA l, FA r, CGraph.CMergeGraphOperation.MergeOptions options)
    {
        //1.Create FA
        FA templateFA = new FA();

        //2.Merge left graph
        CGraph.CMergeGraphOperation lmerge = templateFA.Merge(l, options);
        //Console.WriteLine(l.ToString());
        lmerge.MergeGraphInfo(l, GraphElementType.ET_EDGE, FA.m_FAINFOKEY);
        lmerge.MergeGraphInfo(l, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY);
        lmerge.MergeGraphInfo(l, GraphElementType.ET_NODE, FA.m_FAINFOKEY);
        CGraphNode il = lmerge.GetMirrorNode(l.M_Initial);
        CGraphNode fl = lmerge.GetMirrorNode(l.GetFinalStates()[0]);

        //3.Merge right graph
        CGraph.CMergeGraphOperation rmerge = templateFA.Merge(r, options);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_EDGE, FA.m_FAINFOKEY);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_NODE, FA.m_FAINFOKEY);
        CGraphNode ir = rmerge.GetMirrorNode(r.M_Initial);
        CGraphNode fr = rmerge.GetMirrorNode(r.GetFinalStates()[0]);

        //4.Create the initial and the final node
        CGraphNode FAinit  = templateFA.CreateGraphNode <CGraphNode>();
        CGraphNode FAfinal = templateFA.CreateGraphNode <CGraphNode>();

        templateFA.M_Initial = FAinit;
        templateFA.SetFinalState(FAfinal);
        templateFA.UpdateAlphabet();


        templateFA.AddGraphEdge <CGraphEdge, CGraphNode>(FAinit, il, GraphType.GT_DIRECTED);
        templateFA.AddGraphEdge <CGraphEdge, CGraphNode>(FAinit, ir, GraphType.GT_DIRECTED);
        templateFA.AddGraphEdge <CGraphEdge, CGraphNode>(fr, FAfinal, GraphType.GT_DIRECTED);
        templateFA.AddGraphEdge <CGraphEdge, CGraphNode>(fl, FAfinal, GraphType.GT_DIRECTED);

        //7.Return result
        return(templateFA);
    }
Exemplo n.º 4
0
    internal FA Sythesize(FA l, FA r, CGraph.CMergeGraphOperation.MergeOptions options)
    {
        //1.Create FA
        m_currentFA    = new FA();
        m_ThompsonInfo = new ThompsonInfo(m_currentFA, m_ThompsonInfoKey);

        //2.Merge left graph
        CGraph.CMergeGraphOperation lmerge = m_currentFA.Merge(l, options);
        //Console.WriteLine(l.ToString());
        lmerge.MergeGraphInfo(l, GraphElementType.ET_EDGE, FA.m_FAINFOKEY);
        lmerge.MergeGraphInfo(l, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY);
        lmerge.MergeGraphInfo(l, GraphElementType.ET_NODE, FA.m_FAINFOKEY);

        lmerge.MergeGraphInfo(l, GraphElementType.ET_EDGE, m_ThompsonInfoKey);
        lmerge.MergeGraphInfo(l, GraphElementType.ET_GRAPH, m_ThompsonInfoKey);
        lmerge.MergeGraphInfo(l, GraphElementType.ET_NODE, m_ThompsonInfoKey);

        CGraphNode il = lmerge.GetMirrorNode(l.M_Initial);
        CGraphNode fl = lmerge.GetMirrorNode(l.GetFinalStates()[0]);

        //3.Merge right graph
        CGraph.CMergeGraphOperation rmerge = m_currentFA.Merge(r, options);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_EDGE, FA.m_FAINFOKEY);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_NODE, FA.m_FAINFOKEY);

        rmerge.MergeGraphInfo(r, GraphElementType.ET_EDGE, m_ThompsonInfoKey);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_GRAPH, m_ThompsonInfoKey);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_NODE, m_ThompsonInfoKey);

        CGraphNode ir = rmerge.GetMirrorNode(r.M_Initial);
        CGraphNode fr = rmerge.GetMirrorNode(r.GetFinalStates()[0]);

        //4.Create the initial and the final node
        CGraphNode FAinit  = m_currentFA.CreateGraphNode <CGraphNode>();
        CGraphNode FAfinal = m_currentFA.CreateGraphNode <CGraphNode>();

        m_ThompsonInfo.InitNodeInfo(FAinit, new ThompsonNodeFAInfo());
        m_ThompsonInfo.InitNodeInfo(FAfinal, new ThompsonNodeFAInfo());

        m_currentFA.M_Initial = FAinit;
        m_currentFA.SetFinalState(FAfinal);
        m_currentFA.UpdateAlphabet();

        m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(FAinit, il, GraphType.GT_DIRECTED);
        m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(FAinit, ir, GraphType.GT_DIRECTED);
        m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(fr, FAfinal, GraphType.GT_DIRECTED);
        m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(fl, FAfinal, GraphType.GT_DIRECTED);

        // Update closure information from operand closure
        // Update closure information from operand closure
        UpdateClosureInformation(l, m_currentFA, lmerge);
        UpdateClosureInformation(r, m_currentFA, rmerge);

        //7.Return result
        return(m_currentFA);
    }
Exemplo n.º 5
0
    internal FA Synthesize(FA l, FA r)
    {
        FA m_currentFA = new FA();

        m_ThompsonInfo = new ThompsonInfo(m_currentFA, m_ThompsonInfoKey);
        //2.Merge left graph
        CGraph.CMergeGraphOperation lmerge = m_currentFA.Merge(l, CGraph.CMergeGraphOperation.MergeOptions.MO_DEFAULT);
        lmerge.MergeGraphInfo(l, GraphElementType.ET_EDGE, FA.m_FAINFOKEY);
        lmerge.MergeGraphInfo(l, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY);
        lmerge.MergeGraphInfo(l, GraphElementType.ET_NODE, FA.m_FAINFOKEY);

        lmerge.MergeGraphInfo(l, GraphElementType.ET_EDGE, m_ThompsonInfoKey);
        lmerge.MergeGraphInfo(l, GraphElementType.ET_GRAPH, m_ThompsonInfoKey);
        lmerge.MergeGraphInfo(l, GraphElementType.ET_NODE, m_ThompsonInfoKey);

        CGraphNode il = lmerge.GetMirrorNode(l.M_Initial);
        CGraphNode fl = lmerge.GetMirrorNode(l.GetFinalStates()[0]);

        //3.Merge right graph
        CGraph.CMergeGraphOperation rmerge = m_currentFA.Merge(r, CGraph.CMergeGraphOperation.MergeOptions.MO_DEFAULT);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_EDGE, FA.m_FAINFOKEY);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_NODE, FA.m_FAINFOKEY);

        rmerge.MergeGraphInfo(r, GraphElementType.ET_EDGE, m_ThompsonInfoKey);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_GRAPH, m_ThompsonInfoKey);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_NODE, m_ThompsonInfoKey);

        CGraphNode ir = rmerge.GetMirrorNode(r.M_Initial);
        CGraphNode fr = rmerge.GetMirrorNode(r.GetFinalStates()[0]);

        //4.Create the initial and the final node
        m_currentFA.M_Initial = il;
        m_currentFA.SetFinalState(fr);

        m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(fl, ir, GraphType.GT_DIRECTED);

        // Update closure information from operand closure
        UpdateClosureInformation(l, m_currentFA, lmerge);
        UpdateClosureInformation(r, m_currentFA, rmerge);

        //7.Return result
        return(m_currentFA);
    }