in src/parser/cssParser.ts [550:613]
done: while (true) {
switch (this.token.type) {
case TokenType.SemiColon:
// A semicolon only ends things if we're not inside a delimitor.
if (isTopLevel()) {
break done;
}
break;
case TokenType.Exclamation:
// An exclamation ends the value if we're not inside delims.
if (isTopLevel()) {
break done;
}
break;
case TokenType.CurlyL:
curlyDepth++;
break;
case TokenType.CurlyR:
curlyDepth--;
if (curlyDepth < 0) {
// The property value has been terminated without a semicolon, and
// this is the last declaration in the ruleset.
if (onStopToken() && parensDepth === 0 && bracketsDepth === 0) {
break done;
}
return this.finish(node, ParseError.LeftCurlyExpected);
}
break;
case TokenType.ParenthesisL:
parensDepth++;
break;
case TokenType.ParenthesisR:
parensDepth--;
if (parensDepth < 0) {
if (onStopToken() && bracketsDepth === 0 && curlyDepth === 0) {
break done;
}
return this.finish(node, ParseError.LeftParenthesisExpected);
}
break;
case TokenType.BracketL:
bracketsDepth++;
break;
case TokenType.BracketR:
bracketsDepth--;
if (bracketsDepth < 0) {
return this.finish(node, ParseError.LeftSquareBracketExpected);
}
break;
case TokenType.BadString: // fall through
break done;
case TokenType.EOF:
// We shouldn't have reached the end of input, something is
// unterminated.
let error = ParseError.RightCurlyExpected;
if (bracketsDepth > 0) {
error = ParseError.RightSquareBracketExpected;
} else if (parensDepth > 0) {
error = ParseError.RightParenthesisExpected;
}
return this.finish(node, error);
}
this.consumeToken();
}