| 10252 | |
| 10253 | template <url_pattern_regex::regex_concept regex_provider> |
| 10254 | tl::expected<url_pattern_init, errors> |
| 10255 | constructor_string_parser<regex_provider>::parse(std::string_view input) { |
| 10256 | ada_log("constructor_string_parser::parse input=", input); |
| 10257 | // Let parser be a new constructor string parser whose input is input and |
| 10258 | // token list is the result of running tokenize given input and "lenient". |
| 10259 | auto token_list = tokenize(input, token_policy::lenient); |
| 10260 | if (!token_list) { |
| 10261 | return tl::unexpected(token_list.error()); |
| 10262 | } |
| 10263 | auto parser = constructor_string_parser(input, std::move(*token_list)); |
| 10264 | |
| 10265 | // While parser's token index is less than parser's token list size: |
| 10266 | while (parser.token_index < parser.token_list.size()) { |
| 10267 | // Set parser's token increment to 1. |
| 10268 | parser.token_increment = 1; |
| 10269 | |
| 10270 | // If parser's token list[parser's token index]'s type is "end" then: |
| 10271 | if (parser.token_list[parser.token_index].type == token_type::END) { |
| 10272 | // If parser's state is "init": |
| 10273 | if (parser.state == State::INIT) { |
| 10274 | // Run rewind given parser. |
| 10275 | parser.rewind(); |
| 10276 | // If the result of running is a hash prefix given parser is true, then |
| 10277 | // run change state given parser, "hash" and 1. |
| 10278 | if (parser.is_hash_prefix()) { |
| 10279 | parser.change_state(State::HASH, 1); |
| 10280 | } else if (parser.is_search_prefix()) { |
| 10281 | // Otherwise if the result of running is a search prefix given parser |
| 10282 | // is true: Run change state given parser, "search" and 1. |
| 10283 | parser.change_state(State::SEARCH, 1); |
| 10284 | } else { |
| 10285 | // Run change state given parser, "pathname" and 0. |
| 10286 | parser.change_state(State::PATHNAME, 0); |
| 10287 | } |
| 10288 | // Increment parser's token index by parser's token increment. |
| 10289 | parser.token_index += parser.token_increment; |
| 10290 | // Continue. |
| 10291 | continue; |
| 10292 | } |
| 10293 | |
| 10294 | if (parser.state == State::AUTHORITY) { |
| 10295 | // If parser's state is "authority": |
| 10296 | // Run rewind and set state given parser, and "hostname". |
| 10297 | parser.rewind(); |
| 10298 | parser.change_state(State::HOSTNAME, 0); |
| 10299 | // Increment parser's token index by parser's token increment. |
| 10300 | parser.token_index += parser.token_increment; |
| 10301 | // Continue. |
| 10302 | continue; |
| 10303 | } |
| 10304 | |
| 10305 | // Run change state given parser, "done" and 0. |
| 10306 | parser.change_state(State::DONE, 0); |
| 10307 | // Break. |
| 10308 | break; |
| 10309 | } |
| 10310 | |
| 10311 | // If the result of running is a group open given parser is true: |
no test coverage detected