mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:27:34 +00:00
LibGUI: Use CharacterTypes.h and constexpr functions in {INI,GML}Lexer
This commit is contained in:
parent
e10278402f
commit
e7b5dbe1ac
2 changed files with 14 additions and 14 deletions
|
@ -5,8 +5,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "GMLLexer.h"
|
#include "GMLLexer.h"
|
||||||
|
#include <AK/CharacterTypes.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
|
@ -36,19 +36,19 @@ char GMLLexer::consume()
|
||||||
return ch;
|
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()
|
Vector<GMLToken> GMLLexer::lex()
|
||||||
|
@ -83,9 +83,9 @@ Vector<GMLToken> GMLLexer::lex()
|
||||||
};
|
};
|
||||||
|
|
||||||
while (m_index < m_input.length()) {
|
while (m_index < m_input.length()) {
|
||||||
if (isspace(peek(0))) {
|
if (is_ascii_space(peek(0))) {
|
||||||
begin_token();
|
begin_token();
|
||||||
while (isspace(peek()))
|
while (is_ascii_space(peek()))
|
||||||
consume();
|
consume();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ Vector<GMLToken> GMLLexer::lex()
|
||||||
consume();
|
consume();
|
||||||
commit_token(GMLToken::Type::Colon);
|
commit_token(GMLToken::Type::Colon);
|
||||||
|
|
||||||
while (isspace(peek()))
|
while (is_ascii_space(peek()))
|
||||||
consume();
|
consume();
|
||||||
|
|
||||||
if (peek(0) == '@') {
|
if (peek(0) == '@') {
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "INILexer.h"
|
#include "INILexer.h"
|
||||||
|
#include <AK/CharacterTypes.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
|
@ -61,16 +61,16 @@ Vector<IniToken> IniLexer::lex()
|
||||||
IniToken token;
|
IniToken token;
|
||||||
token.m_type = type;
|
token.m_type = type;
|
||||||
token.m_start = token_start_position;
|
token.m_start = token_start_position;
|
||||||
token.m_end = m_previous_position;
|
token.m_end = m_position;
|
||||||
tokens.append(token);
|
tokens.append(token);
|
||||||
};
|
};
|
||||||
|
|
||||||
while (m_index < m_input.length()) {
|
while (m_index < m_input.length()) {
|
||||||
auto ch = peek();
|
auto ch = peek();
|
||||||
|
|
||||||
if (isspace(ch)) {
|
if (is_ascii_space(ch)) {
|
||||||
begin_token();
|
begin_token();
|
||||||
while (isspace(peek()))
|
while (is_ascii_space(peek()))
|
||||||
consume();
|
consume();
|
||||||
commit_token(IniToken::Type::Whitespace);
|
commit_token(IniToken::Type::Whitespace);
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue