コード例 #1
0
        void DoEdge1()
        {
            graph   = new StdGraph();
            actions = new edge1Actions(graph);
            procEnv = new LGSPGraphProcessingEnvironment(graph, actions);

            // use graph rewrite sequence
            procEnv.ApplyGraphRewriteSequence("init3");

            Console.WriteLine(procEnv.PerformanceInfo.MatchesFound + " matches found.");
            Console.WriteLine(procEnv.PerformanceInfo.RewritesPerformed + " rewrites performed.");
            procEnv.PerformanceInfo.Reset();

            // use old inexact interface
            IMatches matches = actions.GetAction("findTripleCircle").Match(procEnv, 0, null);

            Console.WriteLine(matches.Count + " matches found.");

            // use new exact interface
            IMatchesExact <Rule_findTripleCircle.IMatch_findTripleCircle> matchesExact =
                actions.findTripleCircle.Match(procEnv, 0);

            Console.WriteLine(matchesExact.Count + " matches found.");
            actions.findTripleCircle.Modify(procEnv, matchesExact.FirstExact); // rewrite first match (largely nop, as findTripleCircle is a test)
        }
コード例 #2
0
ファイル: RecursiveExample.cs プロジェクト: jblomer/GrGen.NET
        void DoAlt()
        {
            graph   = new StdGraph();
            actions = new RecursiveActions(graph);
            procEnv = new LGSPGraphProcessingEnvironment(graph, actions);

            IMatches matches;

            Object[] returns;

            Action_createChain createChain = Action_createChain.Instance;

            matches = createChain.Match(procEnv, 0);
            returns = createChain.Modify(procEnv, matches.First);
            Node[] param = new Node[2];
            param[0] = (Node)returns[0];
            param[1] = (Node)returns[1];
            matches  = actions.GetAction("chainFromToReverseToCommon").Match(procEnv, 0, param);
            Console.WriteLine(matches.Count + " matches found.");

            Action_createBlowball createBlowball = Action_createBlowball.Instance;

            matches = createBlowball.Match(procEnv, 0);
            returns = createBlowball.Modify(procEnv, matches.First);
            matches = actions.GetAction("blowball").Match(procEnv, 0, returns);
            Console.WriteLine(matches.Count + " matches found.");

            graph.Clear();

            matches  = createChain.Match(procEnv, 0);
            returns  = createChain.Modify(procEnv, matches.First);
            param[0] = (Node)returns[0];

            Console.WriteLine(procEnv.PerformanceInfo.MatchesFound + " matches found.");
            Console.WriteLine(procEnv.PerformanceInfo.RewritesPerformed + " rewrites performed.");
            procEnv.PerformanceInfo.Reset();

            IAction chainFromCompleteArbitraryBaseAlwaysFailesByGoingBackwards =
                actions.GetAction("chainFromCompleteArbitraryBaseAlwaysFailesByGoingBackwards");

            matches = chainFromCompleteArbitraryBaseAlwaysFailesByGoingBackwards.Match(procEnv, 0, param);
            Console.WriteLine(matches.Count + " matches found.");
        }