public void NoMatchMatch() { Rule d = Rule.AssignParser(null, Prims.Digit); AlternativeParser rp = d | d | d; IScanner scan = Provider.Scanner; ParserMatch m = rp.Parse(scan); Assert.IsTrue(!m.Success); Assert.AreEqual(scan.Offset, 0); }
public void NoMatchMatch() { Rule d = new Rule("digit", Prims.Digit); AlternativeParser rp = d | d | d; IScanner scan = Provider.NewScanner; ParserMatch m = rp.Parse(scan); Assert.IsFalse(m.Success); Assert.AreEqual(0, scan.Offset); }
public void ThirdMatch() { Rule d = Rule.AssignParser(null, Prims.Digit); Rule l = Rule.AssignParser(null, Prims.Letter); AlternativeParser rp = d | d | l; IScanner scan = Provider.Scanner; ParserMatch m = rp.Parse(scan); Assert.IsTrue(m.Success); Assert.AreEqual(m.Length, 1); Assert.AreEqual(scan.Offset, 1); }
public void ThirdMatch() { Rule d = new Rule("digit", Prims.Digit); Rule l = new Rule("letter", Prims.Letter); AlternativeParser rp = d | d | l; IScanner scan = Provider.NewScanner; ParserMatch m = rp.Parse(scan); Assert.IsTrue(m.Success); Assert.AreEqual(1, m.Length); Assert.AreEqual(1, scan.Offset); }
public void FirstMatch() { Rule d = new Rule(); Rule l = new Rule(); d.Parser = Prims.Digit; l.Parser = Prims.Letter; AlternativeParser rp = l | d; IScanner scan = Provider.Scanner; ParserMatch m = rp.Parse(scan); Assert.IsTrue(m.Success); Assert.AreEqual(m.Length, 1); Assert.AreEqual(scan.Offset, 1); }