Exemplo n.º 1
0
        public static void BindRule(RuleBinding ruleBinding, Nfa body)
        {
            Contract.Requires<ArgumentNullException>(ruleBinding != null, "ruleBinding");
            Contract.Requires<ArgumentNullException>(body != null, "body");

            ruleBinding.StartState.AddTransition(new EpsilonTransition(body.StartState));
            body.EndState.AddTransition(new EpsilonTransition(ruleBinding.EndState));
        }
Exemplo n.º 2
0
        public static Nfa Optional(Nfa nfa)
        {
            State startState = new State();
            startState.AddTransition(new EpsilonTransition(nfa.StartState));

            State endState = new State();
            nfa.EndState.AddTransition(new EpsilonTransition(endState));

            startState.AddTransition(new EpsilonTransition(endState));

            return new Nfa(startState, endState);
        }
        protected virtual void TryBindRule(RuleBinding ruleBinding, Nfa nfa)
        {
            Contract.Requires(ruleBinding != null);
            if (nfa == null)
                return;

            Nfa.BindRule(ruleBinding, nfa);
        }