Skip to content

Commit 651c272

Browse files
committed
simplify
1 parent 2ff457a commit 651c272

File tree

1 file changed

+32
-24
lines changed

1 file changed

+32
-24
lines changed

src/main/javacc/CSS3Parser.jj

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2146,10 +2146,7 @@ LexicalUnit hslColor(LexicalUnit prev) :
21462146
(op = unaryOperator() )?
21472147
(
21482148
next = number(next, op)
2149-
| t = <ANGLE_DEG> { next = LexicalUnitImpl.createDegree(next, doubleValue(op, t.image)); }
2150-
| t = <ANGLE_RAD> { next = LexicalUnitImpl.createRadian(next, doubleValue(op, t.image)); }
2151-
| t = <ANGLE_GRAD> { next = LexicalUnitImpl.createGradian(next, doubleValue(op, t.image)); }
2152-
| t = <ANGLE_TURN> { next = LexicalUnitImpl.createTurn(next, doubleValue(op, t.image)); }
2149+
| next = angle(next, op)
21532150

21542151
| t = ident() { next = LexicalUnitImpl.createIdent(next, unescape(t.image, false)); }
21552152
| next = calc(next)
@@ -2215,10 +2212,7 @@ LexicalUnit hslColor(LexicalUnit prev) :
22152212
(
22162213
<NONE> { param = LexicalUnitImpl.createNone(null); }
22172214
| param = number(null, op)
2218-
| t = <ANGLE_DEG> { param = LexicalUnitImpl.createDegree(null, doubleValue(op, t.image)); }
2219-
| t = <ANGLE_RAD> { param = LexicalUnitImpl.createRadian(null, doubleValue(op, t.image)); }
2220-
| t = <ANGLE_GRAD> { param = LexicalUnitImpl.createGradian(null, doubleValue(op, t.image)); }
2221-
| t = <ANGLE_TURN> { param = LexicalUnitImpl.createTurn(null, doubleValue(op, t.image)); }
2215+
| param = angle(null, op)
22222216

22232217
| param = calc(null)
22242218
| param = var(null)
@@ -2328,10 +2322,7 @@ LexicalUnit hwbColor(LexicalUnit prev) :
23282322
(op = unaryOperator() )?
23292323
(
23302324
next = number(next, op)
2331-
| t = <ANGLE_DEG> { next = LexicalUnitImpl.createDegree(next, doubleValue(op, t.image)); }
2332-
| t = <ANGLE_RAD> { next = LexicalUnitImpl.createRadian(next, doubleValue(op, t.image)); }
2333-
| t = <ANGLE_GRAD> { next = LexicalUnitImpl.createGradian(next, doubleValue(op, t.image)); }
2334-
| t = <ANGLE_TURN> { next = LexicalUnitImpl.createTurn(next, doubleValue(op, t.image)); }
2325+
| next = angle(next, op)
23352326

23362327
| t = ident() { next = LexicalUnitImpl.createIdent(next, unescape(t.image, false)); }
23372328
| next = calc(next)
@@ -2396,10 +2387,7 @@ LexicalUnit hwbColor(LexicalUnit prev) :
23962387
(
23972388
<NONE> { param = LexicalUnitImpl.createNone(null); }
23982389
| param = number(null, op)
2399-
| t = <ANGLE_DEG> { param = LexicalUnitImpl.createDegree(null, doubleValue(op, t.image)); }
2400-
| t = <ANGLE_RAD> { param = LexicalUnitImpl.createRadian(null, doubleValue(op, t.image)); }
2401-
| t = <ANGLE_GRAD> { param = LexicalUnitImpl.createGradian(null, doubleValue(op, t.image)); }
2402-
| t = <ANGLE_TURN> { param = LexicalUnitImpl.createTurn(null, doubleValue(op, t.image)); }
2390+
| param = angle(null, op)
24032391

24042392
| param = calc(null)
24052393
| param = var(null)
@@ -2698,10 +2686,7 @@ LexicalUnit lchColor(LexicalUnit prev) :
26982686
(
26992687
(op = unaryOperator() )?
27002688
(
2701-
t = <ANGLE_DEG> { next = LexicalUnitImpl.createDegree(next, doubleValue(op, t.image)); }
2702-
| t = <ANGLE_RAD> { next = LexicalUnitImpl.createRadian(next, doubleValue(op, t.image)); }
2703-
| t = <ANGLE_GRAD> { next = LexicalUnitImpl.createGradian(next, doubleValue(op, t.image)); }
2704-
| t = <ANGLE_TURN> { next = LexicalUnitImpl.createTurn(next, doubleValue(op, t.image)); }
2689+
next = angle(next, op)
27052690

27062691
| t = ident() { next = LexicalUnitImpl.createIdent(next, unescape(t.image, false)); }
27072692
| next = calc(next)
@@ -2767,10 +2752,7 @@ LexicalUnit lchColor(LexicalUnit prev) :
27672752
(op = unaryOperator() )?
27682753
(
27692754
<NONE> { next = LexicalUnitImpl.createNone(next); }
2770-
| t = <ANGLE_DEG> { next = LexicalUnitImpl.createDegree(next, doubleValue(op, t.image)); }
2771-
| t = <ANGLE_RAD> { next = LexicalUnitImpl.createRadian(next, doubleValue(op, t.image)); }
2772-
| t = <ANGLE_GRAD> { next = LexicalUnitImpl.createGradian(next, doubleValue(op, t.image)); }
2773-
| t = <ANGLE_TURN> { next = LexicalUnitImpl.createTurn(next, doubleValue(op, t.image)); }
2755+
| next = angle(next, op)
27742756

27752757
| next = calc(next)
27762758
| next = var(next)
@@ -2981,6 +2963,32 @@ LexicalUnit dimension(LexicalUnit prev, char op) :
29812963
}
29822964
}
29832965

2966+
2967+
//
2968+
// angle()
2969+
//
2970+
LexicalUnit angle(LexicalUnit prev, char op) :
2971+
{
2972+
Token t;
2973+
LexicalUnit value = null;
2974+
}
2975+
{
2976+
(
2977+
t = <ANGLE_DEG> { value = LexicalUnitImpl.createDegree(prev, doubleValue(op, t.image)); }
2978+
| t = <ANGLE_RAD> { value = LexicalUnitImpl.createRadian(prev, doubleValue(op, t.image)); }
2979+
| t = <ANGLE_GRAD> { value = LexicalUnitImpl.createGradian(prev, doubleValue(op, t.image)); }
2980+
| t = <ANGLE_TURN> { value = LexicalUnitImpl.createTurn(prev, doubleValue(op, t.image)); }
2981+
)
2982+
{
2983+
if (value != null)
2984+
{
2985+
value.setLocator(createLocator(token));
2986+
}
2987+
return value;
2988+
}
2989+
}
2990+
2991+
29842992
//
29852993
// unicodeRange
29862994
//

0 commit comments

Comments
 (0)