Beispiel #1
0
/**
 * NewNLPair
 * return a new NfaPair that matches a new line
 * (\r\n?|\n)
 */
        public static NfaPair NewNLPair(Spec spec)
        {
            NfaPair pair = NewNfaPair();

            pair.end   = NewNfa(spec); // newline accepting state
            pair.start = NewNfa(spec); // new state with two epsilon edges

            Nfa pstart = pair.start;

            pstart.SetNext(NewNfa(spec));

            Nfa pstartnext = pstart.GetNext();

            pstartnext.SetEdge(Nfa.CCL);
            pstartnext.SetCharSet(new CharSet());
            pstartnext.GetCharSet().add('\n');
            pstartnext.SetNext(pair.end); // accept '\n'

            pstart.SetSib(NewNfa(spec));
            Nfa pstartsib = pstart.GetSib();

            pstartsib.SetEdge('\r');

            pstartsib.SetNext(NewNfa(spec));
            Nfa pstartsibnext = pstartsib.GetNext();

            pstartsibnext.SetNext(null); // do NOT accept just '\r'

            pstartsibnext.SetSib(NewNfa(spec));
            pstartsibnext.GetSib().SetEdge('\n');
            pstartsibnext.GetSib().SetNext(pair.end); // accept '\r\n'

            return(pair);
        }
Beispiel #2
0
/*
 * Function: NewNfaPair
 */
        public static NfaPair NewNfaPair()
        {
            NfaPair pair = new NfaPair();

            return(pair);
        }