Skip to content

Commit f038208

Browse files
committed
Grammar modified to allow mixed properties and specific at-rules in page (previous version was exclusive)
1 parent fe0871e commit f038208

1 file changed

Lines changed: 49 additions & 25 deletions

File tree

org/w3c/css/parser/analyzer/CssParser.jj

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,30 +1233,15 @@ void page() :
12331233
}
12341234
{
12351235
try {
1236-
<PAGE_SYM> ( <S> )*
1236+
<PAGE_SYM> { if (!isCss1) newAtRule(newRule);
1237+
} ( <S> )*
12371238
( page_selector_list(newRule) )?
1238-
// FIXME <CSS3> ?
1239-
// ( n=<IDENT> { newRule.setIdent(convertIdent(n.image)); }
1240-
// ( <S> )* )?
1241-
// </CSS3>
1242-
// ( pseudo_page(newRule) )?
1243-
<LBRACE> ( <S> )* ( v=pageContent()
1244-
{
1245-
collectv = v;
1246-
}
1247-
) <RBRACE> ( <S> )*
1239+
<LBRACE> ( <S> )* ( v=pageContent() ) <RBRACE> ( <S> )*
12481240
{
12491241
if (!isCss1) {
1250-
newAtRule(getAtRule());
1251-
addProperty(collectv);
12521242
endOfRule();
12531243
endOfAtRule();
12541244
}
1255-
if (v == null) {
1256-
ac.getFrame().addWarning("no-declaration");
1257-
} else {
1258-
handleRule(s, collectv);
1259-
}
12601245
}
12611246
} catch (InvalidParamException ie) {
12621247
if (!isCss1) {
@@ -1279,33 +1264,72 @@ void page() :
12791264
ArrayList<CssProperty> pageContent() :
12801265
{ CssProperty prop;
12811266
ArrayList<CssProperty> v = new ArrayList<CssProperty>();
1267+
ArrayList<CssProperty> allv = new ArrayList<CssProperty>();
1268+
CssSelectors s = new CssSelectors(ac);
1269+
boolean gotContent = false;
12821270
}
12831271
{
1284-
// <CSS3> ?? FIXME
1285-
v=prefAtRule() { return v;}
1286-
// </CSS3>
1287-
|
1288-
v=declarations() { return v;} /* FIXME moved here as it can match empty string */
1272+
v=declarations() {
1273+
if ( v != null ) {
1274+
gotContent = true;
1275+
allv.addAll(v);
1276+
}
1277+
}
1278+
( prefAtRule() { gotContent = true; }
1279+
v=declarations() { if ( v != null ) {
1280+
allv.addAll(v);
1281+
}
1282+
}
1283+
)* {
1284+
if ( allv == null ) {
1285+
if (!gotContent) ac.getFrame().addWarning("no-declaration");
1286+
} else {
1287+
addProperty(allv);
1288+
handleRule(s, allv);
1289+
}
1290+
return allv;
1291+
}
12891292
}
12901293

12911294
ArrayList<CssProperty> prefAtRule() :
12921295
{ Token n;
12931296
ArrayList<CssProperty> v;
1297+
AtRulePage newRule = AtRulePage.getInstance(ac.getCssVersion());
1298+
AtRule old = getAtRule();
1299+
CssSelectors s = new CssSelectors(ac);
1300+
12941301
}
12951302
{
1303+
// This only happen in CSS3 and beyond.
12961304
try {
12971305
( n=<PAGE_TOP_LEFT_CORNER> | n=<PAGE_TOP_LEFT> | n=<PAGE_TOP_CENTER>
12981306
| n=<PAGE_TOP_RIGHT> | n=<PAGE_TOP_RIGHT_CORNER> | n=<PAGE_BOTTOM_LEFT_CORNER>
12991307
| n=<PAGE_BOTTOM_LEFT> | n=<PAGE_BOTTOM_CENTER> | n=<PAGE_BOTTOM_RIGHT>
13001308
| n=<PAGE_BOTTOM_RIGHT_CORNER> | n=<PAGE_LEFT_TOP> | n=<PAGE_LEFT_MIDDLE>
13011309
| n=<PAGE_LEFT_BOTTOM> | n=<PAGE_RIGHT_TOP> | n=<PAGE_RIGHT_MIDDLE>
1302-
| n=<PAGE_RIGHT_BOTTOM> ) ( <S> )*
1303-
<LBRACE> ( <S> )* v=declarations() <RBRACE> ( <S> )*
1310+
| n=<PAGE_RIGHT_BOTTOM> ) { ((org.w3c.css.atrules.css3.AtRulePage) newRule).setKeyword(convertIdent(n.image).substring(1));
1311+
setAtRule(newRule);
1312+
s.setAtRule(getAtRule());
1313+
newAtRule(getAtRule());
1314+
1315+
} ( <S> )*
1316+
<LBRACE> ( <S> )* v=declarations() <RBRACE> {
1317+
if ( v == null ) {
1318+
ac.getFrame().addWarning("no-declaration");
1319+
} else {
1320+
addProperty(v);
1321+
}
1322+
endOfRule();
1323+
endOfAtRule();
1324+
} ( <S> )*
13041325
{
1326+
// FIXME
13051327
return v;
13061328
}
13071329
} catch (ParseException e) {
13081330
addError(e, skipStatement());
1331+
} finally {
1332+
setAtRule(old);
13091333
}
13101334
}
13111335

0 commit comments

Comments
 (0)