public void TestRightrec() { Parser parser; IndirectParser sp_rr = Hammer.Indirect(); sp_rr.Bind(Hammer.Choice(Hammer.Sequence(Hammer.Ch('a'), sp_rr), Hammer.Epsilon_p())); parser = sp_rr; CheckParseOK(parser, "a", new object[] { 'a' }); CheckParseOK(parser, "aa", new object[] { 'a', new object[] { 'a' } }); CheckParseOK(parser, "aaa", new object[] { 'a', new object[] { 'a', new object[] { 'a' } } }); }
public void TestAmbiguous() { Parser parser; IndirectParser sp_d = Hammer.Indirect(); IndirectParser sp_p = Hammer.Indirect(); IndirectParser sp_e = Hammer.Indirect(); sp_d.Bind(Hammer.Ch('d')); sp_p.Bind(Hammer.Ch('+')); sp_e.Bind(Hammer.Choice(Hammer.Sequence(sp_e, sp_p, sp_e), sp_d)); parser = sp_e; CheckParseOK(parser, "d", 'd'); CheckParseOK(parser, "d+d", new object[] { 'd', '+', 'd' }); CheckParseOK(parser, "d+d+d", new object[] { new object[] { 'd', '+', 'd' }, '+', 'd' }); }