/// <summary> /// Gets next token. /// </summary> /// <param name="includeWhitespaces">When false, all white-space tokens will be ignored.</param> /// <param name="includeComments">When false, all comment (single line and multi-line) tokens will be ignored.</param> /// <returns>The token. Check for EndOfFile token-type to detect end-of-file.</returns> public Token NextToken(bool includeWhitespaces = false, bool includeComments = false) { while (_tokenEnumerator.MoveNext()) { 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 virtual bool Move() { var success = false; do { success = _tokens.MoveNext(); } while (success && Text == "\r\n"); return(success); }
/// <summary> /// Converts a string from lower_case to CamelCase. /// /// <param name="lower_case">a string in lower case</param> /// <returns>the specified string converted to camel case</returns> /// </summary> public static string lower_case_to_camel_case(string lower_case) { var result_builder = new StringBuilder(""); ITwoWayEnumerator <char> i = lower_case.GetTwoWayEnumerator(); i.MoveNext(); int length = lower_case.Length; bool last_underscore = true; while (true) { char c = i.Current; if (c == '_') { last_underscore = true; } else if (Char.IsUpper(c)) { // original string is not lower_case, don't apply transformation return(lower_case); } else if (last_underscore) { result_builder.Append(Char.ToUpper(c)); last_underscore = false; } else { result_builder.Append(c); } if (!i.MoveNext()) { break; } } return(result_builder.ToString()); }