Skip to content

Commit e7fe39d

Browse files
committed
simplify parser
1 parent 73d9b5e commit e7fe39d

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

src/main/javacc/CSS3Parser.jj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ TOKEN_MGR_DECLS :
268268
| < SUBSTRINGMATCH: "*=" >
269269

270270
// {w}"{" {return LBRACE;}
271-
| < LBRACE: <W> "{" >
271+
| < LBRACE: "{" >
272272
| < RBRACE: "}" >
273273

274274
| < LROUND: "(" >
@@ -285,16 +285,16 @@ TOKEN_MGR_DECLS :
285285
| < RSQUARE: "]" >
286286

287287
// {w}"+" {return PLUS;}
288-
| < PLUS: <W> "+" >
288+
| < PLUS: "+" >
289289

290290
// {w}">" {return GREATER;}
291-
| < GREATER: <W> ">" >
291+
| < GREATER: ">" >
292292

293293
// {w}"~" {return TILDE;}
294294
| < TILDE: "~" >
295295

296296
// {w}"," {return COMMA;}
297-
| < COMMA: <W> "," >
297+
| < COMMA: "," >
298298

299299
// "#"{name} {return HASH;}
300300
| < HASH: "#" <NAME> >

src/test/java/org/htmlunit/cssparser/parser/CSS3ParserTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -994,17 +994,17 @@ public void rgbVariousErrors() throws Exception {
994994
color(1, "DOM exception: 'rgb mixing numbers and percentages.'", "foreground: rgb(10 20 30%)");
995995
color(1, "DOM exception: 'rgb mixing numbers and percentages.'", "foreground: rgb(10% 20 30%)");
996996

997-
color(1, "Error in expression. (Invalid token \")\". Was expecting one of: <S>, <NUMBER>, \"-\", <PLUS>, <PERCENTAGE>.)",
997+
color(1, "Error in expression. (Invalid token \")\". Was expecting one of: <S>, <NUMBER>, \"-\", \"+\", <PERCENTAGE>.)",
998998
"foreground: rgb(10, 20, 30,)");
999-
color(1, "Error in expression. (Invalid token \")\". Was expecting one of: <S>, <NUMBER>, \"-\", <PLUS>, <PERCENTAGE>.)",
999+
color(1, "Error in expression. (Invalid token \")\". Was expecting one of: <S>, <NUMBER>, \"-\", \"+\", <PERCENTAGE>.)",
10001000
"foreground: rgb(10, 20, 30/)");
10011001

1002-
color(1, "Error in expression. (Invalid token \"20\". Was expecting one of: <S>, <NUMBER>, \"-\", <PLUS>, <PERCENTAGE>.)",
1002+
color(1, "Error in expression. (Invalid token \"20\". Was expecting one of: <S>, <NUMBER>, \"-\", \"+\", <PERCENTAGE>.)",
10031003
"foreground: rgb(10, 20px, 30)");
1004-
color(1, "Error in expression. (Invalid token \"20\". Was expecting one of: <S>, <NUMBER>, \"-\", <PLUS>, <COMMA>, <PERCENTAGE>.)",
1004+
color(1, "Error in expression. (Invalid token \"20\". Was expecting one of: <S>, <NUMBER>, \"-\", \"+\", \",\", <PERCENTAGE>.)",
10051005
"foreground: rgb(10 20px 30)");
10061006

1007-
color(1, "Error in expression. (Invalid token \"10\". Was expecting one of: <S>, <NUMBER>, \"-\", <PLUS>, <PERCENTAGE>.)",
1007+
color(1, "Error in expression. (Invalid token \"10\". Was expecting one of: <S>, <NUMBER>, \"-\", \"+\", <PERCENTAGE>.)",
10081008
"foreground: rgb('10', 20, 30,)");
10091009
}
10101010

@@ -1137,15 +1137,15 @@ public void hslVariousErrors() throws Exception {
11371137
color(1, "DOM exception: 'hsl requires consitent separators (blank or comma).'", "foreground: hsl(10 20%, 30%)");
11381138

11391139
color(1, "Error in expression. (Invalid token \"10\". "
1140-
+ "Was expecting one of: <S>, <NUMBER>, \"-\", <PLUS>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <ANGLE_TURN>.)",
1140+
+ "Was expecting one of: <S>, <NUMBER>, \"-\", \"+\", <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <ANGLE_TURN>.)",
11411141
"foreground: hsl('10', 20% 30%)");
11421142
color(1, "Error in expression. (Invalid token \"10\". "
1143-
+ "Was expecting one of: <S>, <NUMBER>, \"-\", <PLUS>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <ANGLE_TURN>.)",
1143+
+ "Was expecting one of: <S>, <NUMBER>, \"-\", \"+\", <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <ANGLE_TURN>.)",
11441144
"foreground: hsl(10px, 20% 30%)");
11451145

1146-
color(1, "Error in expression. (Invalid token \"20\". Was expecting one of: <S>, \"-\", <PLUS>, <PERCENTAGE>.)",
1146+
color(1, "Error in expression. (Invalid token \"20\". Was expecting one of: <S>, \"-\", \"+\", <PERCENTAGE>.)",
11471147
"foreground: hsl(10, 20, 30%)");
1148-
color(1, "Error in expression. (Invalid token \"30\". Was expecting one of: <S>, \"-\", <PLUS>, <PERCENTAGE>.)",
1148+
color(1, "Error in expression. (Invalid token \"30\". Was expecting one of: <S>, \"-\", \"+\", <PERCENTAGE>.)",
11491149
"foreground: hsl(10, 20%, 30)");
11501150
}
11511151

@@ -1874,15 +1874,15 @@ public void malformedDeclaration() throws Exception {
18741874
final String expected = "Error in declaration. (Invalid token \"}\". Was expecting one of: <S>, \":\".)"
18751875
+ " Error in declaration. (Invalid token \";\". Was expecting one of: <S>, \":\".)"
18761876
+ " Error in expression. (Invalid token \"}\". Was expecting one of: <S>, <NUMBER>, \"inherit\", "
1877-
+ "<IDENT>, <STRING>, \"-\", <PLUS>, <HASH>, <EMS>, <REM>, <EXS>, <CH>, "
1877+
+ "<IDENT>, <STRING>, \"-\", \"+\", <HASH>, <EMS>, <REM>, <EXS>, <CH>, "
18781878
+ "<VW>, <VH>, <VMIN>, <VMAX>, "
18791879
+ "<LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <LENGTH_Q>, "
18801880
+ "<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <ANGLE_TURN>, "
18811881
+ "<TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, "
18821882
+ "<DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION_CALC>, <FUNCTION_VAR>, "
18831883
+ "<FUNCTION_RGB>, <FUNCTION_HSL>, <FUNCTION>, \"progid:\".)"
18841884
+ " Error in expression. (Invalid token \";\". Was expecting one of: <S>, <NUMBER>, \"inherit\", "
1885-
+ "<IDENT>, <STRING>, \"-\", <PLUS>, <HASH>, <EMS>, <REM>, <EXS>, <CH>, "
1885+
+ "<IDENT>, <STRING>, \"-\", \"+\", <HASH>, <EMS>, <REM>, <EXS>, <CH>, "
18861886
+ "<VW>, <VH>, <VMIN>, <VMAX>, "
18871887
+ "<LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <LENGTH_Q>, "
18881888
+ "<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <ANGLE_TURN>, "
@@ -1984,7 +1984,7 @@ public void malformedStatements() throws Exception {
19841984

19851985
assertEquals(1, errorHandler.getErrorCount());
19861986
final String expected = "Error in style rule. "
1987-
+ "(Invalid token \"@here\". Was expecting one of: <S>, <LBRACE>, <COMMA>.)";
1987+
+ "(Invalid token \"@here\". Was expecting one of: <S>, \"{\", \",\".)";
19881988
assertEquals(expected, errorHandler.getErrorMessage());
19891989
assertEquals("2", errorHandler.getErrorLines());
19901990
assertEquals("3", errorHandler.getErrorColumns());
@@ -2179,7 +2179,7 @@ public void unexpectedEndOfString() throws Exception {
21792179
assertEquals(1, errorHandler.getErrorCount());
21802180
final String expected = "Error in expression. "
21812181
+ "(Invalid token \"\\'\". Was expecting one of: <S>, <NUMBER>, \"inherit\", "
2182-
+ "<IDENT>, <STRING>, \"-\", <PLUS>, <HASH>, <EMS>, <REM>, <EXS>, <CH>, "
2182+
+ "<IDENT>, <STRING>, \"-\", \"+\", <HASH>, <EMS>, <REM>, <EXS>, <CH>, "
21832183
+ "<VW>, <VH>, <VMIN>, <VMAX>, "
21842184
+ "<LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <LENGTH_Q>, "
21852185
+ "<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <ANGLE_TURN>, "

src/test/java/org/htmlunit/cssparser/parser/LocatorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void locationsCSS3() throws IOException {
9999
positions.put('R', rPos);
100100
final List<Integer[]> mPos = new ArrayList<>();
101101
mPos.add(new Integer[] {2, 29});
102-
mPos.add(new Integer[] {11, 8});
102+
mPos.add(new Integer[] {11, 16});
103103
positions.put('M', mPos);
104104
final List<Integer[]> pPos = new ArrayList<>();
105105
pPos.add(new Integer[] {5, 3});

0 commit comments

Comments
 (0)