static t_result lex_word(const char **string_p) { t_result result; const char *begin; const char *end; t_token *token; begin = *string_p; end = begin; while (*end && !char_is_whitespace(*end)) { result = lex_token_impl(string_p); if (result.error) return (result); if (result.token) { *string_p = end; break ; } (*string_p)++; end = *string_p; } if (begin == end) return (RESULT_NULL); token = TOKEN_NEW_RANGE(WORD, begin, end); return (RESULT_TOKEN(token)); }
bool string_is_whitespace(string s){ for (unsigned int i = 0; i < s.length(); i++){ if (!char_is_whitespace(s[i])){ return false; } } return true; }
string strip_whitespace_from_string(string s){ string ret = ""; for (unsigned int i = 0; i < s.length(); i++){ if (!char_is_whitespace(s[i])){ ret += s[i]; } } return ret; }
void skip_whitespaces(const char **string_p) { while (char_is_whitespace(**string_p)) NEXT(string_p); }