11<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
22<html lang="en">
3- <!-- $Id: grammar.src,v 1.23 1998-01-27 23:00:56 bbos Exp $ -->
3+ <!-- $Id: grammar.src,v 1.24 1998-01-28 10:01:55 bbos Exp $ -->
44<HEAD>
55<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
66<TITLE>Appendix D: The grammar of CSS2</TITLE>
@@ -24,11 +24,15 @@ imposes restrictions on the possible values of the "class" attribute.
2424<!-- IJ: There used to be a link to "unit notation", but I couldn't
2525find anything in the spec that corresponded. -->
2626
27- <P> The grammar below is LL(1) (but note that most UA's should not use
28- it directly, since it doesn't express the parsing conventions, only
29- the CSS2 syntax). The format of the productions is optimized for
30- human consumption and some shorthand notation beyond
31- <a rel="biblioentry" href="./refs.html#ref-YACC" class="normref">[YACC]</a> is used:</P>
27+ <h2>Grammar</h2>
28+
29+ <P> The grammar below is <span class="index-inst"
30+ title="LL(1)">LL(1)</span> (but note that most UA's should not use it
31+ directly, since it doesn't express the <a
32+ href="syndata.html#parsing-errors">parsing conventions</a>, only the
33+ CSS2 syntax). The format of the productions is optimized for human
34+ consumption and some shorthand notation beyond <a rel="biblioentry"
35+ href="./refs.html#ref-YACC" class="normref">[YACC]</a> is used:</P>
3236
3337<ul>
3438<li><strong>*</strong>: 0 or more
@@ -47,7 +51,7 @@ stylesheet
4751 ;
4852import
4953 : IMPORT_SYM S*
50- [STRING|URL ] S* [ medium [ ',' S* medium]* ]? ';' S*
54+ [STRING|URI ] S* [ medium [ ',' S* medium]* ]? ';' S*
5155 ;
5256media
5357 : MEDIA_SYM S* medium [ ',' S* medium ]* '{' S* ruleset* '}' S*
@@ -82,17 +86,20 @@ ruleset
8286 : selector [ ',' S* selector ]*
8387 '{' S* declaration [ ';' S* declaration ]* '}' S*
8488 ;
85- selector
89+ <span class="index-inst" title=" selector">selector</span>
8690 : simple_selector [ combinator simple_selector ]*
8791 ;
8892/*
8993 * simple selector cannot start with attrib selector
9094 */
9195simple_selector
92- : element_name [ HASH | CLASS | attrib | pseudo ]* S*
93- | HASH [ CLASS | attrib | pseudo ]* S*
94- | pseudo [ HASH | CLASS | attrib | pseudo ]* S*
95- | CLASS [ HASH | CLASS | attrib | pseudo ]* S*
96+ : element_name [ HASH | class | attrib | pseudo ]* S*
97+ | HASH [ class | attrib | pseudo ]* S*
98+ | pseudo [ HASH | class | attrib | pseudo ]* S*
99+ | class [ HASH | class | attrib | pseudo ]* S*
100+ ;
101+ class
102+ : '.' IDENT
96103 ;
97104element_name
98105 : IDENT | '*'
@@ -117,13 +124,13 @@ term
117124 : unary_operator?
118125 [ NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S* | ANGLE S* |
119126 TIME S* | FREQ S* | function ]
120- | STRING S* | IDENT S* | URL S* | RGB S* | UNICODERANGE S* | hexcolor
127+ | STRING S* | IDENT S* | URI S* | RGB S* | UNICODERANGE S* | hexcolor
121128 ;
122129function
123130 : FUNCTION S* expr ')' S*
124131 ;
125132/*
126- * There is a constraint on the color that it must
133+ * There is a constraint on the <span class="index-inst" title=" color">color</span> that it must
127134 * have either 3 or 6 hex-digits (i.e., [0-9a-fA-F])
128135 * after the "#"; e.g., "#000" is OK, but "#abcd" is not.
129136 */
@@ -132,11 +139,13 @@ hexcolor
132139 ;
133140</pre>
134141
135- <p> The following is the tokenizer, written in flex <a
136- rel="biblioentry" href="./refs.html#ref-FLEX" class="normref">[FLEX]</a>
137- notation. The
138- tokenizer is case-insensitive (flex command line
139- option -i).
142+ <h2>Lexical scanner</h2>
143+
144+ <p> The following is the <span class="index-def"
145+ title="tokenizer">tokenizer</span>, written in flex <a
146+ rel="biblioentry" href="./refs.html#ref-FLEX"
147+ class="normref">[FLEX]</a> notation. The tokenizer is case-insensitive
148+ (flex command line option -i).
140149
141150<p>The two occurrences of "\377" represent the highest character
142151number that current versions of Flex can deal with (decimal 255). They
@@ -178,8 +187,6 @@ range {h}(\?{0,5}|{h}(\?{0,4}|{h}(\?{0,3}|{h}(\?{0,2}|{h}(\??|{h})))))
178187
179188{ident} {return IDENT;}
180189
181- "."{ident} {return CLASS;}
182-
183190"#"{name} {return HASH;}
184191
185192"@import" {return IMPORT_SYM;}
@@ -209,8 +216,8 @@ range {h}(\?{0,5}|{h}(\?{0,4}|{h}(\?{0,3}|{h}(\?{0,2}|{h}(\??|{h})))))
209216{num}% {return PERCENTAGE;}
210217{num} {return NUMBER;}
211218
212- "url("{w}{string}{w}")" {return URL ;}
213- "url("{w}{url}{w}")" {return URL ;}
219+ "url("{w}{string}{w}")" {return URI ;}
220+ "url("{w}{url}{w}")" {return URI ;}
214221{ident}"(" {return FUNCTION;}
215222
216223U\+{range} {return UNICODERANGE;}
0 commit comments