Skip to content

Commit

Permalink
Editorial: use Infra to define the ordered set parser
Browse files Browse the repository at this point in the history
Found via whatwg/infra#6.
  • Loading branch information
annevk committed Mar 19, 2017
1 parent c91a0d3 commit a149b84
Showing 1 changed file with 6 additions and 42 deletions.
48 changes: 6 additions & 42 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -224,57 +224,21 @@ of <a>preceding</a>

<h3 id="ordered-sets">Ordered sets</h3>

The <dfn export id=concept-ordered-set-parser>ordered set parser</dfn> takes a string
<p>The <dfn export id=concept-ordered-set-parser>ordered set parser</dfn> takes a string
<var>input</var> and then runs these steps:

<ol>
<li>Let <var>position</var> be a pointer into <var>input</var>,
initially pointing at the start of the string.
<li><p>Let <var>inputTokens</var> be the result of
<a lt="split on ASCII whitespace">splitting <var>input</var> on ASCII whitespace</a>.

<li>Let <var>tokens</var> be an ordered set of tokens, initially empty.
<li><p>Let <var>tokens</var> be a new <a>ordered set</a>.

<li><a>Skip ASCII whitespace</a>.

<li>While <var>position</var> is not past the end of
<var>input</var>:

<ol>
<li><a>Collect a code point sequence</a> of code points that are
not <a>ASCII whitespace</a>.

<li>If the collected string is not in <var>tokens</var>, append the
collected string to <var>tokens</var>.

<li><a>Skip ASCII whitespace</a>.
</ol>
<li><p><a for=list>For each</a> <var>token</var> in <var>inputTokens</var>, <a for=set>append</a>
<var>token</var> to <var>tokens</var>.

<li>Return <var>tokens</var>.
</ol>

To <dfn export>collect a code point sequence</dfn> of
<var>code points</var>, run these steps:

<ol>
<li>Let <var>input</var> and <var>position</var> be the same
variables as those of the same name in the algorithm that invoked these
steps.

<li>Let <var>result</var> be the empty string.

<li>While <var>position</var> does not point past the end of
<var>input</var> and the code point at <var>position</var> is
one of <var>code points</var>, append that code point to the end
of <var>result</var> and advance <var>position</var> to the
next code point in <var>input</var>.

<li>Return <var>result</var>.
</ol>

To <dfn export>skip ASCII whitespace</dfn> means to
<a>collect a code point sequence</a> of
<a>ASCII whitespace</a> and discard the
return value.

<p>The <dfn export id=concept-ordered-set-serializer>ordered set serializer</dfn> takes a
<var>set</var> and returns the concatenation of the strings in <var>set</var>, separated from each
other by U+0020, if <var>set</var> is non-empty, and the empty string otherwise.
Expand Down

0 comments on commit a149b84

Please sign in to comment.