Skip to content

Commit 72cc8b1

Browse files
committed
lang: Add anonymous Tuple syntax
1 parent 3db0380 commit 72cc8b1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/vm/wren_compiler.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1747,6 +1747,7 @@ typedef struct
17471747
// Forward declarations since the grammar is recursive.
17481748
static GrammarRule* getRule(TokenType type);
17491749
static void expression(Compiler* compiler);
1750+
static void maybeTuple(Compiler* compiler);
17501751
static void statement(Compiler* compiler);
17511752
static void definition(Compiler* compiler);
17521753
static void parsePrecedence(Compiler* compiler, Precedence precedence);
@@ -2138,7 +2139,7 @@ static void loadCoreVariable(Compiler* compiler, const char* name)
21382139
// A parenthesized expression.
21392140
static void grouping(Compiler* compiler, bool canAssign)
21402141
{
2141-
expression(compiler);
2142+
maybeTuple(compiler);
21422143
consume(compiler, TOKEN_RIGHT_PAREN, "Expect ')' after expression.");
21432144
}
21442145

@@ -2857,6 +2858,16 @@ void expression(Compiler* compiler)
28572858
parsePrecedence(compiler, PREC_LOWEST);
28582859
}
28592860

2861+
void maybeTuple(Compiler* compiler)
2862+
{
2863+
expression(compiler);
2864+
2865+
if (peek(compiler) == TOKEN_COMMA)
2866+
{
2867+
error(compiler, "Cannot create a tuple.");
2868+
}
2869+
}
2870+
28602871
// Returns the number of bytes for the arguments to the instruction
28612872
// at [ip] in [fn]'s bytecode.
28622873
static int getByteCountForArguments(const uint8_t* bytecode,

0 commit comments

Comments
 (0)