5#include "../parser/parser.hpp"
6#include "../macros.hpp"
9namespace hi {
inline namespace v1 {
11[[nodiscard]]
constexpr static lexer_config theme_selector_lexer_config() noexcept
13 auto r = lexer_config{};
14 r.has_double_quote_string_literal = 1;
15 r.has_color_literal = 1;
16 r.filter_white_space = 1;
17 r.minus_in_identifier = 1;
21template<std::forward_iterator It, std::sentinel_for<It> ItEnd>
22[[nodiscard]]
constexpr std::parse_expected<theme_selector_segment, std::string> parse_selector_segment(It &it, ItEnd last)
24 hi_assert(it != last);
30 if (it == last or it[1] != token::id) {
32 et name after '/', got '{}'.",
token_location(it + 1, last), it[1])};
35 auto r = theme_selector_segment{
static_cast<std::string>(it[1])};
38 while (it != last and *it !=
'/') {
39 if (
auto id = parse_selector_id(it, last)) {
42 }
else if (
id.has_error()) {
46 if (
auto class_name = parse_selector_class(it, last)) {
49 }
else if (class_name.has_error()) {
53 if (
auto attribute = parse_selector_attribute(it, last)) {
54 r.attributes.push_back(*attribute);
56 }
else if (attribute.has_error()) {
64template<std::forward_iterator It, std::sentinel_for<It> ItEnd>
65[[nodiscard]]
constexpr std::expected<theme_selector, std::string> parse_selector(It first, ItEnd last)
67 constexpr auto config = [] {
68 auto r = lexer_config{};
69 r.has_double_quote_string_literal = 1;
70 r.has_color_literal = 1;
71 r.filter_white_space = 1;
72 r.minus_in_identifier = 1;
76 auto lexer_it = lexer<config>.parse(first, last);
77 auto token_it = make_lookahead_iterator<4>(lexer_it);
80 while (token_it != std::sentinel) {
81 if (
auto segment = parse_selector_segment(token_it, std::sentinel)) {
84 r.
back().attributes.clear();
88 }
else if (segment.has_error()) {
The HikoGUI namespace.
Definition array_generic.hpp:20
hi_export constexpr std::string token_location(It &it, ItEnd last, std::string_view path) noexcept
Create a location string for error messages.
Definition token.hpp:163
DOXYGEN BUG.
Definition algorithm_misc.hpp:20