diff options
-rw-r--r-- | eval.c | 6 | ||||
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | test.toc | 25 |
3 files changed, 13 insertions, 22 deletions
@@ -483,8 +483,12 @@ static bool eval_set(Evaluator *ev, Expression *set, Value *to) { } break; default: break; } + break; case EXPR_TUPLE: - /* TODO */ + for (size_t i = 0; i < arr_len(set->tuple); i++) { + if (!eval_set(ev, &set->tuple[i], &to->tuple[i])) + return false; + } break; default: assert(0); @@ -1,15 +1,15 @@ /* TODO: -pointer arithmetic compile time arrays, slices -unicode variable names make sure initializers for global variables are compile-time constants structs length of slice/arr with .len don't allow while {3; 5} (once break is added) +allow omission of trailing ; in foo @= fn() {} any odd number of "s for a string modifiable strings: s := ["sakjdfhkjh ksjdahfkjsd ahs ahdf hsdaf khsadkjfh"]; +unicode variable names */ #include "toc.c" @@ -13,30 +13,17 @@ putf @= fn(x: float) { "); }; -sum @= fn(x: []int, n: int) int { - p := &x[0]; - end := &x[n-1]; - total := 0; - while p <= end { - total = total + *p; - p = p + 1; - } - total +ptriple @= fn(m: int, n: int) (int, int, int) { + m*m-n*n, 2*m*n, m*m+n*n }; f @= fn() int { - N @= 10; - - numbers := new(int, N); - i := 0; - while i < N { - numbers[i] = i; - i = i + 1; - } - sum(numbers, N) + a, b, c : int; + a, b, c = ptriple(3, 2); + a + b + c }; main @= fn() { - a: [f()]int; puti(f()); + A : [f()]int; }; |