summaryrefslogtreecommitdiff
path: root/AK/GenericLexer.cpp
AgeCommit message (Collapse)Author
2022-12-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-02-16AK: Exclude GenericLexer String APIs from the KernelIdan Horowitz
These APIs are only used by userland, and String is OOM-infallible, so let's just ifdef it out of the Kernel.
2022-01-25AK: Standardize the behaviour of GenericLexer::consume_until overloadsIdan Horowitz
Before this commit all consume_until overloads aside from the Predicate one would consume (and ignore) the stop char/string, while the Predicate overload would not, in order to keep behaviour consistent, the other overloads no longer consume the stop char/string as well.
2022-01-25AK: Add a consume_until(StringView) overload to GenericLexerIdan Horowitz
This allows us to skip a strlen call.
2021-08-19AK: Add GenericLexer API to consume an escaped Unicode code pointTimothy Flynn
This parsing is already duplicated between LibJS and LibRegex, and will shortly be needed in more places in those libraries. Move it to AK to prevent further duplication. This API will consume escaped Unicode code points of the form: \\u{code point} \\unnnn (where each n is a hexadecimal digit) \\unnnn\\unnnn (where the two escaped values are a surrogate pair)
2021-04-22AK/GenericLexer: constexpr where possibleLenny Maiorani
Problem: - Much of the `GenericLexer` can be `constexpr`, but is not. Solution: - Make it `constexpr` and de-duplicate code. - Extend some of `StringView` with `constexpr` to support. - Add tests to ensure `constexpr` behavior. Note: - Construction of `StringView` from pointer and length is not `constexpr`-compatible at the moment because the VERIFY cannot be, yet.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2020-10-29AK: Add GenericLexer::retreat()Linus Groh
This allows going back one character at a time, and then re-consume previously consumed chars. The code I need this for looks something like this: ASSERT(lexer.consume_specific('\\')); if (lexer.next_is("foo")) ... lexer.retreat(); lexer.consume_escaped_character(); // This expects lexer.peek() == '\\'
2020-10-22AK: Add `GenericLexer::consume_escaped_character()'AnotherTest
...and use it in `consume_and_unescape_string()'.
2020-10-02AK+Format: Do some housekeeping in the format implementation.asynts
2020-09-27AK: Remove the ctype adapters and use the actual ctype functions insteadBenoît Lormeau
This finally takes care of the kind-of excessive boilerplate code that were the ctype adapters. On the other hand, I had to link `LibC/ctype.cpp` to the Kernel (for `AK/JsonParser.cpp` and `AK/Format.cpp`). The previous commit actually makes sense now: the `string.h` includes in `ctype.{h,cpp}` would require to link more LibC stuff to the Kernel when it only needs the `_ctype_` array of `ctype.cpp`, and there wasn't any string stuff used in ctype. Instead of all this I could have put static derivatives of `is_any_of()` in the concerned AK files, however that would have meant more boilerplate and workarounds; so I went for the Kernel approach.
2020-09-27AK: Use templates instead of Function for Conditions in the GenericLexerBenoit Lormeau
Since commit 1ec59f28cea56f1afced0994127e2df62300e618 turns the ctype macros into functions we can now feed them directly to a GenericLexer! This will lead to removing the ctype adapters that were kind-of excessive boilerplate, but needed as the Kernel doesn't compile with the LibC.
2020-09-26AK: Enhance GenericLexer's string consumptionBenoit Lormeau
The `consume_quoted_string()` can now take an escape character. This allows it (for example) to capture a string's enclosing quotes. The escape character is optional by default. You can also consume and unescape a quoted string with the eponymous method `consume_and_unescape_string()`. It takes an escape character as parameter (backslash by default). It builds a String in which common escape sequences get... unescaped :^) (e.g. \n, \r, \t...).
2020-09-26AK: Alphabetically sort the ctype adaptersBenoit Lormeau
2020-09-25Meta+AK: Make clang-format-10 cleanBen Wiederhake
2020-08-21LibWeb: Use GenericLexer in WrapperGeneratorNico Weber
2020-08-09AK: Add a GenericLexer and extend the JsonParser with it (#2696)Benoît Lormeau