s = new DoWhileLoop(posFrom(start), label, body, cond);
// http://code.google.com/p/google-caja/issues/detail?id=1316
// ES[35] requires ; after do-while, but browsers are ok without it.
// Here we either eat a ; or warn if it's missing.
if (!tq.checkToken(Punctuation.SEMI)) {
FilePosition pos = FilePosition.endOf(tq.lastPosition());
mq.addMessage(
MessageType.SEMICOLON_INSERTED, MessageLevel.LINT, pos);
}
break;
}
case SWITCH:
{
tq.advance();
tq.expectToken(Punctuation.LPAREN);
Expression switchValue = parseExpressionInt(true);
tq.expectToken(Punctuation.RPAREN);
tq.expectToken(Punctuation.LCURLY);
List<SwitchCase> cases = Lists.newArrayList();
while (!tq.checkToken(Punctuation.RCURLY)) {
Mark caseMark = tq.mark();
Expression caseValue;
if (tq.checkToken(Keyword.DEFAULT)) {
caseValue = null;
} else {
tq.expectToken(Keyword.CASE);
caseValue = parseExpressionInt(false);
}
tq.expectToken(Punctuation.COLON);
FilePosition colonPos = tq.lastPosition();
Mark caseBodyStart = tq.mark();
List<Statement> caseBodyContents = Lists.newArrayList();
while (!(tq.lookaheadToken(Keyword.DEFAULT)
|| tq.lookaheadToken(Keyword.CASE)
|| tq.lookaheadToken(Punctuation.RCURLY))) {
caseBodyContents.add(parseTerminatedStatement());
}
FilePosition caseBodyPos = caseBodyContents.isEmpty()
? FilePosition.endOf(colonPos) : posFrom(caseBodyStart);
Block caseBody = new Block(caseBodyPos, caseBodyContents);
finish(caseBody, caseBodyStart);
SwitchCase caseStmt = (null != caseValue)
? new CaseStmt(posFrom(caseMark), caseValue, caseBody)