-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdefault-rules.lm
More file actions
78 lines (65 loc) · 2.8 KB
/
default-rules.lm
File metadata and controls
78 lines (65 loc) · 2.8 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
macro ( ('let x y) )
( (λ x . ()) y );
macro ('match t ps) (tail(
(let (uuid term) t)
(match-pats( (uuid term) ps (fail PatternMatchFailure_s) ))
));
macro ('match-pats( term () remainder )) (
remainder
);
macro ('match-pats( term (ps (lhs rhs)) remainder )) (
(match-pats(
term
ps
(if (match-pats-condition( term lhs )) rhs remainder)
))
);
macro ('match-pats-condition( term (:Variable: v) )) (
(tail( (let v term) (branchtrue()) ))
);
macro ('match-pats-condition( term (:Literal: l) )) (
(==( term l ))
);
macro ('match-pats-condition( term (:Tag: l lt) )) (
(==( (.0( term )) l ))
);
macro ('match-pats-condition( term ((:Tag: l lt) ( x1 )) )) (tail(
(let (uuid ok) Trueu8)
(if (==( (.0( term )) l )) () (set (uuid ok) Falseu8))
(if (match-pats-condition( (.1( (as term lt) )) x1 )) () (set (uuid ok) Falseu8))
(==( (uuid ok) Trueu8 ))
));
macro ('match-pats-condition( term ((:Tag: l lt) ( x2 x1 ) ))) (tail(
(let (uuid ok) Trueu8)
(if (==( (.0( term )) l )) () (set (uuid ok) Falseu8))
(if (match-pats-condition( (.1( (as term lt) )) x1 )) () (set (uuid ok) Falseu8))
(if (match-pats-condition( (.2( (as term lt) )) x2 )) () (set (uuid ok) Falseu8))
(==( (uuid ok) Trueu8 ))
));
macro ('match-pats-condition( term ((:Tag: l lt) ( x3 x2 x1 ) ))) (tail(
(let (uuid ok) Trueu8)
(if (==( (.0( term )) l )) () (set (uuid ok) Falseu8))
(if (match-pats-condition( (.1( (as term lt) )) x1 )) () (set (uuid ok) Falseu8))
(if (match-pats-condition( (.2( (as term lt) )) x2 )) () (set (uuid ok) Falseu8))
(if (match-pats-condition( (.3( (as term lt) )) x3 )) () (set (uuid ok) Falseu8))
(==( (uuid ok) Trueu8 ))
));
macro ('match-pats-condition( term ((:Tag: l lt) ( x4 x3 x2 x1 ) ))) (tail(
(let (uuid ok) Trueu8)
(if (==( (.0( term )) l )) () (set (uuid ok) Falseu8))
(if (match-pats-condition( (.1( (as term lt) )) x1 )) () (set (uuid ok) Falseu8))
(if (match-pats-condition( (.2( (as term lt) )) x2 )) () (set (uuid ok) Falseu8))
(if (match-pats-condition( (.3( (as term lt) )) x3 )) () (set (uuid ok) Falseu8))
(if (match-pats-condition( (.4( (as term lt) )) x4 )) () (set (uuid ok) Falseu8))
(==( (uuid ok) Trueu8 ))
));
macro ('match-pats-condition( term ((:Tag: l lt) ( x5 x4 x3 x2 x1 ) ))) (tail(
(let (uuid ok) Trueu8)
(if (==( (.0( term )) l )) () (set (uuid ok) Falseu8))
(if (match-pats-condition( (.1( (as term lt) )) x1 )) () (set (uuid ok) Falseu8))
(if (match-pats-condition( (.2( (as term lt) )) x2 )) () (set (uuid ok) Falseu8))
(if (match-pats-condition( (.3( (as term lt) )) x3 )) () (set (uuid ok) Falseu8))
(if (match-pats-condition( (.4( (as term lt) )) x4 )) () (set (uuid ok) Falseu8))
(if (match-pats-condition( (.5( (as term lt) )) x5 )) () (set (uuid ok) Falseu8))
(==( (uuid ok) Trueu8 ))
));