summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
diff options
context:
space:
mode:
authorMax Wipfli <mail@maxwipfli.ch>2021-06-04 00:02:12 +0200
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-06-05 00:32:28 +0430
commite7b5dbe1acd5d53ffc7f4821aad1caf69c0b2749 (patch)
tree0239720c0f0cac21a868308a67416bddcde67125 /Userland/Libraries/LibGUI
parente10278402f3965e2c3caaebe752c3758ecddd2a4 (diff)
downloadserenity-e7b5dbe1acd5d53ffc7f4821aad1caf69c0b2749.zip
LibGUI: Use CharacterTypes.h and constexpr functions in {INI,GML}Lexer
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r--Userland/Libraries/LibGUI/GMLLexer.cpp20
-rw-r--r--Userland/Libraries/LibGUI/INILexer.cpp8
2 files changed, 14 insertions, 14 deletions
diff --git a/Userland/Libraries/LibGUI/GMLLexer.cpp b/Userland/Libraries/LibGUI/GMLLexer.cpp
index 1f97e3ac90..9c30d0656e 100644
--- a/Userland/Libraries/LibGUI/GMLLexer.cpp
+++ b/Userland/Libraries/LibGUI/GMLLexer.cpp
@@ -5,8 +5,8 @@
*/
#include "GMLLexer.h"
+#include <AK/CharacterTypes.h>
#include <AK/Vector.h>
-#include <ctype.h>
namespace GUI {
@@ -36,19 +36,19 @@ char GMLLexer::consume()
return ch;
}
-static bool is_valid_identifier_start(char ch)
+constexpr bool is_valid_identifier_start(char ch)
{
- return isalpha(ch) || ch == '_';
+ return is_ascii_alpha(ch) || ch == '_';
}
-static bool is_valid_identifier_character(char ch)
+constexpr bool is_valid_identifier_character(char ch)
{
- return isalnum(ch) || ch == '_';
+ return is_ascii_alphanumeric(ch) || ch == '_';
}
-static bool is_valid_class_character(char ch)
+constexpr bool is_valid_class_character(char ch)
{
- return isalnum(ch) || ch == '_' || ch == ':';
+ return is_ascii_alphanumeric(ch) || ch == '_' || ch == ':';
}
Vector<GMLToken> GMLLexer::lex()
@@ -83,9 +83,9 @@ Vector<GMLToken> GMLLexer::lex()
};
while (m_index < m_input.length()) {
- if (isspace(peek(0))) {
+ if (is_ascii_space(peek(0))) {
begin_token();
- while (isspace(peek()))
+ while (is_ascii_space(peek()))
consume();
continue;
}
@@ -132,7 +132,7 @@ Vector<GMLToken> GMLLexer::lex()
consume();
commit_token(GMLToken::Type::Colon);
- while (isspace(peek()))
+ while (is_ascii_space(peek()))
consume();
if (peek(0) == '@') {
diff --git a/Userland/Libraries/LibGUI/INILexer.cpp b/Userland/Libraries/LibGUI/INILexer.cpp
index e1eb181c10..d602059ae0 100644
--- a/Userland/Libraries/LibGUI/INILexer.cpp
+++ b/Userland/Libraries/LibGUI/INILexer.cpp
@@ -5,8 +5,8 @@
*/
#include "INILexer.h"
+#include <AK/CharacterTypes.h>
#include <AK/Vector.h>
-#include <ctype.h>
namespace GUI {
@@ -61,16 +61,16 @@ Vector<IniToken> IniLexer::lex()
IniToken token;
token.m_type = type;
token.m_start = token_start_position;
- token.m_end = m_previous_position;
+ token.m_end = m_position;
tokens.append(token);
};
while (m_index < m_input.length()) {
auto ch = peek();
- if (isspace(ch)) {
+ if (is_ascii_space(ch)) {
begin_token();
- while (isspace(peek()))
+ while (is_ascii_space(peek()))
consume();
commit_token(IniToken::Type::Whitespace);
continue;