diff --git a/drafts/c.c b/drafts/c.c index 233091e..9af9fef 100644 --- a/drafts/c.c +++ b/drafts/c.c @@ -17,25 +17,27 @@ struct jb_record struct jb_record *jbs= 0; + int eval(oop ast) { case t_call: { - pushJbRec(); - if (0 != set_jmp(jbs->jb)) { - oop result = jbs->result; - popJbRec(); - return result; - } - // run the body of the function here - result = (each statement in the func body...); - popJbRec(); - return result; + pushJbRec(); + if (0 != set_jmp(jbs->jb)) { + oop result = jbs->result; + popJbRec(); + return result; + } + // run the body of the function here + result = (each statement in the func body...); + popJbRec(); + return result; } setjmp(jb); if (n < 2) return 1; return 1 + f(n-1) + f(n-2); } + int main() { printf("%zi\n", sizeof(jmp_buf)); diff --git a/test2.txt b/test2.txt index 6e41de3..f68e1a8 100644 --- a/test2.txt +++ b/test2.txt @@ -1,13 +1,16 @@ fun f() { var i = 0 - while (i<10) { - print(i) - if (i == 5) { - return 42 - } - else { - i = i + 1 + for (var i= 0; i < 10; i = i + 1) { + switch (i) { + case 5: { + continue + } + case 8: { + return 66; + } } + print(i) } + 24 + 2 } f() \ No newline at end of file diff --git a/test3.txt b/test3.txt new file mode 100644 index 0000000..7a52b60 --- /dev/null +++ b/test3.txt @@ -0,0 +1,8 @@ +fun f(n) { + if (n < 2) { + return 1 + } else { + return 1 + f(n-1) + f(n-2) + } +} +f(27) \ No newline at end of file