Skip to content

Commit a9f5cef

Browse files
committed
% simplify
1 parent 6696446 commit a9f5cef

File tree

1 file changed

+17
-32
lines changed

1 file changed

+17
-32
lines changed

src/main/javacc/CSS3Parser.jj

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ ElementSelector elementName() :
11911191
{
11921192
t = <IDENT>
11931193
{
1194-
return new ElementSelector(unescape(t.image, false), createLocator(token));
1194+
return new ElementSelector(unescape(t.image, false), createLocator(t));
11951195
}
11961196
| <ASTERISK>
11971197
{
@@ -1302,6 +1302,7 @@ Object pseudo(Condition pred, boolean pseudoElementFound) :
13021302
Condition c = null;
13031303
Token t;
13041304
String function;
1305+
String arg;
13051306
Selector sel;
13061307
boolean doubleColon = false;
13071308
Locator locator;
@@ -1331,10 +1332,9 @@ Object pseudo(Condition pred, boolean pseudoElementFound) :
13311332
(
13321333
t = <FUNCTION_NOT> { function = unescape(t.image, false); }
13331334
( <S> )*
1334-
sel = negation_arg() {
1335-
String arg = sel.toString();
1336-
if ("".equals(arg)) { arg = "*"; }
1337-
}
1335+
arg = negation_arg() {
1336+
if ("".equals(arg)) { arg = "*"; }
1337+
}
13381338
( <S> )*
13391339
<RROUND>
13401340
{
@@ -1394,7 +1394,7 @@ Condition hash(Condition pred, boolean pseudoElementFound) :
13941394
t = <HASH>
13951395
{
13961396
if (pseudoElementFound) { throw pe; }
1397-
Condition c = new IdCondition(unescape(t.image.substring(1), false), createLocator(token));
1397+
Condition c = new IdCondition(unescape(t.image.substring(1), false), createLocator(t));
13981398
return (pred == null) ? c : new AndCondition(pred, c);
13991399
}
14001400
}
@@ -1445,7 +1445,7 @@ void declaration() :
14451445
// maybe there are strange characters at the end - create error and skip
14461446
( t = <UNKNOWN>
14471447
{
1448-
locator = createLocator(token);
1448+
locator = createLocator(t);
14491449
CSSParseException cpe = toCSSParseException("invalidDeclarationInvalidChar", new String[] {t.image}, locator);
14501450
getErrorHandler().error(cpe);
14511451
error_skipdecl();
@@ -1573,7 +1573,7 @@ LexicalUnit term(LexicalUnit prev) :
15731573
| t = "progid:" { value = LexicalUnitImpl.createIdent(prev, skipUnit().trim()); }
15741574
|
15751575
( t = <IDENT>
1576-
( <COLON> { throw toCSSParseException("invalidExprColon", new String[]{ unescape(t.image, false) }, createLocator(token)); } )?
1576+
( <COLON> { throw toCSSParseException("invalidExprColon", new String[]{ unescape(t.image, false) }, createLocator(t)); } )?
15771577
)
15781578
{ value = LexicalUnitImpl.createIdent(prev, unescape(t.image, false)); }
15791579
| t = <URI> { value = LexicalUnitImpl.createURI(prev, unescape(t.image, true)); }
@@ -1643,36 +1643,21 @@ LexicalUnit function(LexicalUnit prev) :
16431643
// : type_selector | universal | HASH | class | attrib | pseudo
16441644
// ;
16451645
//
1646-
Selector negation_arg() :
1646+
String negation_arg() :
16471647
{
1648-
Selector negationArg = null;
16491648
Condition c = null;
16501649
SimpleSelector simpleSel = null;
1651-
SimpleSelector pseudoElementSel = null;
16521650
Object o;
16531651
}
16541652
{
1655-
(
1656-
simpleSel = elementName() { return simpleSel; }
1657-
|
1658-
(
1659-
c = hash(null, false)
1660-
| c = _class(null, false)
1661-
| c = attrib(null, false)
1662-
| (
1663-
o = pseudo(null, false)
1664-
{ if (o instanceof Condition)
1665-
{ c = (Condition) o;
1666-
} else {
1667-
return new DescendantSelector(null, (SimpleSelector) o);
1668-
}
1669-
}
1670-
)
1671-
)
1672-
)
1673-
{
1674-
return new ConditionalSelector(null, c);
1675-
}
1653+
simpleSel = elementName() { return simpleSel.toString(); }
1654+
| c = hash(null, false) { return c.toString(); }
1655+
| c = _class(null, false) { return c.toString(); }
1656+
| c = attrib(null, false) { return c.toString(); }
1657+
| o = pseudo(null, false)
1658+
{ if (o instanceof Condition) { return o.toString(); }
1659+
return new DescendantSelector(null, (SimpleSelector) o).toString();
1660+
}
16761661
}
16771662

16781663
//

0 commit comments

Comments
 (0)