This repository has been archived by the owner on Jul 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
awesome.ft
237 lines (158 loc) · 2.83 KB
/
awesome.ft
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/*
Hello! This is the awesome program of DRIFT.
*/
/*
Keyword:
def ret for aop
if ef nf new
out go mod use
12 items.
*/
/*
Object:
1. int
2. float
3. char
4. string
5. bool
6. array
7. tuple
8. map
9. enum
10.function
11.whole
12.module
*/
/*
Define name:
def <K> <T> = <E>
In drift, use the `def` keyword to define any type of name.
*/
def x int = 30
def y []int = [4, 5, 6]
def Color
RED
PINK
NONE
def Foo
def () show
putl("CALL")
putl(x, y, Color, Foo, 1 == Color.PINK)
/*
Control follow:
1.IF JUMP
if <E>
<B>
[ef <E>]..
<B>
[nf]
<B>
2.AOP LOOP
aop <E> | ->
<B>
3.FOR LOOP
for <E>; <E>; <E>
<B>
*/
def x int = 10
if x > -1 & x != 0
putl("OK")
if x == 5
putl("A")
ef x == 8
putl("B")
ef x == 10
putl("C")
nf
putl("P")
aop x > 0
if x % 2 == 0
put(x)
x -= 2
for def i float = 8.88; i > 0; i -= 0.01
go i <= 7 /* continue */
if i <= 8
out -> /* break */
nf
put(i)
/*
Loop control:
out ->
out <E>
go ->
go <E>
*/
def x []int = [1, 2, 3, 4, 5, 6, 7, 8]
def y ()string = ("OK", "NO", "PP")
def z {}<int, string> = {3: "A", 5: "K", 8: "L"}
putl(x, y, z)
putl(x[0], y.1, z[5])
/*
Function:
def <K>(<E>..) | -> <E>
<B>
*/
def (x, y int, z string) foo -> int
if len(z) != 0
putl(z)
ret (x + y) * 2
def (a, b int) add -> int
ret a + b
def (x |int, int| -> int, a, b int) sum -> int
ret x(a, b) + x(a, b)
def () set -> |int|
ret def (x int) foo
puts(x * 2)
set()(8)
def (x int) bar -> |int, int| -> []int
putl("x = ", x)
ret def (a, b int) -> []int /* ANONYMOUSE */
ret [
a,
b,
a + b,
a - b,
a * b,
a / b
]
put(
foo(2, 3, "p"), add(3, 1), sum(add, 4, 2), bar(12)(3, 4)
)
/*
Whole:
def <K>
<I>..
<M>..
*/
def Foo
def () *bar /* INTERFACE */
def (bool) *what -> bool
def x int
def y string = "HELLO!!"
def (x, y int) max -> int
if x > y
ret x
nf
ret y
putl(new Foo.max(34, 12), new Foo.x, new Foo.y)
def Kop
def () *more
def Oop <- Foo + Kop /* INHERIT */
def () more
def () bar
putl(max(99, 98)) /* CALL INHERIT */
def (x bool) what -> bool
ret T
putl(new Oop.bar())
/*
Others:
*/
def x int = 30
def y []int = [1, 2, 3]
def z []float = []
putl("x = $x y = $y z = $z")
aop ->
puts("x = ", x)
out x == 20
x -= 1
putl() //