|
1 | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> |
2 | 2 | <html lang="en"> |
3 | | -<!-- $Id: grammar.src,v 2.62 2009-09-03 14:18:13 bbos Exp $ --> |
| 3 | +<!-- $Id: grammar.src,v 2.63 2010-09-29 15:50:10 bbos Exp $ --> |
4 | 4 | <HEAD> |
5 | 5 | <TITLE>Grammar of CSS 2.1</TITLE> |
6 | 6 | </HEAD> |
@@ -153,15 +153,21 @@ nmstart [_a-z]|{nonascii}|{escape} |
153 | 153 | nmchar [_a-z0-9-]|{nonascii}|{escape} |
154 | 154 | string1 \"([^\n\r\f\\"]|\\{nl}|{escape})*\" |
155 | 155 | string2 \'([^\n\r\f\\']|\\{nl}|{escape})*\' |
156 | | -invalid1 \"([^\n\r\f\\"]|\\{nl}|{escape})* |
157 | | -invalid2 \'([^\n\r\f\\']|\\{nl}|{escape})* |
158 | | - |
| 156 | +badstring1 \"([^\n\r\f\\"]|\\{nl}|{escape})*\\? |
| 157 | +badstring2 \'([^\n\r\f\\']|\\{nl}|{escape})*\\? |
| 158 | +badcomment1 \/\*[^*]*\*+([^/*][^*]*\*+)* |
| 159 | +badcomment2 \/\*[^*]*(\*+[^/*][^*]*)* |
| 160 | +baduri1 url\({w}([!#$%&*-\[\]-~]|{nonascii}|{escape})*{w} |
| 161 | +baduri2 url\({w}{string}{w} |
| 162 | +baduri3 url\({w}{badstring} |
159 | 163 | comment \/\*[^*]*\*+([^/*][^*]*\*+)*\/ |
160 | 164 | ident -?{nmstart}{nmchar}* |
161 | 165 | name {nmchar}+ |
162 | 166 | num [0-9]+|[0-9]*"."[0-9]+ |
163 | 167 | string {string1}|{string2} |
164 | | -invalid {invalid1}|{invalid2} |
| 168 | +badstring {badstring1}|{badstring2} |
| 169 | +badcomment {badcomment1}|{badcomment2} |
| 170 | +baduri {baduri1}|{baduri2}|{baduri3} |
165 | 171 | url ([!#$%&*-~]|{nonascii}|{escape})* |
166 | 172 | s [ \t\r\n\f]+ |
167 | 173 | w {s}? |
@@ -192,14 +198,15 @@ Z z|\\0{0,4}(5a|7a)(\r\n|[ \t\r\n\f])?|\\z |
192 | 198 | {s} {return S;} |
193 | 199 |
|
194 | 200 | \/\*[^*]*\*+([^/*][^*]*\*+)*\/ /* ignore comments */ |
| 201 | +{badcomment} /* unclosed comment at EOF */ |
195 | 202 |
|
196 | 203 | "<!--" {return CDO;} |
197 | 204 | "-->" {return CDC;} |
198 | 205 | "~=" {return INCLUDES;} |
199 | 206 | "|=" {return DASHMATCH;} |
200 | 207 |
|
201 | 208 | {string} {return STRING;} |
202 | | -{invalid} {return INVALID; /* unclosed string */} |
| 209 | +{badstring} {return BAD_STRING);} |
203 | 210 |
|
204 | 211 | {ident} {return IDENT;} |
205 | 212 |
|
@@ -234,6 +241,7 @@ Z z|\\0{0,4}(5a|7a)(\r\n|[ \t\r\n\f])?|\\z |
234 | 241 |
|
235 | 242 | {U}{R}{L}"("{w}{string}{w}")" {return URI;} |
236 | 243 | {U}{R}{L}"("{w}{url}{w}")" {return URI;} |
| 244 | +{baduri} {return BAD_URI);} |
237 | 245 |
|
238 | 246 | {ident}"(" {return FUNCTION;} |
239 | 247 |
|
@@ -285,6 +293,36 @@ make ".55ft" a valid class, CSS2 requires the first digit to be |
285 | 293 | escaped (".\35 5ft") |
286 | 294 | </ul> |
287 | 295 |
|
| 296 | +<h2>Implementation note</h2> |
| 297 | + |
| 298 | +<p>This section is non-normative. |
| 299 | + |
| 300 | +<p>The lexical scanner for the CSS core syntax in <a |
| 301 | +href="syndata.html#tokenization">section 4.1.1</a> can be |
| 302 | +implemented as a scanner without back-up. In Lex notation, that |
| 303 | +requires the addition of the following patterns (which do not change |
| 304 | +the returned tokens, only the efficiency of the scanner): |
| 305 | + |
| 306 | +<pre> |
| 307 | +{ident}/\\ return IDENT; |
| 308 | +#{name}/\\ return HASH; |
| 309 | +@{ident}/\\ return ATKEYWORD; |
| 310 | +#/\\ return DELIM; |
| 311 | +@/\\ return DELIM; |
| 312 | +@/- return DELIM; |
| 313 | +@/-\\ return DELIM; |
| 314 | +-/\\ return DELIM; |
| 315 | +-/- return DELIM; |
| 316 | +\</! return DELIM; |
| 317 | +\</!- return DELIM; |
| 318 | +{num}{ident}/\\ return DIMENSION; |
| 319 | +{num}/\\ return NUMBER; |
| 320 | +{num}/- return NUMBER; |
| 321 | +{num}/-\\ return NUMBER; |
| 322 | +[0-9]+/\. return NUMBER; |
| 323 | +u/\+ return IDENT; |
| 324 | +u\+[0-9a-f?]{1,6}/- return UNICODE_RANGE; |
| 325 | +</pre> |
288 | 326 |
|
289 | 327 | </body> |
290 | 328 | </html> |
|
0 commit comments