예제 #1
0
        public static void CopyTo(this IAutomaton @this, IAutomatonBuilder builder, out int oldNewStartState,
                                  out IEnumerable <int> oldNewAcceptingStates)
        {
            var stateMapping = new Dictionary <int, int>();

            for (var state = 0; state < @this.StateCount; state++)
            {
                stateMapping.Add(state, builder.AddState());
            }
            foreach (var kv in @this.TransitionsBySource)
            {
                var source     = stateMapping[kv.Key];
                var transition = kv.Value;
                foreach (var target in transition)
                {
                    foreach (var x in target.Select(v => stateMapping[v]))
                    {
                        builder.AddTransition(source, target.Key, x);
                    }
                }
            }
            oldNewStartState      = stateMapping[@this.StartState];
            oldNewAcceptingStates = @this.AcceptingStates.Select(s => stateMapping[s]).ToArray();
        }
예제 #2
0
        public static void AddTransition(this IAutomatonBuilder @this, int source, char c, int target)
        {
            var charset = new CharSet(c);

            @this.AddTransition(source, charset, target);
        }
예제 #3
0
 public static void AddEpsilonTransition(this IAutomatonBuilder @this, int source, int target)
 {
     @this.AddTransition(source, CharSet.Epsilon, target);
 }