Beispiel #1
0
		private Token GetCurrentToken()
		{
			if (currentToken == null)
			{
				if (scanner.InternalMoveNext())
				{
					currentToken = scanner.Current;
				}
			}
			return currentToken;
		}
Beispiel #2
0
		private void AssertToken(Token expected, Token actual, int tokenNumber)
		{
			Dump.WriteLine(expected.GetType().Name);
            Assert.NotNull(actual);
			Assert.AreEqual(expected.GetType(), actual.GetType(), "Token {0} is not of the expected type", tokenNumber);

			foreach (var property in expected.GetType().GetProperties())
			{
				if (property.PropertyType != typeof(Mark) && property.CanRead)
				{
					var value = property.GetValue(actual, null);
					var expectedValue = property.GetValue(expected, null);
					Dump.WriteLine("\t{0} = {1}", property.Name, value);
                    Assert.AreEqual(expectedValue, value, "Comparing property {0} in token {1}", property.Name, tokenNumber);
				}
			}
		}
Beispiel #3
0
		/// <summary>
		/// Consumes the current token and increments the parsed token count
		/// </summary>
		internal void ConsumeCurrent()
		{
			++tokensParsed;
			tokenAvailable = false;
			current = null;
		}
Beispiel #4
0
		private void Skip()
		{
			if (currentToken != null)
			{
				currentToken = null;
				scanner.ConsumeCurrent();
			}
		}
Beispiel #5
0
		internal bool InternalMoveNext()
		{
			if (!tokenAvailable && !streamEndProduced)
			{
				FetchMoreTokens();
			}
			if (tokens.Count > 0)
			{
				current = tokens.Dequeue();
				tokenAvailable = false;
				return true;
			}
			else
			{
				current = null;
				return false;
			}
		}