Skip to content

Commit dcc056f

Browse files
Add javacc as a submodule & regen analyzer with it
1 parent a0bb2f8 commit dcc056f

File tree

10 files changed

+413
-315
lines changed

10 files changed

+413
-315
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "testsuite"]
55
path = testsuite
66
url = https://github.com/w3c/css-validator-testsuite.git
7+
[submodule "javacc"]
8+
path = javacc
9+
url = git@github.com:javacc/javacc.git

build.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@
164164
</java>
165165
</target>
166166

167+
<target name="javacc">
168+
<ant antfile="build.xml" dir="javacc"/>
169+
</target>
170+
167171
<target name="clean" description="Cleans up generated files">
168172
<delete file="${jar.file}"/>
169173
<delete file="${war.file}"/>

javacc

Submodule javacc added at 38f8f9e

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

Lines changed: 267 additions & 233 deletions
Large diffs are not rendered by default.

org/w3c/css/parser/analyzer/CssParserTokenManager.java

Lines changed: 88 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
import org.w3c.css.selectors.attributes.AttributeSuffix;
7878

7979
/** Token Manager. */
80-
@SuppressWarnings("unused")public class CssParserTokenManager implements CssParserConstants {
80+
public class CssParserTokenManager implements CssParserConstants {
8181

8282
/** Debug output. */
8383
public java.io.PrintStream debugStream = System.out;
@@ -6131,7 +6131,7 @@ else if ((0x800000008000L & l) != 0L)
61316131
kind = 96;
61326132
{ jjCheckNAddTwoStates(678, 679); }
61336133
break;
6134-
default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break;
6134+
default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break;
61356135
}
61366136
} while(i != startsAt);
61376137
}
@@ -6167,6 +6167,41 @@ else if (jjmatchedPos == strPos && jjmatchedKind > strKind)
61676167

61686168
return toRet;
61696169
}
6170+
6171+
/** Token literal values. */
6172+
public static final String[] jjstrLiteralImages = {
6173+
"", null, null, null, null, null, null, null, null, null, null, null, null,
6174+
null, null, null, null, null, null, null, null, null, "\74\41\55\55", "\55\55\76",
6175+
null, "\174\75", null, null, "\55", null, null, null, null, null, null, null, null,
6176+
null, null, "\175", "\136\75", "\44\75", "\52\75", "\75", "\73", "\57", "\133",
6177+
"\135", "\52", "\56", "\51", "\50", "\72", null, null, null, null, null, null, null,
6178+
null, null, null, null, null, null, null, null, "\72\72", null, null, null, null,
6179+
null, null, null, null, null, null, null, null, null, null, null, null, null, null,
6180+
null, null, null, null, null, null, null, null, null, null, null, null, null, null,
6181+
null, null, null, "\174", "\45", };
6182+
protected Token jjFillToken()
6183+
{
6184+
final Token t;
6185+
final String curTokenImage;
6186+
final int beginLine;
6187+
final int endLine;
6188+
final int beginColumn;
6189+
final int endColumn;
6190+
String im = jjstrLiteralImages[jjmatchedKind];
6191+
curTokenImage = (im == null) ? input_stream.GetImage() : im;
6192+
beginLine = input_stream.getBeginLine();
6193+
beginColumn = input_stream.getBeginColumn();
6194+
endLine = input_stream.getEndLine();
6195+
endColumn = input_stream.getEndColumn();
6196+
t = Token.newToken(jjmatchedKind, curTokenImage);
6197+
6198+
t.beginLine = beginLine;
6199+
t.endLine = endLine;
6200+
t.beginColumn = beginColumn;
6201+
t.endColumn = endColumn;
6202+
6203+
return t;
6204+
}
61706205
static final int[] jjnextStates = {
61716206
700, 701, 702, 564, 703, 704, 705, 567, 706, 707, 708, 570, 709, 710, 711, 573,
61726207
712, 713, 714, 576, 715, 716, 717, 579, 718, 719, 720, 584, 721, 722, 723, 589,
@@ -6305,41 +6340,6 @@ private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, lo
63056340
}
63066341
}
63076342

6308-
/** Token literal values. */
6309-
public static final String[] jjstrLiteralImages = {
6310-
"", null, null, null, null, null, null, null, null, null, null, null, null,
6311-
null, null, null, null, null, null, null, null, null, "\74\41\55\55", "\55\55\76",
6312-
null, "\174\75", null, null, "\55", null, null, null, null, null, null, null, null,
6313-
null, null, "\175", "\136\75", "\44\75", "\52\75", "\75", "\73", "\57", "\133",
6314-
"\135", "\52", "\56", "\51", "\50", "\72", null, null, null, null, null, null, null,
6315-
null, null, null, null, null, null, null, null, "\72\72", null, null, null, null,
6316-
null, null, null, null, null, null, null, null, null, null, null, null, null, null,
6317-
null, null, null, null, null, null, null, null, null, null, null, null, null, null,
6318-
null, null, null, "\174", "\45", };
6319-
protected Token jjFillToken()
6320-
{
6321-
final Token t;
6322-
final String curTokenImage;
6323-
final int beginLine;
6324-
final int endLine;
6325-
final int beginColumn;
6326-
final int endColumn;
6327-
String im = jjstrLiteralImages[jjmatchedKind];
6328-
curTokenImage = (im == null) ? input_stream.GetImage() : im;
6329-
beginLine = input_stream.getBeginLine();
6330-
beginColumn = input_stream.getBeginColumn();
6331-
endLine = input_stream.getEndLine();
6332-
endColumn = input_stream.getEndColumn();
6333-
t = Token.newToken(jjmatchedKind, curTokenImage);
6334-
6335-
t.beginLine = beginLine;
6336-
t.endLine = endLine;
6337-
t.beginColumn = beginColumn;
6338-
t.endColumn = endColumn;
6339-
6340-
return t;
6341-
}
6342-
63436343
int curLexState = 0;
63446344
int defaultLexState = 0;
63456345
int jjnewStateCnt;
@@ -6361,7 +6361,7 @@ public Token getNextToken()
63616361
{
63626362
curChar = input_stream.BeginToken();
63636363
}
6364-
catch(java.io.IOException e)
6364+
catch(Exception e)
63656365
{
63666366
jjmatchedKind = 0;
63676367
jjmatchedPos = -1;
@@ -6422,6 +6422,31 @@ public Token getNextToken()
64226422
}
64236423
}
64246424

6425+
void SkipLexicalActions(Token matchedToken)
6426+
{
6427+
switch(jjmatchedKind)
6428+
{
6429+
default :
6430+
break;
6431+
}
6432+
}
6433+
void MoreLexicalActions()
6434+
{
6435+
jjimageLen += (lengthOfMatch = jjmatchedPos + 1);
6436+
switch(jjmatchedKind)
6437+
{
6438+
default :
6439+
break;
6440+
}
6441+
}
6442+
void TokenLexicalActions(Token matchedToken)
6443+
{
6444+
switch(jjmatchedKind)
6445+
{
6446+
default :
6447+
break;
6448+
}
6449+
}
64256450
private void jjCheckNAdd(int state)
64266451
{
64276452
if (jjrounds[state] != jjround)
@@ -6465,9 +6490,14 @@ public CssParserTokenManager (SimpleCharStream stream, int lexState){
64656490
}
64666491

64676492
/** Reinitialise parser. */
6493+
64686494
public void ReInit(SimpleCharStream stream)
64696495
{
6470-
jjmatchedPos = jjnewStateCnt = 0;
6496+
6497+
6498+
jjmatchedPos =
6499+
jjnewStateCnt =
6500+
0;
64716501
curLexState = defaultLexState;
64726502
input_stream = stream;
64736503
ReInitRounds();
@@ -6483,6 +6513,7 @@ private void ReInitRounds()
64836513

64846514
/** Reinitialise parser. */
64856515
public void ReInit(SimpleCharStream stream, int lexState)
6516+
64866517
{
64876518
ReInit(stream);
64886519
SwitchTo(lexState);
@@ -6497,10 +6528,20 @@ public void SwitchTo(int lexState)
64976528
curLexState = lexState;
64986529
}
64996530

6531+
65006532
/** Lexer state names. */
65016533
public static final String[] lexStateNames = {
65026534
"DEFAULT",
65036535
};
6536+
6537+
/** Lex State array. */
6538+
public static final int[] jjnewLexState = {
6539+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
6540+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
6541+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
6542+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
6543+
-1, -1, -1, -1, -1, -1,
6544+
};
65046545
static final long[] jjtoToken = {
65056546
0xffffffffffe00001L, 0x3ff803fffffL,
65066547
};
@@ -6509,12 +6550,17 @@ public void SwitchTo(int lexState)
65096550
};
65106551
static final long[] jjtoSpecial = {
65116552
0x2L, 0x0L,
6553+
};
6554+
static final long[] jjtoMore = {
6555+
0x0L, 0x0L,
65126556
};
65136557
protected SimpleCharStream input_stream;
65146558

65156559
private final int[] jjrounds = new int[775];
65166560
private final int[] jjstateSet = new int[2 * 775];
6517-
6518-
6519-
protected char curChar;
6561+
private final StringBuilder jjimage = new StringBuilder();
6562+
private StringBuilder image = jjimage;
6563+
private int jjimageLen;
6564+
private int lengthOfMatch;
6565+
protected int curChar;
65206566
}

org/w3c/css/parser/analyzer/Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Note that we will filter \u005c in simple \ as some IDEs have trouble with this.
2-
CssParser.java: CssParser.jj
3-
javacc CssParser.jj
4-
cat CssParser.java | sed 's/u005c//g' > C && mv -f C CssParser.java
2+
CssParser.java: CssParser.jj .FORCE
3+
java -cp ../../../../../javacc/target/javacc.jar javacc CssParser.jj
4+
cat CssParser.java \
5+
| sed 's/^}/ }/g; $$d' > C && mv -f C CssParser.java && \
6+
echo '}' >> CssParser.java
7+
.FORCE:

org/w3c/css/parser/analyzer/ParseException.java

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 6.0 */
2-
/* JavaCCOptions:KEEP_LINE_COL=null */
1+
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 7.0 */
2+
/* JavaCCOptions:KEEP_LINE_COLUMN=true */
33
package org.w3c.css.parser.analyzer;
44

55
/**
@@ -20,6 +20,11 @@ public class ParseException extends Exception {
2020
*/
2121
private static final long serialVersionUID = 1L;
2222

23+
/**
24+
* The end of line string for this machine.
25+
*/
26+
protected static String EOL = System.getProperty("line.separator", "\n");
27+
2328
/**
2429
* This constructor is used by the method "generateParseException"
2530
* in the generated parser. Calling this constructor generates
@@ -88,7 +93,7 @@ public ParseException(String message) {
8893
private static String initialise(Token currentToken,
8994
int[][] expectedTokenSequences,
9095
String[] tokenImage) {
91-
String eol = System.getProperty("line.separator", "\n");
96+
9297
StringBuffer expected = new StringBuffer();
9398
int maxSize = 0;
9499
for (int i = 0; i < expectedTokenSequences.length; i++) {
@@ -101,7 +106,7 @@ private static String initialise(Token currentToken,
101106
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
102107
expected.append("...");
103108
}
104-
expected.append(eol).append(" ");
109+
expected.append(EOL).append(" ");
105110
}
106111
String retval = "Encountered \"";
107112
Token tok = currentToken.next;
@@ -118,20 +123,23 @@ private static String initialise(Token currentToken,
118123
tok = tok.next;
119124
}
120125
retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
121-
retval += "." + eol;
122-
if (expectedTokenSequences.length == 1) {
123-
retval += "Was expecting:" + eol + " ";
126+
retval += "." + EOL;
127+
128+
129+
if (expectedTokenSequences.length == 0) {
130+
// Nothing to add here
124131
} else {
125-
retval += "Was expecting one of:" + eol + " ";
132+
if (expectedTokenSequences.length == 1) {
133+
retval += "Was expecting:" + EOL + " ";
134+
} else {
135+
retval += "Was expecting one of:" + EOL + " ";
136+
}
137+
retval += expected.toString();
126138
}
127-
retval += expected.toString();
139+
128140
return retval;
129141
}
130142

131-
/**
132-
* The end of line string for this machine.
133-
*/
134-
protected String eol = System.getProperty("line.separator", "\n");
135143

136144
/**
137145
* Used to convert raw characters to their escaped version
@@ -144,8 +152,6 @@ static String add_escapes(String str) {
144152
for (int i = 0; i < str.length(); i++) {
145153
switch (str.charAt(i))
146154
{
147-
case 0 :
148-
continue;
149155
case '\b':
150156
retval.append("\\b");
151157
continue;
@@ -184,4 +190,4 @@ static String add_escapes(String str) {
184190
}
185191

186192
}
187-
/* JavaCC - OriginalChecksum=6b814b86a7f83d7302418ed01d10c383 (do not edit this line) */
193+
/* JavaCC - OriginalChecksum=7d68a6a068da3c9ac8d23a9a0983a253 (do not edit this line) */

org/w3c/css/parser/analyzer/SimpleCharStream.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 6.0 */
1+
/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 7.0 */
22
/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
33
package org.w3c.css.parser.analyzer;
44

@@ -30,13 +30,14 @@ public class SimpleCharStream
3030
protected char[] buffer;
3131
protected int maxNextCharInd = 0;
3232
protected int inBuf = 0;
33-
protected int tabSize = 8;
34-
protected boolean trackLineColumn = false;
33+
protected int tabSize = 1;
34+
protected boolean trackLineColumn = true;
3535

3636
public void setTabSize(int i) { tabSize = i; }
3737
public int getTabSize() { return tabSize; }
3838

3939

40+
4041
protected void ExpandBuff(boolean wrapAround)
4142
{
4243
char[] newbuffer = new char[bufsize + 2048];
@@ -467,8 +468,7 @@ public void adjustBeginLineColumn(int newLine, int newCol)
467468
line = bufline[j];
468469
column = bufcolumn[j];
469470
}
470-
471471
boolean getTrackLineColumn() { return trackLineColumn; }
472-
void setTrackLineColumn(boolean trackLineColumn) { this.trackLineColumn = trackLineColumn; }
472+
void setTrackLineColumn(boolean tlc) { trackLineColumn = tlc; }
473473
}
474-
/* JavaCC - OriginalChecksum=e2781e1a6e95beb7efed54cdfe328ade (do not edit this line) */
474+
/* JavaCC - OriginalChecksum=ddaf552144d8059b9d34162bcfbf9de7 (do not edit this line) */

org/w3c/css/parser/analyzer/Token.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* Generated By:JavaCC: Do not edit this line. Token.java Version 6.0 */
2-
/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
1+
/* Generated By:JavaCC: Do not edit this line. Token.java Version 7.0 */
2+
/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COLUMN=true,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
33
package org.w3c.css.parser.analyzer;
44

55
/**
@@ -97,6 +97,7 @@ public Token(int kind, String image)
9797
/**
9898
* Returns the image.
9999
*/
100+
@Override
100101
public String toString()
101102
{
102103
return image;
@@ -128,4 +129,4 @@ public static Token newToken(int ofKind)
128129
}
129130

130131
}
131-
/* JavaCC - OriginalChecksum=7af9a5dffce9b3c54b5b20fb3ae238c7 (do not edit this line) */
132+
/* JavaCC - OriginalChecksum=36fc9b16b8ca0d6418e40ba2b00d4428 (do not edit this line) */

0 commit comments

Comments
 (0)