public void M2() { var data = " 77 AND45 OR( NO"; var p = new LexemeScanner(data); var items = new List <Operators>(); while (p.IsSafeToRead) { var machine = new OperatorMachine(p); var op = machine.Get(); if (op.IsSome) { items.Add(op.First().@operator); machine.Done(); } else { p.Next(); } } Assert.IsTrue(items.Any(), "Nothing extracted"); Assert.IsTrue(items.Count == 2, "not found required number of elements"); }
public void M1() { var p = new LexemeScanner(" AND OR NOT NOTO"); var p2 = new OperatorMachine(p); var t = p2.Get(); Assert.IsTrue(t.IsSome && t.First().@operator == Operators.AND); t = p2.Get(); Assert.IsTrue(t.IsSome && t.First().@operator == Operators.OR); t = p2.Get(); Assert.IsTrue(t.IsSome && t.First().@operator == Operators.NOT); t = p2.Get(); Assert.IsTrue(t.IsNone); }
public void P1() { var lp = new LexemeScanner("Hello = New AND Parent = SOSO "); var items = new List <object>(); while (lp.IsSafeToRead) { var idm = new IdentifierMachine(lp); var canContinue = true; do { var t0 = idm.Get(); t0.Match(x => { items.Add(x); idm.Done(); }, () => canContinue = false); } while(canContinue); var om = new OperatorMachine(lp); canContinue = true; do { var t0 = om.Get(); t0.Match(x => { items.Add(x); om.Done(); }, () => canContinue = false); } while(canContinue); } }