Exemplo n.º 1
0
        public void TestConsumeAllCharactersInAnANTLRInputStream()
        {
            Encoding encoding = Encoding.Unicode;

            byte[]       grammarStrBuffer = encoding.GetBytes(grammarStr);
            MemoryStream grammarStream    = new MemoryStream(grammarStrBuffer);

            ANTLRInputStream inputStream = new ANTLRInputStream(grammarStream, Encoding.Unicode);

            while (inputStream.Index() < inputStream.Size())
            {
                Console.Out.Write((char)inputStream.LA(1));
                inputStream.Consume();
            }
            Assert.AreEqual(inputStream.Index(), inputStream.Size());
        }
		public void TestSizeOnEmptyANTLRInputStream()
		{
			MemoryStream grammarStream = new MemoryStream(new byte[] { });

			ANTLRInputStream inputStream = new ANTLRInputStream(grammarStream, Encoding.Unicode);
			Assert.AreEqual(0, inputStream.Size());
		}
Exemplo n.º 3
0
        public void TestSizeOnEmptyANTLRInputStream()
        {
            MemoryStream grammarStream = new MemoryStream(new byte[] { });

            ANTLRInputStream inputStream = new ANTLRInputStream(grammarStream, Encoding.Unicode);

            Assert.AreEqual(0, inputStream.Size());
        }
Exemplo n.º 4
0
        public void TestSizeOnANTLRInputStream()
        {
            Encoding encoding = Encoding.Unicode;

            byte[]       grammarStrBuffer = encoding.GetBytes(grammarStr);
            MemoryStream grammarStream    = new MemoryStream(grammarStrBuffer);

            ANTLRInputStream inputStream = new ANTLRInputStream(grammarStream, Encoding.Unicode);

            Assert.AreEqual(grammarStr.Length, inputStream.Size());
        }
Exemplo n.º 5
0
        public void TestConsumeAndIndexOnANTLRInputStream()
        {
            Encoding encoding = Encoding.Unicode;

            byte[]       grammarStrBuffer = encoding.GetBytes(grammarStr);
            MemoryStream grammarStream    = new MemoryStream(grammarStrBuffer);

            ANTLRInputStream inputStream = new ANTLRInputStream(grammarStream, Encoding.Unicode);

            Assert.AreEqual(0, inputStream.Index());

            inputStream.Consume();
            Assert.AreEqual(1, inputStream.Index());

            inputStream.Consume();
            Assert.AreEqual(2, inputStream.Index());

            while (inputStream.Index() < inputStream.Size())
            {
                inputStream.Consume();
            }
            Assert.AreEqual(inputStream.Index(), inputStream.Size());
        }
		public void TestConsumeAndIndexOnANTLRInputStream()
		{
			Encoding encoding = Encoding.Unicode;
			byte[] grammarStrBuffer = encoding.GetBytes(grammarStr);
			MemoryStream grammarStream = new MemoryStream(grammarStrBuffer);

			ANTLRInputStream inputStream = new ANTLRInputStream(grammarStream, Encoding.Unicode);
			Assert.AreEqual(0, inputStream.Index());

			inputStream.Consume();
			Assert.AreEqual(1, inputStream.Index());

			inputStream.Consume();
			Assert.AreEqual(2, inputStream.Index());

			while (inputStream.Index() < inputStream.Size())
			{
				inputStream.Consume();
			}
			Assert.AreEqual(inputStream.Index(), inputStream.Size());
		}
		public void TestSizeOnANTLRInputStream()
		{
			Encoding encoding = Encoding.Unicode;
			byte[] grammarStrBuffer = encoding.GetBytes(grammarStr);
			MemoryStream grammarStream = new MemoryStream(grammarStrBuffer);

			ANTLRInputStream inputStream = new ANTLRInputStream(grammarStream, Encoding.Unicode);
			Assert.AreEqual(grammarStr.Length, inputStream.Size());
		}
		public void TestConsumeAllCharactersInAnANTLRInputStream()
		{
			Encoding encoding = Encoding.Unicode;
			byte[] grammarStrBuffer = encoding.GetBytes(grammarStr);
			MemoryStream grammarStream = new MemoryStream(grammarStrBuffer);

			ANTLRInputStream inputStream = new ANTLRInputStream(grammarStream, Encoding.Unicode);
			while (inputStream.Index() < inputStream.Size())
			{
				Console.Out.Write((char)inputStream.LA(1));
				inputStream.Consume();
			}
			Assert.AreEqual(inputStream.Index(), inputStream.Size());
		}