22.12.2013 Views

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Contents<br />

Appendix D. The grammar of <strong>CSS2</strong><br />

D.1 Grammar . . . . . . . . . . . . . . 309 .<br />

D.2 Lexical scanner . . . . . . . . . . . . . 311 .<br />

D.3 Comparison of tokenization in <strong>CSS2</strong> and CSS1 . . . . . 312 .<br />

This appendix is normative.<br />

The grammar below defines the syntax of <strong>CSS2</strong>. It is in some sense, however,<br />

a superset of <strong>CSS2</strong> as this specification imposes additional semantic constraints<br />

not expressed in this grammar. A conforming UA must also adhere to the<br />

forward-compatible parsing rules [p. 35] , the property and value notation [p. 14] ,<br />

and the unit notation. In addition, the document language may impose restrictions,<br />

e.g. HTML imposes restrictions on the possible values of the "class"<br />

attribute.<br />

D.1 Grammar<br />

The grammar below is LL(1) (but note that most UA’s should not use it directly,<br />

since it doesn’t express the parsing conventions [p. 42] , only the <strong>CSS2</strong> syntax).<br />

The format of the productions is optimized for human consumption and some<br />

shorthand notation beyond Yacc (see [YACC]) is used:<br />

*: 0 or more<br />

+: 1 or more<br />

?: 0 or 1<br />

|: separates alternatives<br />

[ ]: grouping<br />

The productions are:<br />

stylesheet<br />

: [ CHARSET_SYM S* STRING S* ’;’ ]?<br />

[S|CDO|CDC]* [ import [S|CDO|CDC]* ]*<br />

[ [ ruleset | <strong>media</strong> | page | font_face ] [S|CDO|CDC]* ]*<br />

;<br />

import<br />

: IMPORT_SYM S*<br />

[STRING|URI] S* [ medium [ ’,’ S* medium]* ]? ’;’ S*<br />

;<br />

<strong>media</strong><br />

: MEDIA_SYM S* medium [ ’,’ S* medium ]* ’{’ S* ruleset* ’}’ S*<br />

;<br />

medium<br />

: IDENT S*<br />

;<br />

page<br />

: PAGE_SYM S* IDENT? pseudo_page? S*<br />

’{’ S* declaration [ ’;’ S* declaration ]* ’}’ S*<br />

;<br />

309

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!