mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Allow trailing commas when writing a compound
This commit is contained in:
@@ -168,6 +168,10 @@ static Toy_Opcode compound(Toy_Parser* parser, Toy_ASTNode** nodeHandle) {
|
|||||||
consume(parser, TOY_TOKEN_COMMA, "Expected ',' in array or dictionary");
|
consume(parser, TOY_TOKEN_COMMA, "Expected ',' in array or dictionary");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (match(parser, TOY_TOKEN_BRACKET_RIGHT)) { //allow for trailing commas
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
iterations++;
|
iterations++;
|
||||||
|
|
||||||
Toy_ASTNode* left = NULL;
|
Toy_ASTNode* left = NULL;
|
||||||
|
|||||||
8
test/scripts/trailing-comma-bugfix.toy
Normal file
8
test/scripts/trailing-comma-bugfix.toy
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
var array = [
|
||||||
|
1, 2, 3,
|
||||||
|
4, 5, 6,
|
||||||
|
7, 8, 9, //explicitly leave a trailing comma
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
print "All good";
|
||||||
@@ -140,6 +140,7 @@ int main() {
|
|||||||
"polyfill-remove.toy",
|
"polyfill-remove.toy",
|
||||||
"short-circuiting-support.toy",
|
"short-circuiting-support.toy",
|
||||||
"ternary-expressions.toy",
|
"ternary-expressions.toy",
|
||||||
|
"trailing-comma-bugfix.toy",
|
||||||
"types.toy",
|
"types.toy",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user