Quellcode durchsuchen

Modify drafts and tests

master
mtardy vor 4 Jahren
Ursprung
Commit
319f05ff1c
3 geänderte Dateien mit 30 neuen und 17 gelöschten Zeilen
  1. +12
    -10
      drafts/c.c
  2. +10
    -7
      test2.txt
  3. +8
    -0
      test3.txt

+ 12
- 10
drafts/c.c Datei anzeigen

@ -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));

+ 10
- 7
test2.txt Datei anzeigen

@ -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()

+ 8
- 0
test3.txt Datei anzeigen

@ -0,0 +1,8 @@
fun f(n) {
if (n < 2) {
return 1
} else {
return 1 + f(n-1) + f(n-2)
}
}
f(27)

Laden…
Abbrechen
Speichern