@@ -2100,6 +2100,50 @@ Parser Entry Points</h3>
21002100 All of the algorithms defined in this spec may be called with either a list of tokens or of component values.
21012101 Either way produces an identical result.
21022102
2103+ <h4 id="parse-grammar">
2104+ Parse something according to a CSS grammar</h4>
2105+
2106+ It is often desirable to parse a string or token list
2107+ to see if it matches some CSS grammar,
2108+ and if it does,
2109+ to destructure it according to the grammar.
2110+ This section provides a generic hook for this kind of operation.
2111+ It should be invoked like "parse <var> foo</var> as a CSS <<color>> ", or similar.
2112+
2113+ Note: As a reminder, this algorithm, along with all the others in this section,
2114+ can be called with a string,
2115+ a stream of CSS tokens,
2116+ or a stream of CSS component values,
2117+ whichever is most convenient.
2118+
2119+ This algorithm must be called with <b> some input to be parsed</b> ,
2120+ and <b> some CSS grammar specification or term</b> .
2121+
2122+ This algorithm returns either failure,
2123+ if the input does not match the provided grammar,
2124+ or the result of parsing the input according to the grammar,
2125+ which is an unspecified structure corresponding to the provided grammar specification.
2126+ The return value must only be interacted with by specification prose,
2127+ where the representation ambiguity is not problematic
2128+ if it is meant to be exposed outside of spec language,
2129+ the spec using the result must explicitly translate it into a well-specified representation,
2130+ such as, for example, by invoking a CSS serialization algorithm
2131+ (like "serialize as a CSS <<string>> value").
2132+
2133+ To <dfn export>parse something according to a CSS grammar</dfn> :
2134+
2135+ <ol>
2136+ <li>
2137+ <a>Parse a list of component values</a> from the input,
2138+ and let <var> result</var> be the return value.
2139+
2140+ <li>
2141+ Attempt to match <var> result</var> against the provided grammar.
2142+ If this is successful,
2143+ return the matched result;
2144+ otherwise, return failure.
2145+ </ol>
2146+
21032147
21042148<h4 id="parse-a-stylesheet">
21052149Parse a stylesheet</h4>
0 commit comments