public void TestSeek() { // ^(101 ^(102 103 ^(106 107) ) 104 105) // stream has 7 real + 6 nav nodes // Sequence of types: 101 DN 102 DN 103 106 DN 107 UP UP 104 105 UP EOF ITree r0 = new CommonTree(new CommonToken(101)); ITree r1 = new CommonTree(new CommonToken(102)); r0.AddChild(r1); r1.AddChild(new CommonTree(new CommonToken(103))); ITree r2 = new CommonTree(new CommonToken(106)); r2.AddChild(new CommonTree(new CommonToken(107))); r1.AddChild(r2); r0.AddChild(new CommonTree(new CommonToken(104))); r0.AddChild(new CommonTree(new CommonToken(105))); ITreeNodeStream stream = newStream(r0); stream.Consume(); // consume 101 stream.Consume(); // consume DN stream.Consume(); // consume 102 stream.Seek(7); // seek to 107 Assert.AreEqual(107, ((ITree)stream.LT(1)).Type); stream.Consume(); // consume 107 stream.Consume(); // consume UP stream.Consume(); // consume UP Assert.AreEqual(104, ((ITree)stream.LT(1)).Type); }
public override void Reset() { base.Reset(); // reset all recognizer state variables if (input != null) { input.Seek(0); // rewind the input } }