mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +00:00
AK: Exclude GenericLexer String APIs from the Kernel
These APIs are only used by userland, and String is OOM-infallible, so let's just ifdef it out of the Kernel.
This commit is contained in:
parent
410183a7b0
commit
b22cb40565
2 changed files with 15 additions and 2 deletions
|
@ -7,9 +7,12 @@
|
||||||
#include <AK/Assertions.h>
|
#include <AK/Assertions.h>
|
||||||
#include <AK/CharacterTypes.h>
|
#include <AK/CharacterTypes.h>
|
||||||
#include <AK/GenericLexer.h>
|
#include <AK/GenericLexer.h>
|
||||||
#include <AK/String.h>
|
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <AK/Utf16View.h>
|
|
||||||
|
#ifndef KERNEL
|
||||||
|
# include <AK/String.h>
|
||||||
|
# include <AK/Utf16View.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
// Consume a number of characters
|
// Consume a number of characters
|
||||||
|
@ -125,6 +128,7 @@ StringView GenericLexer::consume_quoted_string(char escape_char)
|
||||||
return m_input.substring_view(start, length);
|
return m_input.substring_view(start, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef KERNEL
|
||||||
String GenericLexer::consume_and_unescape_string(char escape_char)
|
String GenericLexer::consume_and_unescape_string(char escape_char)
|
||||||
{
|
{
|
||||||
auto view = consume_quoted_string(escape_char);
|
auto view = consume_quoted_string(escape_char);
|
||||||
|
@ -206,5 +210,6 @@ auto GenericLexer::decode_single_or_paired_surrogate(bool combine_surrogate_pair
|
||||||
retreat(6);
|
retreat(6);
|
||||||
return *high_surrogate;
|
return *high_surrogate;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,10 +83,12 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef KERNEL
|
||||||
bool consume_specific(const String& next)
|
bool consume_specific(const String& next)
|
||||||
{
|
{
|
||||||
return consume_specific(StringView { next });
|
return consume_specific(StringView { next });
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
constexpr bool consume_specific(const char* next)
|
constexpr bool consume_specific(const char* next)
|
||||||
{
|
{
|
||||||
|
@ -115,14 +117,18 @@ public:
|
||||||
StringView consume_until(const char*);
|
StringView consume_until(const char*);
|
||||||
StringView consume_until(StringView);
|
StringView consume_until(StringView);
|
||||||
StringView consume_quoted_string(char escape_char = 0);
|
StringView consume_quoted_string(char escape_char = 0);
|
||||||
|
#ifndef KERNEL
|
||||||
String consume_and_unescape_string(char escape_char = '\\');
|
String consume_and_unescape_string(char escape_char = '\\');
|
||||||
|
#endif
|
||||||
|
|
||||||
enum class UnicodeEscapeError {
|
enum class UnicodeEscapeError {
|
||||||
MalformedUnicodeEscape,
|
MalformedUnicodeEscape,
|
||||||
UnicodeEscapeOverflow,
|
UnicodeEscapeOverflow,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef KERNEL
|
||||||
Result<u32, UnicodeEscapeError> consume_escaped_code_point(bool combine_surrogate_pairs = true);
|
Result<u32, UnicodeEscapeError> consume_escaped_code_point(bool combine_surrogate_pairs = true);
|
||||||
|
#endif
|
||||||
|
|
||||||
constexpr void ignore(size_t count = 1)
|
constexpr void ignore(size_t count = 1)
|
||||||
{
|
{
|
||||||
|
@ -212,8 +218,10 @@ protected:
|
||||||
size_t m_index { 0 };
|
size_t m_index { 0 };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#ifndef KERNEL
|
||||||
Result<u32, UnicodeEscapeError> decode_code_point();
|
Result<u32, UnicodeEscapeError> decode_code_point();
|
||||||
Result<u32, UnicodeEscapeError> decode_single_or_paired_surrogate(bool combine_surrogate_pairs);
|
Result<u32, UnicodeEscapeError> decode_single_or_paired_surrogate(bool combine_surrogate_pairs);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr auto is_any_of(StringView values)
|
constexpr auto is_any_of(StringView values)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue