String directive = "";
String args;
while (true) {
if (peek(1) == Tokenizer.EOL) {
return new CommentToken(line, col, builder.toString(), getLineNo(), getColumn());
}
if ("".equals(directive) && Character.isWhitespace(peek(1))) {
directive = builder.substring(5);
}
if (peek(1) == '-' && peek(2) == '-' && peek(3) == '>') {
args = builder.substring(5 + directive.length() + 1).trim();
break;
}
builder.append(nextChar());
}
nextChar(3);
builder.append("-->");
ParserDirectiveToken tok = new ParserDirectiveToken(line, col, builder.toString(), getLineNo(), getColumn(), directive, args);
if (peek(1) == '\r') {
if (peek(2) == '\n') {
nextChar(2);
tok.setTrailingSpace("\r\n");
} else {
tok.setTrailingSpace("\r");
nextChar();
}
} else if (peek(1) == '\n') {
tok.setTrailingSpace("\n");
nextChar();
}
return tok;
} else if (peek(1) == '-' && peek(2) == '-') {
nextChar(2);
// Comment block
builder.append("!--");
while (true) {
if (peek(1) == Tokenizer.EOL) {
return new CommentToken(line, col, builder.toString(), getLineNo(), getColumn());
}
if (peek(1) == '-' && peek(2) == '-' && peek(3) == '>') break;
builder.append(nextChar());
}
nextChar(3);
builder.append("-->");
return new CommentToken(line, col, builder.toString(), getLineNo(), getColumn());
// CDATA Blocks
} else if ("[CDATA[".equals(peekString(7))) {
c = nextChar(7);