mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
Merge branch 'hw14' of github.com:dboulytchev/compiler-workout-private into hw14
This commit is contained in:
commit
975126e2bd
3 changed files with 73 additions and 0 deletions
9
regression/x86only/orig/test002.log
Normal file
9
regression/x86only/orig/test002.log
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
1
|
||||||
|
1
|
||||||
|
1
|
||||||
|
1
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
100
|
||||||
|
`cons (3, `cons (2, `cons (1, `cons (6, `cons (5, `cons (4, `cons (3, `cons (2, `cons (1, `nil)))))))))
|
||||||
63
regression/x86only/test002.expr
Normal file
63
regression/x86only/test002.expr
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
fun collect_ints_acc (v, tail) local i {
|
||||||
|
case v of
|
||||||
|
a@#unboxed -> return `cons (a, tail)
|
||||||
|
| #string -> return tail
|
||||||
|
| _ ->
|
||||||
|
for i := 0, i < v.length, i := i + 1 do
|
||||||
|
tail := collect_ints_acc (v[i], tail)
|
||||||
|
od;
|
||||||
|
return tail
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
fun collect_ints (v) {
|
||||||
|
return collect_ints_acc (v, `nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1 of
|
||||||
|
5 -> write (5)
|
||||||
|
| 4 -> write (4)
|
||||||
|
| 3 -> write (3)
|
||||||
|
| 2 -> write (2)
|
||||||
|
| 1 -> write (1)
|
||||||
|
| 0 -> write (0)
|
||||||
|
esac;
|
||||||
|
|
||||||
|
case 1 of
|
||||||
|
a@5 -> write (a)
|
||||||
|
| a@4 -> write (a)
|
||||||
|
| a@3 -> write (a)
|
||||||
|
| a@2 -> write (a)
|
||||||
|
| a@1 -> write (a)
|
||||||
|
| a@0 -> write (a)
|
||||||
|
esac;
|
||||||
|
|
||||||
|
case `a (1, 2, 3) of
|
||||||
|
`a (1, 3, 5) -> write (0)
|
||||||
|
| `a (3, 4, 5) -> write (0)
|
||||||
|
| `a (1, 2, 3) -> write (1)
|
||||||
|
| `a (6, 7, 8) -> write (0)
|
||||||
|
esac;
|
||||||
|
|
||||||
|
case "abc" of
|
||||||
|
"def" -> write (0)
|
||||||
|
| "ab" -> write (0)
|
||||||
|
| "abc" -> write (1)
|
||||||
|
| "" -> write (0)
|
||||||
|
esac;
|
||||||
|
|
||||||
|
case [1, 2, 3] of
|
||||||
|
[] -> write (0)
|
||||||
|
| [a, b] -> write (0)
|
||||||
|
| [a, b, c] -> write (a); write (b); write (c)
|
||||||
|
| [_, _, _] -> write (0)
|
||||||
|
esac;
|
||||||
|
|
||||||
|
case [1, 2, 3] of
|
||||||
|
[] -> write (0)
|
||||||
|
| [a, b] -> write (0)
|
||||||
|
| [_, _, _] -> write (100)
|
||||||
|
| [a, b, c] -> write (a); write (b); write (c)
|
||||||
|
esac;
|
||||||
|
|
||||||
|
printf ("%s\n", collect_ints ([1, 2, 3, [4, 5, 6, `cons (1, 2, 3)]]).string)
|
||||||
1
regression/x86only/test002.input
Normal file
1
regression/x86only/test002.input
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
0
|
||||||
Loading…
Add table
Add a link
Reference in a new issue