The simplest form of extending the current (ES 2015) syntax would probably be extending RegularExpressionBackslashSequence with an optional Unicode property block. I've highlighted my diffs extending section 11.8.5 (Regular Expression Literals).
RegularExpressionLiteral ::
/ RegularExpressionBody / RegularExpressionFlags
RegularExpressionBody ::
RegularExpressionFirstChar RegularExpressionChars
RegularExpressionChars ::
[empty]
RegularExpressionChars RegularExpressionChar
RegularExpressionFirstChar ::
RegularExpressionNonTerminator but not one of * or \ or / or [
RegularExpressionBackslashSequence
RegularExpressionClass
RegularExpressionChar ::
RegularExpressionNonTerminator but not one of \ or / or [
RegularExpressionBackslashSequence
RegularExpressionClass
RegularExpressionBackslashSequence ::
\ RegularExpressionNonTerminator RegularExpressionNonTerminatorBlockopt
RegularExpressionNonTerminatorBlock ::
RegularExpressionNonTerminatorBlockChar
{ RegularExpressionNonTerminatorBlockChars }
RegularExpressionNonTerminatorBlockChars ::
[empty]
RegularExpressionNonTerminatorBlockChars RegularExpressionNonTerminatorBlockChar
RegularExpressionNonTerminatorBlockChar ::
RegularExpressionNonTerminator but not }
RegularExpressionNonTerminator ::
SourceCharacter but not LineTerminator
RegularExpressionClass ::
[ RegularExpressionClassChars ]
RegularExpressionClassChars ::
[empty]
RegularExpressionClassChars RegularExpressionClassChar
RegularExpressionClassChar ::
RegularExpressionNonTerminator but not one of ] or \
RegularExpressionBackslashSequence
RegularExpressionFlags ::
[empty]
RegularExpressionFlags IdentifierPart
This would make \p{…}
, \P{…}
and others part of the syntax, but note that this approach would make \d{…}
syntactically valid, too.
I'm not sure if empty _RegularExpressionNonTerminatorBlock_s should make any sense at all. It would be an easy fix for the grammar to enforce at least one character in _RegularExpressionNonTerminatorBlock_s, but I have yet to find out if any RE engine supports empty blocks and how they behave if they see them.