private Token GetCurrentToken() { if (currentToken == null) { if (scanner.InternalMoveNext()) { currentToken = scanner.Current; } } return currentToken; }
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); } } }
/// <summary> /// Consumes the current token and increments the parsed token count /// </summary> internal void ConsumeCurrent() { ++tokensParsed; tokenAvailable = false; current = null; }
private void Skip() { if (currentToken != null) { currentToken = null; scanner.ConsumeCurrent(); } }
internal bool InternalMoveNext() { if (!tokenAvailable && !streamEndProduced) { FetchMoreTokens(); } if (tokens.Count > 0) { current = tokens.Dequeue(); tokenAvailable = false; return true; } else { current = null; return false; } }