blob: 489206d33eb56562324160f5fb12d006f79b898a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
default Order inc
default Nat 'i
default Order 'o
default bool b
default forall 'a. list<'a> b
val forall 'a, 'b . ('a, 'b) -> 'b effect pure snd
val forall Type 'i, 'b. ('i, 'b) -> 'i effect pure fst
typedef int_list [name = "il"] = list<nat>
typedef reco = const struct forall 'i, 'a, 'b. { 'a['i] v; 'b w; }
typedef maybe = const union forall 'a. { Nne; 'a Sme; }
typedef creg = register bits [5:10] { 5 : h ; 6..7 : j}
let bool e = true
val forall Nat 'a, Nat 'b. bit['a:'b] sliced
let bit v = bitzero
let ( bit [ 32 ] ) v1 = 0b101
let ( bit [32] ) v2 = 0xABCDEF01
val forall Type 'a. 'a -> 'a effect pure identity
function forall Type 'a. 'a identity i = i
(*function unit ignore(x) = ()*)
(* scattered function definition and union definition *)
scattered typedef ast = const union
scattered function ast f
union ast member (bit, bit, bit) A
function clause f ( A (a,b,c) ) = C(a)
union ast member (bit, bit) B
function clause f ( B (a,b) ) = C(a)
union ast member bit C
function clause f ( C (a) ) = C(a)
end ast
end f
function unit a (bit) b = if identity(b) then (identity()) else ()
function bit sw s = switch s { case 0 -> bitzero }
typedef colors = enumerate { red; green; blue }
let colors rgb = red
function bit enu (red) = 0
function bit main _ = {ignore(sw(0)); ignore((nat) v2); ignore(enu(0)); v1[0] }
|