CFGLibTest.Unit.TestCFGToCNF.TestAccepts02 C# (CSharp) Method

TestAccepts02() private method

private TestAccepts02 ( ) : void
return void
		public void TestAccepts02() {
			var productions = new HashSet<Production> {
				CFGParser.Production("<X_0> -> <X_0> 'x4' <X_0> 'x0'"),
				CFGParser.Production("<X_0> -> <X_0> <X_0> 'x2' <X_0> 'x3'"),
				CFGParser.Production("<X_0> -> <X_0> 'x1' <X_0>"),
				CFGParser.Production("<X_0> -> <X_0> 'x1' 'x1' 'x1' 'x3'"),
				CFGParser.Production("<X_0> -> ε"),
			};
			Grammar g = new Grammar(productions, Nonterminal.Of("X_0"));
			CNFGrammar h = g.ToCNF();

			Assert.IsTrue(h.Accepts(Sentence.FromLetters("")));
			Assert.IsTrue(h.Accepts(Sentence.FromWords("x4 x0")));
			Assert.IsTrue(h.Accepts(Sentence.FromWords("x4 x0 x4 x2 x3 x0")));
		}