Added opcodes to build collection literals

This commit is contained in:
nocturn9x 2021-10-31 10:43:45 +01:00
parent 033aac50c2
commit 08f68f09df
2 changed files with 8 additions and 2 deletions

View File

@ -123,7 +123,11 @@ type
BeginTry, BeginTry,
FinishTry, FinishTry,
Yield, Yield,
Await Await,
BuildList,
BuildDict,
BuildSet,
BuildTuple

View File

@ -250,7 +250,9 @@ proc primary(self: Parser): ASTNode =
of LeftBrace: of LeftBrace:
let tok = self.step() let tok = self.step()
if self.match(RightBrace): if self.match(RightBrace):
# This yields an empty dictionary # This yields an empty dictionary, not an empty set!
# For empty sets, there will be a builtin set() type
# that can be instantiated with no arguments
result = newDictExpr(@[], @[], tok) result = newDictExpr(@[], @[], tok)
else: else:
result = self.expression() result = self.expression()