Ejemplo n.º 1
0
        public virtual void MoveBack(int position)
        {
            counter = new PositionCounter(before);

            while (counter.Position < position)
            {
                counter.Add(this[counter.Position]);
            }
        }
Ejemplo n.º 2
0
        public void Test()
        {
            string[] strings = new[] { "es", " ", "\n", "eju" };
            List<Token> tokens = new List<Token>();
            PositionCounter feeder = new PositionCounter();

            foreach (string s in strings)
            {
                Token token = new Token();
                token.Text = s;

                token.Position = feeder.Position;
                token.Line = feeder.Line;
                token.LinePosition = feeder.LinePosition;
                feeder.Add(s);
                token.PositionEnd = feeder.Position;
                token.LineEnd = feeder.Line;
                token.LinePositionEnd = feeder.LinePosition;

                tokens.Add(token);
            }

            Assert.AreEqual(4, tokens.Count);

            Assert.AreEqual(0, tokens[0].Position);
            Assert.AreEqual(2, tokens[0].PositionEnd);
            Assert.AreEqual(0, tokens[0].Line);
            Assert.AreEqual(0, tokens[0].LineEnd);
            Assert.AreEqual(0, tokens[0].LinePosition);
            Assert.AreEqual(2, tokens[0].LinePositionEnd);

            Assert.AreEqual(2, tokens[1].Position);
            Assert.AreEqual(3, tokens[1].PositionEnd);
            Assert.AreEqual(0, tokens[1].Line);
            Assert.AreEqual(0, tokens[1].LineEnd);
            Assert.AreEqual(2, tokens[1].LinePosition);
            Assert.AreEqual(3, tokens[1].LinePositionEnd);

            Assert.AreEqual(3, tokens[2].Position);
            Assert.AreEqual(4, tokens[2].PositionEnd);
            Assert.AreEqual(0, tokens[2].Line);
            Assert.AreEqual(1, tokens[2].LineEnd);
            Assert.AreEqual(3, tokens[2].LinePosition);
            Assert.AreEqual(0, tokens[2].LinePositionEnd);

            Assert.AreEqual(4, tokens[3].Position);
            Assert.AreEqual(7, tokens[3].PositionEnd);
            Assert.AreEqual(1, tokens[3].Line);
            Assert.AreEqual(1, tokens[3].LineEnd);
            Assert.AreEqual(0, tokens[3].LinePosition);
            Assert.AreEqual(3, tokens[3].LinePositionEnd);
        }
Ejemplo n.º 3
0
 public PositionCounter(PositionCounter other)
 {
     Position = other.Position;
     Line = other.Line;
     LinePosition = other.LinePosition;
 }
Ejemplo n.º 4
0
 public virtual void Reset()
 {
     counter = new PositionCounter();
     before = new PositionCounter();
 }
Ejemplo n.º 5
0
 public virtual void Release()
 {
     before = new PositionCounter(counter);
 }
Ejemplo n.º 6
0
        public virtual void MoveBack(int position)
        {
            counter = new PositionCounter(before);

            while (counter.Position < position)
            {
                counter.Add(this[counter.Position]);
            }
        }
Ejemplo n.º 7
0
 public virtual void Dispose()
 {
     counter = null;
     before = null;
 }
Ejemplo n.º 8
0
 public PositionCounter(PositionCounter other)
 {
     Position     = other.Position;
     Line         = other.Line;
     LinePosition = other.LinePosition;
 }
Ejemplo n.º 9
0
 public virtual void Dispose()
 {
     counter = null;
     before  = null;
 }
Ejemplo n.º 10
0
 public virtual void Reset()
 {
     counter = new PositionCounter();
     before  = new PositionCounter();
 }
Ejemplo n.º 11
0
 public virtual void Release()
 {
     before = new PositionCounter(counter);
 }