From d7dc4a5861ae234947f79c8d205ac24e492bf2b3 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Sat, 11 Nov 2017 21:05:00 +0000 Subject: [PATCH] [Normative] Add RegExp `dotAll` mode (`s` flag) Proposal repo: https://github.com/tc39/proposal-regexp-dotall-flag --- spec.html | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/spec.html b/spec.html index c28b5d38b4e..732f3c23c03 100644 --- a/spec.html +++ b/spec.html @@ -29491,6 +29491,9 @@

Notation

  • _NcapturingParens_ is the total number of left-capturing parentheses (i.e. the total number of Atom :: `(` Disjunction `)` Parse Nodes) in the pattern. A left-capturing parenthesis is any `(` pattern character that is matched by the `(` terminal of the Atom :: `(` Disjunction `)` production.
  • +
  • + _DotAll_ is *true* if the RegExp object's [[OriginalFlags]] internal slot contains `"s"` and otherwise is *false*. +
  • _IgnoreCase_ is *true* if the RegExp object's [[OriginalFlags]] internal slot contains `"i"` and otherwise is *false*.
  • @@ -30065,7 +30068,9 @@

    Atom

    The production Atom :: `.` evaluates as follows:

    - 1. Let _A_ be the set of all characters except |LineTerminator|. + 1. If _DotAll_ is *true*, then + 1. Let _A_ be the set of all characters. + 1. Otherwise, let _A_ be the set of all characters except |LineTerminator|. 1. Call CharacterSetMatcher(_A_, *false*) and return its Matcher result.

    The production Atom :: `\` AtomEscape evaluates as follows:

    @@ -30474,7 +30479,7 @@

    Runtime Semantics: RegExpInitialize ( _obj_, _pattern_, _flags_ )

    1. Else, let _P_ be ? ToString(_pattern_). 1. If _flags_ is *undefined*, let _F_ be the empty String. 1. Else, let _F_ be ? ToString(_flags_). - 1. If _F_ contains any code unit other than `"g"`, `"i"`, `"m"`, `"u"`, or `"y"` or if it contains the same code unit more than once, throw a *SyntaxError* exception. + 1. If _F_ contains any code unit other than `"g"`, `"i"`, `"m"`, `"s"`, `"u"`, or `"y"` or if it contains the same code unit more than once, throw a *SyntaxError* exception. 1. If _F_ contains `"u"`, let _BMP_ be *false*; else let _BMP_ be *true*. 1. If _BMP_ is *true*, then 1. Parse _P_ using the grammars in and interpreting each of its 16-bit elements as a Unicode BMP code point. UTF-16 decoding is not applied to the elements. The goal symbol for the parse is |Pattern[~U]|. Throw a *SyntaxError* exception if _P_ did not conform to the grammar, if any elements of _P_ were not matched by the parse, or if any Early Error conditions exist. @@ -30680,6 +30685,8 @@

    get RegExp.prototype.flags

    1. If _ignoreCase_ is *true*, append the code unit 0x0069 (LATIN SMALL LETTER I) as the last code unit of _result_. 1. Let _multiline_ be ToBoolean(? Get(_R_, `"multiline"`)). 1. If _multiline_ is *true*, append the code unit 0x006D (LATIN SMALL LETTER M) as the last code unit of _result_. + 1. Let _dotAll_ be ToBoolean(? Get(_R_, `"dotAll"`)). + 1. If _dotAll_ is *true*, append the code unit 0x0073 (LATIN SMALL LETTER S) as the last code unit of _result_. 1. Let _unicode_ be ToBoolean(? Get(_R_, `"unicode"`)). 1. If _unicode_ is *true*, append the code unit 0x0075 (LATIN SMALL LETTER U) as the last code unit of _result_. 1. Let _sticky_ be ToBoolean(? Get(_R_, `"sticky"`)). @@ -30862,6 +30869,21 @@

    RegExp.prototype [ @@search ] ( _string_ )

    + +

    get RegExp.prototype.dotAll

    +

    `RegExp.prototype.dotAll` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:

    + + 1. Let _R_ be the *this* value. + 1. If Type(_R_) is not Object, throw a *TypeError* exception. + 1. If _R_ does not have an [[OriginalFlags]] internal slot, then + 1. If SameValue(_R_, %RegExpPrototype%) is *true*, return *undefined*. + 1. Otherwise, throw a *TypeError* exception. + 1. Let _flags_ be _R_.[[OriginalFlags]]. + 1. If _flags_ contains the code unit 0x0073 (LATIN SMALL LETTER S), return *true*. + 1. Return *false*. + +
    +

    get RegExp.prototype.source