| 499 | } |
| 500 | |
| 501 | uint32_t parseUnicodeCharacterNumber (bool isLowSurrogate) |
| 502 | { |
| 503 | uint32_t result = 0; |
| 504 | |
| 505 | for (int i = 4; --i >= 0;) |
| 506 | { |
| 507 | auto errorPos = current; |
| 508 | auto digit = pop(); |
| 509 | |
| 510 | if (digit >= '0' && digit <= '9') digit -= '0'; |
| 511 | else if (digit >= 'a' && digit <= 'f') digit = 10 + (digit - 'a'); |
| 512 | else if (digit >= 'A' && digit <= 'F') digit = 10 + (digit - 'A'); |
| 513 | else throwError ("Syntax error in unicode character", errorPos); |
| 514 | |
| 515 | result = (result << 4) + digit; |
| 516 | } |
| 517 | |
| 518 | if (isLowSurrogate && ! text::isUnicodeLowSurrogate (result)) |
| 519 | throwError ("Expected a unicode low surrogate codepoint"); |
| 520 | |
| 521 | if (text::isUnicodeHighSurrogate (result)) |
| 522 | { |
| 523 | if (! isLowSurrogate && popIf ("\\u")) |
| 524 | return text::createUnicodeFromHighAndLowSurrogates ({ result, parseUnicodeCharacterNumber (true) }); |
| 525 | |
| 526 | throwError ("Expected a unicode low surrogate codepoint"); |
| 527 | } |
| 528 | |
| 529 | return result; |
| 530 | } |
| 531 | }; |
| 532 | |
| 533 | Parser p { text, text }; |
nothing calls this directly
no test coverage detected