summaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2019-08-30 18:18:13 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2019-08-30 18:18:13 -0400
commit88c3ad84bdd3bda3bb121019d8c55da21bf6fab8 (patch)
treeb86885cd3937d5fa817aa75b30bdb9abc2d27495 /parse.c
parent94e8da0bc35d80df12e2d1490b3aa751576095f6 (diff)
tuple assignment
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/parse.c b/parse.c
index cae15bc..5a85165 100644
--- a/parse.c
+++ b/parse.c
@@ -80,6 +80,7 @@ typedef enum {
BINARY_SET, /* e.g. x = y */
BINARY_PLUS,
BINARY_MINUS,
+ BINARY_COMMA,
BINARY_AT_INDEX /* e.g. x[i] */
} BinaryOp;
@@ -154,6 +155,7 @@ static const char *binary_op_to_str(BinaryOp b) {
case BINARY_PLUS: return "+";
case BINARY_MINUS: return "-";
case BINARY_SET: return "=";
+ case BINARY_COMMA: return ",";
case BINARY_AT_INDEX: return "[]";
}
assert(0);
@@ -292,6 +294,8 @@ static int op_precedence(Keyword op) {
switch (op) {
case KW_EQ:
return 0;
+ case KW_COMMA:
+ return 5;
case KW_PLUS:
return 10;
case KW_MINUS:
@@ -869,6 +873,9 @@ static bool parse_expr(Parser *p, Expression *e, Token *end) {
case KW_EQ:
op = BINARY_SET;
break;
+ case KW_COMMA:
+ op = BINARY_COMMA;
+ break;
default: assert(0); break;
}
e->binary.op = op;
@@ -982,6 +989,7 @@ static bool parse_single_type_in_decl(Parser *p, Declaration *d) {
if (d->type.kind != TYPE_VOID) {
*(Type*)arr_add(&tup_arr) = d->type; /* add current type */
}
+ d->type.flags = 0;
d->type.kind = TYPE_TUPLE;
d->type.tuple = tup_arr;
for (size_t i = 0; i < n_idents_with_this_type; i++) {
@@ -1197,6 +1205,9 @@ static void fprint_expr(FILE *out, Expression *e) {
case BINARY_AT_INDEX:
fprintf(out, "at");
break;
+ case BINARY_COMMA:
+ fprintf(out, "tuple");
+ break;
}
fprintf(out, "(");
fprint_expr(out, e->binary.lhs);