Ejemplo n.º 1
0
		private void LexWithSCSAndCompare(List<Lexing.Token> originalTokens, string lesCode)
		{
			var msgs = new MessageHolder();
			var stream = new MemoryStream(Encoding.UTF8.GetBytes(lesCode));
			var source = new StreamCharSource(stream, Encoding.UTF8.GetDecoder(), _bufSize);
			var lexer = Les2LanguageService.Value.Tokenize(source, "StreamCharSource.les", msgs);
			var tokens = lexer.ToList().Where(tok => !tok.IsWhitespace).ToList();
			Assert.AreEqual(0, msgs.List.Count);
			ExpectList(tokens, originalTokens);

			// Now reset the lexer and read the same StreamCharSource again 
			// (different code paths are used the second time)
			lexer.Reset();
			tokens = lexer.ToList().Where(tok => !tok.IsWhitespace).ToList();
			Assert.AreEqual(0, msgs.List.Count);
			ExpectList(tokens, originalTokens);
		}
Ejemplo n.º 2
0
        private void LexWithSCSAndCompare(List <Lexing.Token> originalTokens, string lesCode)
        {
            var msgs   = new MessageHolder();
            var stream = new MemoryStream(Encoding.UTF8.GetBytes(lesCode));
            var source = new StreamCharSource(stream, Encoding.UTF8.GetDecoder(), _bufSize);
            var lexer  = LesLanguageService.Value.Tokenize(source, "StreamCharSource.les", msgs);
            var tokens = lexer.Buffered().Where(tok => !tok.IsWhitespace).ToList();

            Assert.AreEqual(0, msgs.List.Count);
            ExpectList(tokens, originalTokens);

            // Now reset the lexer and read the same StreamCharSource again
            // (different code paths are used the second time)
            lexer.Reset();
            tokens = lexer.Buffered().Where(tok => !tok.IsWhitespace).ToList();
            Assert.AreEqual(0, msgs.List.Count);
            ExpectList(tokens, originalTokens);
        }