private Token GetCurrentToken() { if (currentToken == null) { while (scanner.InternalMoveNext()) { currentToken = scanner.Current; var commentToken = currentToken as Comment; if (commentToken != null) { pendingEvents.Enqueue(new Events.Comment(commentToken.Value, commentToken.IsInline, commentToken.Start, commentToken.End)); } else { break; } } } return currentToken; }
private void Skip() { if (currentToken != null) { currentToken = null; scanner.ConsumeCurrent(); } }
private void TokenInfoParsed(Token token, TokenType type, ColorIndex color) { TokenInfo info = new TokenInfo(token.Start.Index, token.End.Index - 1, type); info.Color = (TokenColor)color; scannedTokens.Enqueue(info); }
internal bool InternalMoveNext() { if (!tokenAvailable && !streamEndProduced) { FetchMoreTokens(); } if (tokens.Count > 0) { current = tokens.Dequeue(); tokenAvailable = false; return true; } else { current = null; return false; } }
/// <summary> /// Consumes the current token and increments the parsed token count /// </summary> internal void ConsumeCurrent() { ++tokensParsed; tokenAvailable = false; current = null; }
/// <summary> /// Consumes the current token and increments the parsed token count /// </summary> internal void ConsumeCurrent() { ++tokensParsed; tokenAvailable = false; previous = Current; Current = null; }
private void AssertToken(Token expected, Token actual, int tokenNumber) { Dump.WriteLine(expected.GetType().Name); actual.Should().NotBeNull(); actual.GetType().Should().Be(expected.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); value.Should().Be(expectedValue, "Comparing property {0} in token {1}", property.Name, tokenNumber); } } }
private void AssertNext(Scanner scanner, Token expected) { AssertHasNext(scanner); AssertCurrent(scanner, expected); }
private void AssertCurrent(Scanner scanner, Token expected) { Dump.WriteLine(expected.GetType().Name); Assert.NotNull(scanner.Current); Assert.True(expected.GetType().IsAssignableFrom(scanner.Current.GetType())); foreach (var property in expected.GetType().GetProperties()) { if (property.PropertyType != typeof(Mark) && property.CanRead) { var value = property.GetValue(scanner.Current, null); Dump.WriteLine("\t{0} = {1}", property.Name, value); Assert.Equal(property.GetValue(expected, null), value); } } }
private Token GetCurrentToken() { if (currentToken == null) { if (scanner.InternalMoveNext()) { currentToken = scanner.Current; } } return currentToken; }
private void AssertCurrent(Scanner scanner, Token expected) { Console.WriteLine(expected.GetType().Name); Assert.IsNotNull(scanner.Current, "The current token is null."); Assert.IsTrue(expected.GetType().IsAssignableFrom(scanner.Current.GetType()), "The token is not of the expected type."); foreach (var property in expected.GetType().GetProperties()) { if(property.PropertyType != typeof(Mark) && property.CanRead) { object value = property.GetValue(scanner.Current, null); Console.WriteLine("\t{0} = {1}", property.Name, value); Assert.AreEqual(property.GetValue(expected, null), value, string.Format("The property '{0}' is incorrect.", property.Name)); } } }