Skip to content

Commit c845873

Browse files
committed
[css2] Changed the tokens for '{', '+', ',' and '>' to include initial
whitespace. This means that a space followed by a '+' in a selector is now seen as a single PLUS token, removing the ambiguity of spaces and keeping the grammar LL(1). --HG-- extra : convert_revision : svn%3A73dc7c4b-06e6-40f3-b4f7-9ed1dbc14bfc/trunk%402113
1 parent b68fc55 commit c845873

1 file changed

Lines changed: 23 additions & 14 deletions

File tree

css2/grammar.src

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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&nbsp;2.1</TITLE>
@@ -28,7 +28,7 @@ find anything in the spec that corresponded. -->
2828
title="LL(1)">LL(1)</span> (but note that most UA's should not use it
2929
directly, since it doesn't express the <a
3030
href="syndata.html#parsing-errors">parsing conventions</a>, only the
31-
CSS&nbsp;2.1 syntax). The format of the productions is optimized for human
31+
CSS&nbsp;2.1 syntax). The format of the productions is optimized for human
3232
consumption and some shorthand notation beyond Yacc (see [[YACC]]) is
3333
used:</P>
3434

@@ -50,42 +50,45 @@ stylesheet
5050
;
5151
import
5252
: IMPORT_SYM S*
53-
[STRING|URI] S* [ medium [ ',' S* medium]* ]? ';' S*
53+
[STRING|URI] S* [ medium [ COMMA S* medium]* ]? ';' S*
5454
;
5555
media
56-
: MEDIA_SYM S* medium [ ',' S* medium ]* '{' S* ruleset* '}' S*
56+
: MEDIA_SYM S* medium [ COMMA S* medium ]* LBRACE S* ruleset* '}' S*
5757
;
5858
medium
5959
: IDENT S*
6060
;
6161
page
6262
: PAGE_SYM S* pseudo_page? S*
63-
'{' S* declaration [ ';' S* declaration ]* '}' S*
63+
LBRACE S* declaration [ ';' S* declaration ]* '}' S*
6464
;
6565
pseudo_page
6666
: ':' IDENT
6767
;
6868
operator
69-
: '/' S* | ',' S* | /* empty */
69+
: '/' S* | COMMA S* | /* empty */
7070
;
7171
combinator
72-
: '+' S* | '>' S* | /* empty */
72+
: PLUS S*
73+
| GREATER S*
74+
| S+
7375
;
7476
unary_operator
75-
: '-' | '+'
77+
: '-' | PLUS
7678
;
7779
property
7880
: IDENT S*
7981
;
8082
ruleset
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
;
8789
simple_selector
88-
: element_name? [ HASH | class | attrib | pseudo ]* S*
90+
: element_name [ HASH | class | attrib | pseudo ]*
91+
| [ HASH | class | attrib | pseudo ]+
8992
;
9093
class
9194
: '.' IDENT
@@ -160,21 +163,27 @@ name {nmchar}+
160163
num [0-9]+|[0-9]*"."[0-9]+
161164
string {string1}|{string2}
162165
url ([!#$%&amp;*-~]|{nonascii}|{escape})*
163-
w [ \t\r\n\f]*
166+
s [ \t\r\n\f]
167+
w {s}*
164168
nl \n|\r\n|\r|\f
165169
range \?{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-
"&lt;!--" {return CDO;}
177+
"&lt;!--" {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

Comments
 (0)