11<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
22<html lang="en">
3- <!-- $Id: grammar.src,v 2.30 2003-07-01 15:42:14 bbos Exp $ -->
3+ <!-- $Id: grammar.src,v 2.31 2003-07-14 15:27:12 bbos Exp $ -->
44<HEAD>
55<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
66<TITLE>Appendix: grammar of CSS 2.1</TITLE>
@@ -28,7 +28,7 @@ find anything in the spec that corresponded. -->
2828title="LL(1)">LL(1)</span> (but note that most UA's should not use it
2929directly, since it doesn't express the <a
3030href="syndata.html#parsing-errors">parsing conventions</a>, only the
31- CSS 2.1 syntax). The format of the productions is optimized for human
31+ CSS 2.1 syntax). The format of the productions is optimized for human
3232consumption and some shorthand notation beyond Yacc (see [[YACC]]) is
3333used:</P>
3434
@@ -50,42 +50,45 @@ stylesheet
5050 ;
5151import
5252 : IMPORT_SYM S*
53- [STRING|URI] S* [ medium [ ',' S* medium]* ]? ';' S*
53+ [STRING|URI] S* [ medium [ COMMA S* medium]* ]? ';' S*
5454 ;
5555media
56- : MEDIA_SYM S* medium [ ',' S* medium ]* '{' S* ruleset* '}' S*
56+ : MEDIA_SYM S* medium [ COMMA S* medium ]* LBRACE S* ruleset* '}' S*
5757 ;
5858medium
5959 : IDENT S*
6060 ;
6161page
6262 : PAGE_SYM S* pseudo_page? S*
63- '{' S* declaration [ ';' S* declaration ]* '}' S*
63+ LBRACE S* declaration [ ';' S* declaration ]* '}' S*
6464 ;
6565pseudo_page
6666 : ':' IDENT
6767 ;
6868operator
69- : '/' S* | ',' S* | /* empty */
69+ : '/' S* | COMMA S* | /* empty */
7070 ;
7171combinator
72- : '+' S* | '>' S* | /* empty */
72+ : PLUS S*
73+ | GREATER S*
74+ | S+
7375 ;
7476unary_operator
75- : '-' | '+'
77+ : '-' | PLUS
7678 ;
7779property
7880 : IDENT S*
7981 ;
8082ruleset
81- : selector [ ',' S* selector ]*
82- '{' S* declaration [ ';' S* declaration ]* '}' S*
83+ : selector [ COMMA S* selector ]*
84+ LBRACE S* declaration [ ';' S* declaration ]* '}' S*
8385 ;
8486<span class="index-inst" title="selector">selector</span>
8587 : simple_selector [ combinator simple_selector ]*
8688 ;
8789simple_selector
88- : element_name? [ HASH | class | attrib | pseudo ]* S*
90+ : element_name [ HASH | class | attrib | pseudo ]*
91+ | [ HASH | class | attrib | pseudo ]+
8992 ;
9093class
9194 : '.' IDENT
@@ -160,21 +163,27 @@ name {nmchar}+
160163num [0-9]+|[0-9]*"."[0-9]+
161164string {string1}|{string2}
162165url ([!#$%&*-~]|{nonascii}|{escape})*
163- w [ \t\r\n\f]*
166+ s [ \t\r\n\f]
167+ w {s}*
164168nl \n|\r\n|\r|\f
165169range \?{1,6}|{h}(\?{0,5}|{h}(\?{0,4}|{h}(\?{0,3}|{h}(\?{0,2}|{h}(\??|{h})))))
166170
167171%%
168172
169- [ \t\r\n\f]+ {return S;}
173+ {s}+ {return S;}
170174
171175\/\*[^*]*\*+([^/*][^*]*\*+)*\/ /* ignore comments */
172176
173- "<!--" {return CDO;}
177+ "<!--" {return CDO;}
174178"-->" {return CDC;}
175179"~=" {return INCLUDES;}
176180"|=" {return DASHMATCH;}
177181
182+ {w}"{" {return LBRACE;}
183+ {w}"+" {return PLUS;}
184+ {w}">" {return GREATER;}
185+ {w}"," {return COMMA;}
186+
178187{string} {return STRING;}
179188
180189{ident} {return IDENT;}
0 commit comments