diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/elna/boot/driver.h | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/include/elna/boot/driver.h b/include/elna/boot/driver.h index 9076e23..45e2e40 100644 --- a/include/elna/boot/driver.h +++ b/include/elna/boot/driver.h @@ -45,15 +45,31 @@ namespace elna::boot constexpr char escape_invalid_char = '\xff'; - char escape_char(char escape); /** - * Replaces both \r\n sequences and lone \r characters with \n. - * Modifies the original input. + * Parses a character literal and produces code point integer + * representation. * - * \param string Text to normalize. + * \param escape Text to parse. + * \return Code point. */ - void normalize_newlines(std::string& string); - std::optional<std::string> escape_string(const char *escape); + std::optional<std::uint32_t> parse_character_literal(const char *escape); + + /** + * Parses and unescapes a single byte character. Fails if the input inside + * single quotes contains more than a single character. Rejects unicode. + * + * \param escape Text to unescape. + * \return Unescaped character. + */ + std::optional<std::uint8_t> parse_byte_literal(const char *escape); + + /** + * Parses and unescapes a string. + * + * \param escape Text to unescape. + * \return Unescaped string. + */ + std::optional<std::string> parse_string_literal(const char *escape); template<typename T> std::optional<std::pair<std::make_unsigned_t<T>, integer_sign>> |
