public void testConsumeText() { var p = new Parsable("123 4567890"); Assert.IsTrue(p.Consume("123")); Assert.IsTrue(p.Consume("456")); // skipping whitespace }
//console.exe -d=production -t=arl -a=invalidate -e="*****@*****.**" -f="c:\\path\\arls.txt" //console.exe -? private static void ShowHelp(Parsable parser) { Context.Logger.Warn(string.Empty + "\n"); foreach (var o in parser.Options) { Context.Logger.Warn(o.Description); } Context.Logger.Warn(string.Empty + "\n"); Context.Logger.Warn(parser.GetHelpText()); }
public void testLinePosition() { var p = new Parsable("1234567890\n1234567890\n1234567890\n1234567890"); p.Consume("1234567890"); // skipping also \n whitespace p.Consume("1234567890"); p.Consume("12345"); Assert.AreEqual(27, p.Position); Assert.AreEqual(2, p.Line); Assert.AreEqual(5, p.LinePosition); }
public void testLineOf() { var p = new Parsable("1234567890\n1234567890\n1234567890\n1234567890"); Assert.AreEqual(0, p.LineOf(0)); Assert.AreEqual(0, p.LineOf(11)); Assert.AreEqual(1, p.LineOf(12)); Assert.AreEqual(1, p.LineOf(22)); Assert.AreEqual(2, p.LineOf(23)); Assert.AreEqual(2, p.LineOf(27)); }
public void testFailurePosition() { var p = new Parsable("1234567890\n1234567890\n1234567890\n1234567890"); p.Consume("1234567890"); // skipping also \n whitespace p.Consume("1234567890"); p.Consume("12345"); try { p.Consume("FAIL"); Assert.Fail("Should have thrown ParseException"); } catch (ParseException e) { Assert.AreEqual(27, e.Position); Assert.AreEqual(2, e.Line); Assert.AreEqual(5, e.LinePosition); } }
public static JobBean Parse(Parsable obj) { JobBean ret = new JobBean(); String name = obj.getName(), company = obj.getCompany(), date = obj.getDate(); string quals = obj.getQualifications(); ret.position = getPosition(name); ret.company = company; ret.month = getMonth(date); ret.skillList = getSkills(quals); ret.adjList = getAdjs(quals); return(ret); }