MCPcopy Create free account
hub / github.com/Genivia/RE-flex / parse_esc

Method parse_esc

lib/pattern.cpp:1600–1734  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1598}
1599
1600Pattern::Char Pattern::parse_esc(Location& loc, Chars *chars) const
1601{
1602 Char c = at(++loc);
1603 if (c == '0')
1604 {
1605 c = 0;
1606 int d = at(++loc);
1607 if (d >= '0' && d <= '7')
1608 {
1609 c = d - '0';
1610 d = at(++loc);
1611 if (d >= '0' && d <= '7')
1612 {
1613 c = (c << 3) + d - '0';
1614 d = at(++loc);
1615 if (c < 32 && d >= '0' && d <= '7')
1616 {
1617 c = (c << 3) + d - '0';
1618 ++loc;
1619 }
1620 }
1621 }
1622 }
1623 else if ((c == 'x' || c == 'u') && at(loc + 1) == '{')
1624 {
1625 c = 0;
1626 loc += 2;
1627 int d = at(loc);
1628 if (std::isxdigit(d))
1629 {
1630 c = (d > '9' ? (d | 0x20) - ('a' - 10) : d - '0');
1631 d = at(++loc);
1632 if (std::isxdigit(d))
1633 {
1634 c = (c << 4) + (d > '9' ? (d | 0x20) - ('a' - 10) : d - '0');
1635 ++loc;
1636 }
1637 }
1638 if (at(loc) == '}')
1639 ++loc;
1640 else
1641 error(regex_error::invalid_escape, loc);
1642 }
1643 else if (c == 'x' && std::isxdigit(at(loc + 1)))
1644 {
1645 int d = at(++loc);
1646 c = (d > '9' ? (d | 0x20) - ('a' - 10) : d - '0');
1647 d = at(++loc);
1648 if (std::isxdigit(d))
1649 {
1650 c = (c << 4) + (d > '9' ? (d | 0x20) - ('a' - 10) : d - '0');
1651 ++loc;
1652 }
1653 }
1654 else if (c == 'c')
1655 {
1656 c = at(++loc) % 32;
1657 ++loc;

Callers

nothing calls this directly

Calls 3

atFunction · 0.85
errorFunction · 0.50
addMethod · 0.45

Tested by

no test coverage detected