Example #1
0
        internal Nfa.Nfa BuildNfa()
        {
            var     nfa      = new Nfa.Nfa();
            NfaNode end_node = new NfaNode().SetAccepting(true);

            foreach (Tuple <char, char> elem in bracketElements)
            {
                nfa.StartNode.ConnectTo(end_node, NfaEdge.Create(elem.Item1, elem.Item2));
            }

            return(nfa);
        }
Example #2
0
        public static Nfa.Nfa BuildNfa(object this_)
        {
            switch (AtomType(this_))
            {
            case RegexAtom.Bracket: return(AsBracket(this_).BuildNfa());

            case RegexAtom.Alternatives: return(AsAlternatives(this_).BuildNfa());

            case RegexAtom.Char:
            {
                var nfa = new Nfa.Nfa();
                nfa.StartNode.ConnectTo(new NfaNode().SetAccepting(true), NfaEdge.Create(AsChar(this_)));
                return(nfa);
            }
            }

            throw new Exception();
        }