forked from yetanotherflower/mm0
-
Notifications
You must be signed in to change notification settings - Fork 1
/
string.mmu
142 lines (124 loc) · 5.06 KB
/
string.mmu
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
(sort hex strict free)
(term x0 () (hex ()))
(term x1 () (hex ()))
(term x2 () (hex ()))
(term x3 () (hex ()))
(term x4 () (hex ()))
(term x5 () (hex ()))
(term x6 () (hex ()))
(term x7 () (hex ()))
(term x8 () (hex ()))
(term x9 () (hex ()))
(term xa () (hex ()))
(term xb () (hex ()))
(term xc () (hex ()))
(term xd () (hex ()))
(term xe () (hex ()))
(term xf () (hex ()))
(sort char strict free)
(term ch ((_ hex ()) (_ hex ())) (char ()))
(sort string strict free)
(term s0 () (string ()))
(term s1 ((_ char ())) (string ()))
(term sadd ((_ string ()) (_ string ())) (string ()))
(local def k ((h1 hex ()) (h2 hex ()) (r string ())) (string ()) ()
(sadd (s1 (ch h1 h2)) r))
(local def nl ((r string ())) (string ()) () (k (x0) (xa) r))
(local def __ ((r string ())) (string ()) () (k (x2) (x0) r))
(local def colon ((r string ())) (string ()) () (k (x3) (xa) r))
(local def semi ((r string ())) (string ()) () (k (x3) (xb) r))
(local def arrow ((r string ())) (string ()) () (k (x3) (xe) r))
(local def _0 ((r string ())) (string ()) () (k (x3) (x0) r))
(local def _1 ((r string ())) (string ()) () (k (x3) (x1) r))
(local def _2 ((r string ())) (string ()) () (k (x3) (x2) r))
(local def _3 ((r string ())) (string ()) () (k (x3) (x3) r))
(local def _4 ((r string ())) (string ()) () (k (x3) (x4) r))
(local def _5 ((r string ())) (string ()) () (k (x3) (x5) r))
(local def _6 ((r string ())) (string ()) () (k (x3) (x6) r))
(local def _7 ((r string ())) (string ()) () (k (x3) (x7) r))
(local def _8 ((r string ())) (string ()) () (k (x3) (x8) r))
(local def _9 ((r string ())) (string ()) () (k (x3) (x9) r))
(local def _a ((r string ())) (string ()) () (k (x6) (x1) r))
(local def _b ((r string ())) (string ()) () (k (x6) (x2) r))
(local def _c ((r string ())) (string ()) () (k (x6) (x3) r))
(local def _d ((r string ())) (string ()) () (k (x6) (x4) r))
(local def _e ((r string ())) (string ()) () (k (x6) (x5) r))
(local def _f ((r string ())) (string ()) () (k (x6) (x6) r))
(local def _g ((r string ())) (string ()) () (k (x6) (x7) r))
(local def _h ((r string ())) (string ()) () (k (x6) (x8) r))
(local def _i ((r string ())) (string ()) () (k (x6) (x9) r))
(local def _l ((r string ())) (string ()) () (k (x6) (xc) r))
(local def _m ((r string ())) (string ()) () (k (x6) (xd) r))
(local def _n ((r string ())) (string ()) () (k (x6) (xe) r))
(local def _o ((r string ())) (string ()) () (k (x6) (xf) r))
(local def _p ((r string ())) (string ()) () (k (x7) (x0) r))
(local def _q ((r string ())) (string ()) () (k (x7) (x1) r))
(local def _r ((r string ())) (string ()) () (k (x7) (x2) r))
(local def _s ((r string ())) (string ()) () (k (x7) (x3) r))
(local def _t ((r string ())) (string ()) () (k (x7) (x4) r))
(local def _u ((r string ())) (string ()) () (k (x7) (x5) r))
(local def _w ((r string ())) (string ()) () (k (x7) (x7) r))
(local def _x ((r string ())) (string ()) () (k (x7) (x8) r))
(local def csort ((s string ()) (r string ())) (string ()) ()
(sadd (_s (_t (_r (_i (_c (_t (__
(_f (_r (_e (_e (__ (_s (_o (_r (_t (__ s)))))))))))))))))
(semi (nl r))))
(local def cdecl ((c string ()) (t string ()) (s string ()) (r string ())) (string ()) ()
(sadd c (sadd (__ t) (sadd (colon (__ s)) (semi (nl r))))))
(local def sterm () (string ()) () (_t (_e (_r (_m (s0))))))
(local def sdef () (string ()) () (_d (_e (_f (s0)))))
(local def sinput () (string ()) () (_i (_n (_p (_u (_t (s0)))))))
(local def soutput () (string ()) () (_o (_u (_t (_p (_u (_t (s0))))))))
(local def shex () (string ()) () (_h (_e (_x (s0)))))
(local def schar () (string ()) () (_c (_h (_a (_r (s0))))))
(local def sstr () (string ()) () (_s (_t (_r (_i (_n (_g (s0))))))))
(local def sarrow ((a string ()) (r string ())) (string ()) ()
(sadd a (__ (arrow (__ r)))))
(local def cterm_hex ((n string ()) (r string ())) (string ()) ()
(cdecl (sterm) (_x n) (shex) r))
(local def shello () (string ()) () (_h (_e (_l (_l (_o (s0)))))))
(def input () (string ()) ()
(sadd
(csort (shex)
(cterm_hex (_0 (s0))
(cterm_hex (_1 (s0))
(cterm_hex (_2 (s0))
(cterm_hex (_3 (s0))
(cterm_hex (_4 (s0))
(cterm_hex (_5 (s0))
(cterm_hex (_6 (s0))
(cterm_hex (_7 (s0))
(cterm_hex (_8 (s0))
(cterm_hex (_9 (s0))
(cterm_hex (_a (s0))
(cterm_hex (_b (s0))
(cterm_hex (_c (s0))
(cterm_hex (_d (s0))
(cterm_hex (_e (s0))
(cterm_hex (_f (s0))
(nl (s0)))))))))))))))))))
(sadd
(csort (schar)
(cdecl (sterm) (_c (_h (s0))) (sarrow (shex) (sarrow (shex) (schar)))
(nl (s0))))
(sadd
(csort (sstr)
(cdecl (sterm) (_s (_0 (s0))) (sstr)
(cdecl (sterm) (_s (_1 (s0))) (sarrow (schar) (sstr))
(cdecl (sterm) (_s (_a (_d (_d (s0))))) (sarrow (sstr) (sarrow (sstr) (sstr)))
(nl (s0))))))
(sadd
(cdecl (sdef) (sinput) (sstr)
(cdecl (sinput) (sstr) (sinput)
(cdecl (soutput) (sstr) (sinput)
(nl (s0)))))
(sadd
(cdecl (sdef) (shello) (sstr)
(cdecl (soutput) (sstr) (shello)
(s0)))
(s0)))))))
(input string)
(output string)
(def hello () (string ()) ()
(sadd (shello) (__ (_w (_o (_r (_l (_d (s0)))))))))
(output string)