/// <summary> /// Moves to the previous the token. /// </summary> /// <param name="includeWhitespaces">If set to <c>true</c> includes whitespaces.</param> /// <param name="includeComments">If set to <c>true</c> include comments.</param> /// <returns>The token. Check for EndOfFile token-type to detect end-of-file.</returns> public Token PreviousToken(bool includeWhitespaces = false, bool includeComments = false) { while (_tokenEnumerator.MovePrevious()) { var token = _tokenEnumerator.Current; if (token == null) { continue; } _line -= CountLines(token); if (token.Type == TokenType.Newline) { if (includeWhitespaces) { return(token); } continue; } if (!includeWhitespaces && token.Type == TokenType.Whitespace) { continue; } return(token); } return(new Token(TokenType.EndOfFile, string.Empty)); }
public bool MovePrevious() { var success = false; do { success = _tokens.MovePrevious(); } while (success && Text == "\r\n"); return(success); }