@@ -1526,6 +1526,214 @@ extension RegexTests {
15261526 matchingOptions ( adding: . extended) , isIsolated: true , charClass ( " a " , " b " ) )
15271527 )
15281528
1529+ // Test multi-line comment handling.
1530+ parseTest (
1531+ """
1532+ # a
1533+ bc # d
1534+ ef# g
1535+ # h
1536+ """ ,
1537+ concat ( " b " , " c " , " e " , " f " ) ,
1538+ syntax: . extendedSyntax
1539+ )
1540+ parseTest (
1541+ """
1542+ # a \r \
1543+ bc # d \r \
1544+ ef# g \r \
1545+ # h \r
1546+ """ ,
1547+ concat ( " b " , " c " , " e " , " f " ) ,
1548+ syntax: . extendedSyntax
1549+ )
1550+ parseTest (
1551+ """
1552+ # a \r \
1553+ bc # d \r \
1554+ ef# g \r \
1555+ # h \r
1556+ """ ,
1557+ concat ( " b " , " c " , " e " , " f " ) ,
1558+ syntax: . extendedSyntax
1559+ )
1560+ parseTest (
1561+ """
1562+ # a \r
1563+ bc # d \r
1564+ ef# g \r
1565+ # h \r
1566+ """ ,
1567+ concat ( " b " , " c " , " e " , " f " ) ,
1568+ syntax: . extendedSyntax
1569+ )
1570+ parseTest (
1571+ """
1572+ # a \n \r \
1573+ bc # d \n \r \
1574+ ef# g \n \r \
1575+ # h \n \r
1576+ """ ,
1577+ concat ( " b " , " c " , " e " , " f " ) ,
1578+ syntax: . extendedSyntax
1579+ )
1580+ parseTest (
1581+ """
1582+ (*CR)
1583+ # a
1584+ bc # d
1585+ ef# g
1586+ # h
1587+ """ ,
1588+ ast ( empty ( ) , opts: . newlineMatching( . carriageReturnOnly) ) ,
1589+ syntax: . extendedSyntax
1590+ )
1591+ parseTest (
1592+ """
1593+ (*CR) \r \
1594+ # a \r \
1595+ bc # d \r \
1596+ ef# g \r \
1597+ # h
1598+ """ ,
1599+ ast ( concat ( " b " , " c " , " e " , " f " ) , opts: . newlineMatching( . carriageReturnOnly) ) ,
1600+ syntax: . extendedSyntax
1601+ )
1602+ parseTest (
1603+ """
1604+ (*LF)
1605+ # a
1606+ bc # d
1607+ ef# g
1608+ # h
1609+ """ ,
1610+ ast ( concat ( " b " , " c " , " e " , " f " ) , opts: . newlineMatching( . linefeedOnly) ) ,
1611+ syntax: . extendedSyntax
1612+ )
1613+ parseTest (
1614+ """
1615+ (*CRLF)
1616+ # a
1617+ bc # d
1618+ ef# g
1619+ # h
1620+ """ ,
1621+ ast ( empty ( ) , opts: . newlineMatching( . carriageAndLinefeedOnly) ) ,
1622+ syntax: . extendedSyntax
1623+ )
1624+ parseTest (
1625+ """
1626+ (*CRLF)
1627+ # a \r
1628+ bc # d \r
1629+ ef# g \r
1630+ # h
1631+ """ ,
1632+ ast ( concat ( " b " , " c " , " e " , " f " ) , opts: . newlineMatching( . carriageAndLinefeedOnly) ) ,
1633+ syntax: . extendedSyntax
1634+ )
1635+ parseTest (
1636+ """
1637+ (*ANYCRLF)
1638+ # a
1639+ bc # d
1640+ ef# g
1641+ # h
1642+ """ ,
1643+ ast ( concat ( " b " , " c " , " e " , " f " ) , opts: . newlineMatching( . anyCarriageReturnOrLinefeed) ) ,
1644+ syntax: . extendedSyntax
1645+ )
1646+ parseTest (
1647+ """
1648+ (*ANYCRLF)
1649+ # a \r \
1650+ bc # d \r \
1651+ ef# g \r \
1652+ # h
1653+ """ ,
1654+ ast ( concat ( " b " , " c " , " e " , " f " ) , opts: . newlineMatching( . anyCarriageReturnOrLinefeed) ) ,
1655+ syntax: . extendedSyntax
1656+ )
1657+ parseTest (
1658+ """
1659+ (*ANYCRLF)
1660+ # a \r
1661+ bc # d \r
1662+ ef# g \r
1663+ # h
1664+ """ ,
1665+ ast ( concat ( " b " , " c " , " e " , " f " ) , opts: . newlineMatching( . anyCarriageReturnOrLinefeed) ) ,
1666+ syntax: . extendedSyntax
1667+ )
1668+ parseTest (
1669+ """
1670+ (*ANY)
1671+ # a
1672+ bc # d
1673+ ef# g
1674+ # h
1675+ """ ,
1676+ ast ( concat ( " b " , " c " , " e " , " f " ) , opts: . newlineMatching( . anyUnicode) ) ,
1677+ syntax: . extendedSyntax
1678+ )
1679+ parseTest (
1680+ """
1681+ # a \u{2028} \
1682+ bc # d
1683+ ef# g \u{2028} \
1684+ # h
1685+ """ ,
1686+ concat ( " e " , " f " ) ,
1687+ syntax: . extendedSyntax
1688+ )
1689+ parseTest (
1690+ """
1691+ (*ANY)
1692+ # a \u{2028} \
1693+ bc # d \u{2028} \
1694+ ef# g \u{2028} \
1695+ # h
1696+ """ ,
1697+ ast ( concat ( " b " , " c " , " e " , " f " ) , opts: . newlineMatching( . anyUnicode) ) ,
1698+ syntax: . extendedSyntax
1699+ )
1700+ parseTest (
1701+ """
1702+ (*NUL)
1703+ # a
1704+ bc # d \0 \
1705+ ef# g
1706+ # h
1707+ """ ,
1708+ ast ( concat ( " e " , " f " ) , opts: . newlineMatching( . nulCharacter) ) ,
1709+ syntax: . extendedSyntax
1710+ )
1711+ parseTest (
1712+ """
1713+ (*NUL)
1714+ # a \0 \
1715+ bc # d \0 \
1716+ ef# g \0 \
1717+ # h
1718+ """ ,
1719+ ast ( concat ( " b " , " c " , " e " , " f " ) , opts: . newlineMatching( . nulCharacter) ) ,
1720+ syntax: . extendedSyntax
1721+ )
1722+ parseTest (
1723+ """
1724+ (*CR)(*NUL)
1725+ # a \0 \
1726+ bc # d \0 \
1727+ ef# g \0 \
1728+ # h
1729+ """ ,
1730+ ast ( concat ( " b " , " c " , " e " , " f " ) ,
1731+ opts: . newlineMatching( . carriageReturnOnly) ,
1732+ . newlineMatching( . nulCharacter)
1733+ ) ,
1734+ syntax: . extendedSyntax
1735+ )
1736+
15291737 // MARK: Parse with delimiters
15301738
15311739 parseWithDelimitersTest ( " #/a b/# " , concat ( " a " , " " , " b " ) )
0 commit comments