@@ -1746,44 +1746,26 @@ export class RegExpValidator {
1746
1746
*/
1747
1747
private consumeModifiers ( ) : boolean {
1748
1748
const start = this . index
1749
+ this . onModifiersEnter ( start )
1750
+ const hasAddModifiers = this . eatModifiers ( )
1751
+ const addModifiers = this . parseModifiers ( start , this . index )
1752
+ this . onAddModifiers ( start , this . index , addModifiers )
1749
1753
1750
- if ( this . eatModifiers ( ) ) {
1751
- this . onModifiersEnter ( start )
1752
- const addModifiers = this . parseModifiers ( start , this . index )
1753
- this . onAddModifiers ( start , this . index , addModifiers )
1754
- if ( this . eat ( HYPHEN_MINUS ) ) {
1755
- const modifiersStart = this . index
1756
- if ( this . eatModifiers ( ) ) {
1757
- const modifiers = this . parseModifiers (
1758
- modifiersStart ,
1759
- this . index ,
1760
- addModifiers ,
1761
- )
1762
- this . onRemoveModifiers (
1763
- modifiersStart ,
1764
- this . index ,
1765
- modifiers ,
1766
- )
1767
- }
1768
- }
1769
- this . onModifiersLeave ( start , this . index )
1770
- return true
1771
- } else if ( this . eat ( HYPHEN_MINUS ) ) {
1772
- this . onModifiersEnter ( start )
1754
+ if ( this . eat ( HYPHEN_MINUS ) ) {
1773
1755
const modifiersStart = this . index
1774
- if ( this . eatModifiers ( ) ) {
1775
- const modifiers = this . parseModifiers (
1776
- modifiersStart ,
1777
- this . index ,
1778
- )
1779
- this . onRemoveModifiers ( modifiersStart , this . index , modifiers )
1780
- } else {
1756
+ if ( ! this . eatModifiers ( ) && ! hasAddModifiers ) {
1781
1757
this . raise ( "Invalid empty flags" )
1782
1758
}
1783
- this . onModifiersLeave ( start , this . index )
1784
- return true
1759
+ const modifiers = this . parseModifiers (
1760
+ modifiersStart ,
1761
+ this . index ,
1762
+ addModifiers ,
1763
+ )
1764
+ this . onRemoveModifiers ( modifiersStart , this . index , modifiers )
1785
1765
}
1786
- return false
1766
+
1767
+ this . onModifiersLeave ( start , this . index )
1768
+ return true
1787
1769
}
1788
1770
1789
1771
/**
0 commit comments