listOrSetLiteral method
Implementation
AstNode listOrSetLiteral() {
List<AstNode> elements = [];
if (!check(TokenType.rightBracket)) {
do {
if (check(TokenType.rightBracket)) break;
elements.add(expression());
} while (match([TokenType.comma]));
}
consume(TokenType.rightBracket, "Expect ']' after list or set elements.");
// If we have a colon after the closing bracket, it's a set
if (match([TokenType.colon])) {
return SetLiteral(elements);
}
return ListLiteral(elements);
}