summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AK/GenericLexer.cpp63
1 files changed, 32 insertions, 31 deletions
diff --git a/AK/GenericLexer.cpp b/AK/GenericLexer.cpp
index c5818f714b..e49d41e690 100644
--- a/AK/GenericLexer.cpp
+++ b/AK/GenericLexer.cpp
@@ -269,31 +269,27 @@ void GenericLexer::ignore_until(const char* stop)
}
// Ignore characters until `condition` return true
-// We don't skip the stop character as it may not be a single value
+// We don't skip the stop character as it may not be a unique value
void GenericLexer::ignore_until(Condition condition)
{
while (!is_eof() && !condition(peek()))
m_index++;
}
-bool is_control(char c)
-{
- return (c >= 0 && c <= 31) || c == 127;
-}
-
-bool is_whitespace(char c)
+// CType adapters
+bool is_alpha(char c)
{
- return (c >= '\t' && c <= '\r') || c == ' ';
+ return is_lowercase(c) || is_uppercase(c);
}
-bool is_lowercase(char c)
+bool is_alphanum(char c)
{
- return c >= 'a' && c <= 'z';
+ return is_alpha(c) || is_digit(c);
}
-bool is_uppercase(char c)
+bool is_control(char c)
{
- return c >= 'A' && c <= 'Z';
+ return (c >= 0 && c <= 31) || c == 127;
}
bool is_digit(char c)
@@ -301,39 +297,39 @@ bool is_digit(char c)
return c >= '0' && c <= '9';
}
-bool is_punctuation(char c)
+bool is_graphic(char c)
{
- return (c >= '!' && c <= '/')
- || (c >= ':' && c <= '@')
- || (c >= '[' && c <= '`')
- || (c >= '{' && c <= '~');
+ return c > ' ' && c <= '~';
}
-bool is_printable(char c)
+bool is_hex_digit(char c)
{
- return c >= ' ' && c <= '~';
+ return is_digit(c)
+ || (c >= 'A' && c <= 'F')
+ || (c >= 'a' && c <= 'f');
}
-bool is_graphic(char c)
+bool is_lowercase(char c)
{
- return c > ' ' && c <= '~';
+ return c >= 'a' && c <= 'z';
}
-bool is_alpha(char c)
+bool is_path_separator(char c)
{
- return is_lowercase(c) || is_uppercase(c);
+ return c == '/' || c == '\\';
}
-bool is_alphanum(char c)
+bool is_printable(char c)
{
- return is_alpha(c) || is_digit(c);
+ return c >= ' ' && c <= '~';
}
-bool is_hex_digit(char c)
+bool is_punctuation(char c)
{
- return is_digit(c)
- || (c >= 'A' && c <= 'F')
- || (c >= 'a' && c <= 'f');
+ return (c >= '!' && c <= '/')
+ || (c >= ':' && c <= '@')
+ || (c >= '[' && c <= '`')
+ || (c >= '{' && c <= '~');
}
bool is_quote(char c)
@@ -341,9 +337,14 @@ bool is_quote(char c)
return c == '\'' || c == '"';
}
-bool is_path_separator(char c)
+bool is_uppercase(char c)
{
- return c == '/' || c == '\\';
+ return c >= 'A' && c <= 'Z';
+}
+
+bool is_whitespace(char c)
+{
+ return (c >= '\t' && c <= '\r') || c == ' ';
}
}