@@ -149,7 +149,10 @@ stylesheet : [ CDO | CDC | S | statement ]*;
149149statement : ruleset | at-rule;
150150at-rule : ATKEYWORD S* any* [ block | ';' S* ];
151151block : '{' S* [ any | block | ATKEYWORD S* | ';' S* ]* '}' S*;
152- ruleset : selector? '{' S* declaration? [ ';' S* declaration? ]* '}' S*;
152+ ruleset : selector? '{' S* declaration-list '}' S*;
153+ declaration-list: declaration [ ';' S* declaration-list ]?
154+ | at-rule declaration-list
155+ | /* empty */;
153156selector : any+;
154157declaration : property S* ':' S* value;
155158property : IDENT;
@@ -475,8 +478,12 @@ a declaration block.
475478title="declaration block"><dfn>declaration block</dfn></span>
476479starts with a left curly
477480brace ({) and ends with the matching right curly brace (}). In between
478- there must be a list of zero or more semicolon-separated (;)
479- declarations.
481+ there must be a list of zero or more declarations and at-rules.
482+ Declarations must end with a semicolon (;) unless they are last in the
483+ list.
484+ </p>
485+ <p class=note>Note: CSS level 2 has no at-rules that may appear
486+ inside rule sets, but such at-rules may be defined in future levels.
480487</p>
481488<p>The <span class="index-def"
482489title="selector"><em>selector</em></span> (see also the section on <a
@@ -689,11 +696,20 @@ unexpected tokens encountered while parsing a declaration by reading
689696until the end of the declaration, while observing the rules for matching
690697pairs of (), [], {}, "", and '', and correctly handling escapes. For
691698example, a malformed declaration may be missing a property name, colon (:), or
692- property value. The following are all equivalent:
699+ property value.
700+
701+ <p>When the UA expects the start of a declaration or at-rule (i.e., an
702+ IDENT token or an ATKEYWORD token) but finds an unexpected token
703+ instead, that token is considered to be the first token of a malformed
704+ declaration. I.e., the rule for malformed declarations, rather than
705+ malformed statements is used to determine which tokens to ignore in
706+ that case.
693707
708+ <p>The following are all equivalent:
694709
695710<pre class="example"><code>
696711p { color:green }
712+ p { @foo { bar: baz } color:green } /* unknown at-rule */
697713p { color:green; color } /* malformed declaration missing ':', value */
698714p { color:red; color; color:green } /* same with expected recovery */
699715p { color:green; color: } /* malformed declaration missing value */
0 commit comments