Example #1
0
        public static Nfa Rule(RuleBinding ruleBinding)
        {
            State startState = new State();
            State endState = new State();

            PushContextTransition push = new PushContextTransition(ruleBinding.StartState, startState.Id);
            PopContextTransition pop = new PopContextTransition(endState, startState.Id);

            startState.AddTransition(push);
            ruleBinding.EndState.AddTransition(pop);

            return new Nfa(startState, endState);
        }
Example #2
0
 private IEnumerable<State> GetEnclosedStates(PushContextTransition transition)
 {
     HashSet<State> states = new HashSet<State>(ObjectReferenceEqualityComparer<State>.Default);
     states.Add(transition.TargetState);
     GetSiblingStates(transition.TargetState, states);
     return states;
 }
 internal IEnumerable<PopContextTransition> GetPopContextTransitions(PushContextTransition pushContextTransition)
 {
     Contract.Requires<ArgumentNullException>(pushContextTransition != null, "pushContextTransition");
     Contract.Ensures(Contract.Result<IEnumerable<PopContextTransition>>() != null);
     return GetPopContextTransitions(pushContextTransition.ContextIdentifiers[0]);
 }