public void SubsetConstruction_String() { var nfaBuilder = new Graph.Builder(); NFAHelper.Graph( nfaBuilder, NFAHelper.Series( nfaBuilder, NFAHelper.CreateSimplePath(nfaBuilder, '"'), NFAHelper.Optional( nfaBuilder, NFAHelper.Repeat( nfaBuilder, NFAHelper.Parallell( nfaBuilder, NFAHelper.Series( nfaBuilder, NFAHelper.CreateSimplePath(nfaBuilder, '"'), NFAHelper.CreateSimplePath(nfaBuilder, '"')), NFAHelper.CreateSimplePath(nfaBuilder, '"', true)))), NFAHelper.CreateSimplePath(nfaBuilder, '"'))); var dfaGraph = FATools.CreateDfa(nfaBuilder.Graph); const string expected = "0 (S:S0) -- [\"] --> 1\r\n" + "1 -- [\"] --> 2 (L:E0)\r\n" + "1 -- ![\"] --> 1\r\n" + "2 (L:E0) -- [\"] --> 1\r\n" + ""; Assert.That(FARenderer.Render(dfaGraph), Is.EqualTo(expected)); }
public void SubsetConstruction_Label() { var nfaGraphBuilder = new Graph.Builder(); var lead = new CharRange[] { new CharRange('A', 'Z'), new CharRange('a', 'z') }; var tail = new CharRange[] { new CharRange('A', 'Z'), new CharRange('a', 'z'), new CharRange('0', '9'), new CharRange('_', '_') }; NFAHelper.Graph( nfaGraphBuilder, NFAHelper.Series( nfaGraphBuilder, NFAHelper.CreateSimplePath(nfaGraphBuilder, CharSet.New(lead)), NFAHelper.Optional( nfaGraphBuilder, NFAHelper.Repeat( nfaGraphBuilder, NFAHelper.CreateSimplePath(nfaGraphBuilder, CharSet.New(tail)))))); var dfaGraph = FATools.CreateDfa(nfaGraphBuilder.Graph); const string expected = "0 (S:S0) -- [A-Z,a-z] --> 1 (L:E0)\r\n" + "1 (L:E0) -- [0-9,A-Z,_,a-z] --> 1 (L:E0)\r\n" + ""; Assert.That(FARenderer.Render(dfaGraph), Is.EqualTo(expected)); }