diff --git a/spec/negotiation.html b/spec/negotiation.html index 4963328d..34a46fae 100644 --- a/spec/negotiation.html +++ b/spec/negotiation.html @@ -435,29 +435,26 @@

description
- The [[Value]] field will be a String value if [[Type]] is *"literal"*, and *undefined* otherwise. + It interprets _pattern_ as containing an arbitrary number of brace-wrapped "placeholder" substrings and returns a List in which each such placeholder is represented as a Record with [[Type]] equal to the unwrapped substring and [[Value]] equal to *undefined*, and each non-empty substring adjacent to or between such placeholders is represented as a Record with [[Type]] equal to *"literal"* and [[Value]] equal to the substring, preserving the relative order of appearance such that _pattern_ could be recovered by concatenating the value from the appropriate field of each Record in turn. The syntax of the abstract pattern strings is an implementation detail and is not exposed to users of ECMA-402.
1. Let _result_ be a new empty List. - 1. Let _beginIndex_ be StringIndexOf(_pattern_, *"{"*, 0). - 1. Let _endIndex_ be 0. - 1. Let _nextIndex_ be 0. - 1. Let _length_ be the number of code units in _pattern_. - 1. Repeat, while _beginIndex_ is an integer index into _pattern_, - 1. Set _endIndex_ to StringIndexOf(_pattern_, *"}"*, _beginIndex_). - 1. Assert: _endIndex_ is greater than _beginIndex_. - 1. If _beginIndex_ is greater than _nextIndex_, then - 1. Let _literal_ be a substring of _pattern_ from position _nextIndex_, inclusive, to position _beginIndex_, exclusive. + 1. Let _placeholderEnd_ be -1. + 1. Let _placeholderStart_ be StringIndexOf(_pattern_, *"{"*, 0). + 1. Repeat, while _placeholderEnd_ < _placeholderStart_, + 1. Let _literal_ be the substring of _pattern_ from _placeholderEnd_ + 1 to _placeholderStart_. + 1. If _literal_ is not the empty String, then 1. Append the Record { [[Type]]: *"literal"*, [[Value]]: _literal_ } to _result_. - 1. Let _p_ be the substring of _pattern_ from position _beginIndex_, exclusive, to position _endIndex_, exclusive. - 1. Append the Record { [[Type]]: _p_, [[Value]]: *undefined* } to _result_. - 1. Set _nextIndex_ to _endIndex_ + 1. - 1. Set _beginIndex_ to StringIndexOf(_pattern_, *"{"*, _nextIndex_). - 1. If _nextIndex_ is less than _length_, then - 1. Let _literal_ be the substring of _pattern_ from position _nextIndex_, inclusive, to position _length_, exclusive. - 1. Append the Record { [[Type]]: *"literal"*, [[Value]]: _literal_ } to _result_. + 1. Set _placeholderEnd_ to StringIndexOf(_pattern_, *"}"*, _placeholderStart_). + 1. Assert: _placeholderStart_ < _placeholderEnd_. + 1. Let _placeholderName_ be the substring of _pattern_ from _placeholderStart_ + 1 to _placeholderEnd_. + 1. Append the Record { [[Type]]: _placeholderName_, [[Value]]: *undefined* } to _result_. + 1. Set _placeholderStart_ to StringIndexOf(_pattern_, *"{"*, _placeholderEnd_). + 1. Let _tail_ be the substring of _pattern_ from _placeholderEnd_ + 1. + 1. If _tail_ is not the empty String, then + 1. Append the Record { [[Type]]: *"literal"*, [[Value]]: _tail_ } to _result_. 1. Return _result_.