@@ -1441,20 +1441,20 @@ void page_selector_list(AtRulePage pageRule) :
1441
1441
}
1442
1442
{
1443
1443
(
1444
- ( ( n=ident() { ns = convertIdent(n.image); } ) ( ":" p=ident() { if (ps == null) { ps = new ArrayList(); } ps.add(":"+convertIdent(p.image)); } )* ) {
1444
+ ( ( n=ident() { ns = convertIdent(n.image); } ) ( ":" p=ident() { if (ps == null) { ps = new ArrayList<String> (); } ps.add(":"+convertIdent(p.image)); } )* ) {
1445
1445
pageRule.addSelector(ns, ps, ac);
1446
1446
ns = null; ps = null;
1447
1447
}
1448
- | ( ":" p=ident() { if (ps == null) { ps = new ArrayList(); } ps.add(":"+convertIdent(p.image)); } )+ {
1448
+ | ( ":" p=ident() { if (ps == null) { ps = new ArrayList<String> (); } ps.add(":"+convertIdent(p.image)); } )+ {
1449
1449
pageRule.addSelector(null, ps, ac);
1450
1450
ps = null;
1451
1451
} ) ( <S> ) *
1452
1452
( <COMMA> ( <S> )* (
1453
- ( ( n=ident() { ns = convertIdent(n.image); } ) ( ":" p=ident() { if (ps == null) { ps = new ArrayList(); } ps.add(":"+convertIdent(p.image)); } )* ) {
1453
+ ( ( n=ident() { ns = convertIdent(n.image); } ) ( ":" p=ident() { if (ps == null) { ps = new ArrayList<String> (); } ps.add(":"+convertIdent(p.image)); } )* ) {
1454
1454
pageRule.addSelector(ns, ps, ac);
1455
1455
ns = null; ps = null;
1456
1456
}
1457
- | ( ":" p=ident() { if (ps == null) { ps = new ArrayList(); } ps.add(":"+convertIdent(p.image)); } )+ {
1457
+ | ( ":" p=ident() { if (ps == null) { ps = new ArrayList<String> (); } ps.add(":"+convertIdent(p.image)); } )+ {
1458
1458
pageRule.addSelector(null, ps, ac);
1459
1459
ps = null;
1460
1460
} ) ( <S> )* )*
@@ -2374,7 +2374,7 @@ void element_name(CssSelectors s) :
2374
2374
.addError(new CssError(getSourceFile(), getBeginLine(),
2375
2375
getBeginColumn(), getEndLine(), getEndColumn(),
2376
2376
new InvalidParamException("notversion",
2377
- "namespace" , ac.getCssVersionString(), ac)));
2377
+ sb.toString() , ac.getCssVersionString(), ac)));
2378
2378
removeThisRule();
2379
2379
} else if (n!=null) {
2380
2380
prefix = convertIdent(n.image);
@@ -2416,10 +2416,12 @@ void attrib(CssSelectors s) :
2416
2416
{
2417
2417
Token att = null;
2418
2418
Token val = null;
2419
+ Token mod = null;
2420
+ Token pre = null;
2419
2421
int selectorType = CssSelectors.ATTRIBUTE_ANY;
2420
2422
}
2421
2423
{
2422
- <LBRACKET> ( <S> )* att=ident() ( <S> )*
2424
+ <LBRACKET> ( <S> )* ( LOOKAHEAD(2) (pre=ident() | pre=<ANY>)? "|" )? att=ident() ( <S> )*
2423
2425
( (<EQ> { selectorType = CssSelectors.ATTRIBUTE_EXACT; }
2424
2426
| <INCLUDES> { selectorType = CssSelectors.ATTRIBUTE_ONE_OF; }
2425
2427
| <DASHMATCH> { selectorType = CssSelectors.ATTRIBUTE_BEGIN; }
@@ -2432,76 +2434,104 @@ void attrib(CssSelectors s) :
2432
2434
| val=<STRING>
2433
2435
{ val.image = convertStringIndex(val.image, 1, val.image.length() -1, false);}
2434
2436
)
2435
- ( <S> )* )?
2436
- <RBRACKET>
2437
+ ( LOOKAHEAD(2) ( <S> )+ mod=ident() )? ( <S> )* )?
2438
+ <RBRACKET>
2437
2439
{
2438
- if (ac.getCssVersion() == CssVersion.CSS1) {
2439
- StringBuilder reason;
2440
- CssParseException cp;
2441
- ParseException p;
2442
- reason = new StringBuilder(" [");
2443
- if (att != null) {
2444
- reason.append(convertIdent(att.image));
2445
- }
2446
- if (val != null ) {
2447
- reason.append('=').append(val.image);
2448
- }
2449
- reason.append(']');
2450
- p = new ParseException(ac.getMsg().getString("parser.attrcss1")+
2451
- reason.toString());
2452
- cp = new CssParseException(p);
2453
- ac.getFrame()
2454
- .addError(new CssError(getSourceFile(), getBeginLine(),
2455
- getBeginColumn(), getEndLine(), getEndColumn(), cp));
2456
- removeThisRule();
2457
- }
2458
- if (selectorType == CssSelectors.ATTRIBUTE_ANY) {
2459
- try {
2460
- s.addAttribute(new AttributeAny(att.image.toLowerCase()));
2461
- // s.addAttribute(att.image.toLowerCase(), null, selectorType);
2462
- } catch (InvalidParamException e) {
2463
- removeThisRule();
2464
- ac.getFrame()
2465
- .addError(new CssError(getSourceFile(), getBeginLine(),
2466
- getBeginColumn(), getEndLine(), getEndColumn(), e));
2467
- }
2468
- } else {
2469
- AttributeSelector attribute;
2470
- switch(selectorType) {
2471
- case CssSelectors.ATTRIBUTE_BEGIN:
2472
- attribute = new AttributeBegin(att.image.toLowerCase(), val.image);
2473
- break;
2474
- case CssSelectors.ATTRIBUTE_EXACT:
2475
- attribute = new AttributeExact(att.image.toLowerCase(), val.image);
2476
- break;
2477
- case CssSelectors.ATTRIBUTE_ONE_OF:
2478
- attribute = new AttributeOneOf(ac, att.image.toLowerCase(), val.image);
2479
- break;
2480
- case CssSelectors.ATTRIBUTE_START:
2481
- attribute = new AttributeStart(att.image.toLowerCase(), val.image);
2482
- break;
2483
- case CssSelectors.ATTRIBUTE_SUBSTR:
2484
- attribute = new AttributeSubstr(att.image.toLowerCase(), val.image);
2485
- break;
2486
- case CssSelectors.ATTRIBUTE_SUFFIX:
2487
- attribute = new AttributeSuffix(att.image.toLowerCase(), val.image);
2488
- break;
2489
- default:
2490
- attribute = new AttributeExact(att.image.toLowerCase(), val.image);
2491
- break;
2492
- }
2493
- try {
2494
- s.addAttribute(attribute);
2440
+ if (ac.getCssVersion() == CssVersion.CSS1) {
2441
+ StringBuilder reason;
2442
+ CssParseException cp;
2443
+ ParseException p;
2444
+ reason = new StringBuilder(" [");
2445
+ if (att != null) {
2446
+ reason.append(convertIdent(att.image));
2447
+ }
2448
+ if (val != null ) {
2449
+ reason.append('=').append(val.image);
2450
+ }
2451
+ reason.append(']');
2452
+ p = new ParseException(ac.getMsg().getString("parser.attrcss1")+
2453
+ reason.toString());
2454
+ cp = new CssParseException(p);
2455
+ ac.getFrame().addError(new CssError(getSourceFile(), getBeginLine(),
2456
+ getBeginColumn(), getEndLine(), getEndColumn(), cp));
2457
+ removeThisRule();
2458
+ }
2459
+ if ((mod != null) && ac.getCssVersion().compareTo(CssVersion.CSS3) < 0) {
2460
+ String reason = mod.image;
2461
+ ac.getFrame().addError(new CssError(getSourceFile(), getBeginLine(),
2462
+ getBeginColumn(), getEndLine(), getEndColumn(),
2463
+ new InvalidParamException("notversion",
2464
+ reason, ac.getCssVersionString(), ac)));
2465
+
2466
+ removeThisRule();
2467
+ }
2468
+ if ((pre != null) && ac.getCssVersion().compareTo(CssVersion.CSS3) < 0) {
2469
+ StringBuilder sb = new StringBuilder("namespace \"").append(pre.image).append('"');
2470
+ ac.getFrame().addError(new CssError(getSourceFile(), getBeginLine(),
2471
+ getBeginColumn(), getEndLine(), getEndColumn(),
2472
+ new InvalidParamException("notversion",
2473
+ sb.toString(), ac.getCssVersionString(), ac)));
2474
+ removeThisRule();
2475
+ }
2476
+ if (selectorType == CssSelectors.ATTRIBUTE_ANY) {
2477
+ try {
2478
+ AttributeSelector as;
2479
+ as = new AttributeAny(att.image.toLowerCase());
2480
+ if (pre != null) {
2481
+ as.setPrefix(pre.image);
2482
+ }
2483
+ if (mod != null) {
2484
+ as.setModifier(mod.image, ac);
2485
+ }
2486
+ s.addAttribute(as);
2487
+ // s.addAttribute(att.image.toLowerCase(), null, selectorType);
2488
+ } catch (InvalidParamException e) {
2489
+ removeThisRule();
2490
+ ac.getFrame().addError(new CssError(getSourceFile(), getBeginLine(),
2491
+ getBeginColumn(), getEndLine(), getEndColumn(), e));
2492
+ }
2493
+ } else {
2494
+ AttributeSelector attribute;
2495
+ switch(selectorType) {
2496
+ case CssSelectors.ATTRIBUTE_BEGIN:
2497
+ attribute = new AttributeBegin(att.image.toLowerCase(), val.image);
2498
+ break;
2499
+ case CssSelectors.ATTRIBUTE_EXACT:
2500
+ attribute = new AttributeExact(att.image.toLowerCase(), val.image);
2501
+ break;
2502
+ case CssSelectors.ATTRIBUTE_ONE_OF:
2503
+ attribute = new AttributeOneOf(ac, att.image.toLowerCase(), val.image);
2504
+ break;
2505
+ case CssSelectors.ATTRIBUTE_START:
2506
+ attribute = new AttributeStart(att.image.toLowerCase(), val.image);
2507
+ break;
2508
+ case CssSelectors.ATTRIBUTE_SUBSTR:
2509
+ attribute = new AttributeSubstr(att.image.toLowerCase(), val.image);
2510
+ break;
2511
+ case CssSelectors.ATTRIBUTE_SUFFIX:
2512
+ attribute = new AttributeSuffix(att.image.toLowerCase(), val.image);
2513
+ break;
2514
+ default:
2515
+ attribute = new AttributeExact(att.image.toLowerCase(), val.image);
2516
+ break;
2517
+ }
2518
+ try {
2519
+ if (pre != null) {
2520
+ attribute.setPrefix(pre.image);
2521
+ }
2522
+ if (mod != null) {
2523
+ attribute.setModifier(mod.image, ac);
2524
+ }
2525
+ s.addAttribute(attribute);
2495
2526
// s.addAttribute(att.image.toLowerCase(), val.image,
2496
2527
// selectorType);
2497
- } catch (InvalidParamException e) {
2498
- removeThisRule();
2499
- ac.getFrame()
2500
- .addError(new CssError(getSourceFile(), getBeginLine(),
2501
- getBeginColumn(), getEndLine(), getEndColumn(), e));
2502
- }
2503
- }
2504
- }
2528
+ } catch (InvalidParamException e) {
2529
+ removeThisRule();
2530
+ ac.getFrame().addError(new CssError(getSourceFile(), getBeginLine(),
2531
+ getBeginColumn(), getEndLine(), getEndColumn(), e));
2532
+ }
2533
+ }
2534
+ }
2505
2535
}
2506
2536
2507
2537
void negation(CssSelectors s) :
0 commit comments