Skip to content

Commit c11153c

Browse files
committed
[css2] Issues 129 and 139 from http://wiki.csswg.org/spec/css2.1
--HG-- extra : convert_revision : svn%3A73dc7c4b-06e6-40f3-b4f7-9ed1dbc14bfc/trunk%403030
1 parent db86f9e commit c11153c

1 file changed

Lines changed: 44 additions & 6 deletions

File tree

css2/grammar.src

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
22
<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 $ -->
44
<HEAD>
55
<TITLE>Grammar of CSS&nbsp;2.1</TITLE>
66
</HEAD>
@@ -153,15 +153,21 @@ nmstart [_a-z]|{nonascii}|{escape}
153153
nmchar [_a-z0-9-]|{nonascii}|{escape}
154154
string1 \"([^\n\r\f\\"]|\\{nl}|{escape})*\"
155155
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}
159163
comment \/\*[^*]*\*+([^/*][^*]*\*+)*\/
160164
ident -?{nmstart}{nmchar}*
161165
name {nmchar}+
162166
num [0-9]+|[0-9]*"."[0-9]+
163167
string {string1}|{string2}
164-
invalid {invalid1}|{invalid2}
168+
badstring {badstring1}|{badstring2}
169+
badcomment {badcomment1}|{badcomment2}
170+
baduri {baduri1}|{baduri2}|{baduri3}
165171
url ([!#$%&amp;*-~]|{nonascii}|{escape})*
166172
s [ \t\r\n\f]+
167173
w {s}?
@@ -192,14 +198,15 @@ Z z|\\0{0,4}(5a|7a)(\r\n|[ \t\r\n\f])?|\\z
192198
{s} {return S;}
193199

194200
\/\*[^*]*\*+([^/*][^*]*\*+)*\/ /* ignore comments */
201+
{badcomment} /* unclosed comment at EOF */
195202

196203
"&lt;!--" {return CDO;}
197204
"-->" {return CDC;}
198205
"~=" {return INCLUDES;}
199206
"|=" {return DASHMATCH;}
200207

201208
{string} {return STRING;}
202-
{invalid} {return INVALID; /* unclosed string */}
209+
{badstring} {return BAD_STRING);}
203210

204211
{ident} {return IDENT;}
205212

@@ -234,6 +241,7 @@ Z z|\\0{0,4}(5a|7a)(\r\n|[ \t\r\n\f])?|\\z
234241

235242
{U}{R}{L}"("{w}{string}{w}")" {return URI;}
236243
{U}{R}{L}"("{w}{url}{w}")" {return URI;}
244+
{baduri} {return BAD_URI);}
237245

238246
{ident}"(" {return FUNCTION;}
239247

@@ -285,6 +293,36 @@ make ".55ft" a valid class, CSS2 requires the first digit to be
285293
escaped (".\35 5ft")
286294
</ul>
287295

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&nbsp;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>
288326

289327
</body>
290328
</html>

0 commit comments

Comments
 (0)