@see https://urlpattern.spec.whatwg.org/#tokenizer
| 5542 | |
| 5543 | // @see https://urlpattern.spec.whatwg.org/#tokenizer |
| 5544 | class Tokenizer { |
| 5545 | public: |
| 5546 | explicit Tokenizer(std::string_view new_input, token_policy new_policy) |
| 5547 | : input(new_input), policy(new_policy) {} |
| 5548 | |
| 5549 | // @see https://urlpattern.spec.whatwg.org/#get-the-next-code-point |
| 5550 | constexpr void get_next_code_point(); |
| 5551 | |
| 5552 | // @see https://urlpattern.spec.whatwg.org/#seek-and-get-the-next-code-point |
| 5553 | constexpr void seek_and_get_next_code_point(size_t index); |
| 5554 | |
| 5555 | // @see https://urlpattern.spec.whatwg.org/#add-a-token |
| 5556 | |
| 5557 | void add_token(token_type type, size_t next_position, size_t value_position, |
| 5558 | size_t value_length); |
| 5559 | |
| 5560 | // @see https://urlpattern.spec.whatwg.org/#add-a-token-with-default-length |
| 5561 | void add_token_with_default_length(token_type type, size_t next_position, |
| 5562 | size_t value_position); |
| 5563 | |
| 5564 | // @see |
| 5565 | // https://urlpattern.spec.whatwg.org/#add-a-token-with-default-position-and-length |
| 5566 | void add_token_with_defaults(token_type type); |
| 5567 | |
| 5568 | // @see https://urlpattern.spec.whatwg.org/#process-a-tokenizing-error |
| 5569 | std::optional<errors> process_tokenizing_error( |
| 5570 | size_t next_position, size_t value_position) ada_warn_unused; |
| 5571 | |
| 5572 | friend tl::expected<std::vector<token>, errors> tokenize( |
| 5573 | std::string_view input, token_policy policy); |
| 5574 | |
| 5575 | private: |
| 5576 | // has an associated input, a pattern string, initially the empty string. |
| 5577 | std::string input; |
| 5578 | // has an associated policy, a tokenize policy, initially "strict". |
| 5579 | token_policy policy; |
| 5580 | // has an associated token list, a token list, initially an empty list. |
| 5581 | std::vector<token> token_list{}; |
| 5582 | // has an associated index, a number, initially 0. |
| 5583 | size_t index = 0; |
| 5584 | // has an associated next index, a number, initially 0. |
| 5585 | size_t next_index = 0; |
| 5586 | // has an associated code point, a Unicode code point, initially null. |
| 5587 | char32_t code_point{}; |
| 5588 | }; |
| 5589 | |
| 5590 | // @see https://urlpattern.spec.whatwg.org/#constructor-string-parser |
| 5591 | template <url_pattern_regex::regex_concept regex_provider> |