mainLoop method
void
mainLoop()
Implementation
void mainLoop() {
while (tokenizer.moveNext()) {
final token = tokenizer.current;
Token? newToken = token;
int type;
while (newToken != null) {
type = newToken.kind;
// Note: avoid "is" test here, see http://dartbug.com/4795
if (type == TokenKind.parseError) {
final error = newToken as ParseErrorToken;
parseError(error.span, error.data, error.messageParams);
newToken = null;
} else {
var localPhase = phase;
if (inForeignContent(token, type)) {
localPhase = _inForeignContentPhase;
}
switch (type) {
case TokenKind.characters:
newToken =
localPhase.processCharacters(newToken as CharactersToken);
break;
case TokenKind.spaceCharacters:
newToken = localPhase
.processSpaceCharacters(newToken as SpaceCharactersToken);
break;
case TokenKind.startTag:
newToken = localPhase.processStartTag(newToken as StartTagToken);
break;
case TokenKind.endTag:
newToken = localPhase.processEndTag(newToken as EndTagToken);
break;
case TokenKind.comment:
newToken = localPhase.processComment(newToken as CommentToken);
break;
case TokenKind.doctype:
newToken = localPhase.processDoctype(newToken as DoctypeToken);
break;
}
}
}
if (token is StartTagToken) {
if (token.selfClosing && !token.selfClosingAcknowledged) {
parseError(token.span, 'non-void-element-with-trailing-solidus',
{'name': token.name});
}
}
}
// When the loop finishes it's EOF
var reprocess = true;
final reprocessPhases = <Phase>[];
while (reprocess) {
reprocessPhases.add(phase);
reprocess = phase.processEOF();
if (reprocess) {
assert(!reprocessPhases.contains(phase));
}
}
}