| 10410 | } |
| 10411 | |
| 10412 | bool valid_name_code_point(char32_t code_point, bool first) { |
| 10413 | // https://tc39.es/ecma262/#prod-IdentifierStart |
| 10414 | // Fast paths: |
| 10415 | if (first && |
| 10416 | (code_point == '$' || code_point == '_' || is_ascii_letter(code_point))) { |
| 10417 | return true; |
| 10418 | } |
| 10419 | if (!first && (code_point == '$' || is_ascii_letter_or_digit(code_point))) { |
| 10420 | return true; |
| 10421 | } |
| 10422 | // Slow path... |
| 10423 | if (code_point == 0xffffffff) { |
| 10424 | return false; // minimal error handling |
| 10425 | } |
| 10426 | if (first) { |
| 10427 | auto iter = std::lower_bound( |
| 10428 | std::begin(ada::idna::id_start), std::end(ada::idna::id_start), |
| 10429 | code_point, |
| 10430 | [](const uint32_t* range, uint32_t cp) { return range[1] < cp; }); |
| 10431 | return iter != std::end(id_start) && code_point >= (*iter)[0]; |
| 10432 | } else { |
| 10433 | auto iter = std::lower_bound( |
| 10434 | std::begin(id_continue), std::end(id_continue), code_point, |
| 10435 | [](const uint32_t* range, uint32_t cp) { return range[1] < cp; }); |
| 10436 | return iter != std::end(id_start) && code_point >= (*iter)[0]; |
| 10437 | } |
| 10438 | } |
| 10439 | } // namespace ada::idna |
| 10440 | /* end file src/identifier.cpp */ |
| 10441 | /* end file src/idna.cpp */ |
no test coverage detected