-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyntax-smoke-screen.language
315 lines (261 loc) · 4.84 KB
/
syntax-smoke-screen.language
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
//
// type declaration
//
// alias primitive
type pepe = i8
// alias nother type
type pepe2 = pepe
// aggregate type
type pepe3 = pepe | pepe2
type pepe4 = i8 | i16 | pepe
type pepe5 = i8 | i16 | pepe | i8[]
// TODO is this useful ?
// empty struct declaration
type pepe2 = struct {}
// one propery struct declaration
type onefloat = struct {
float x
}
// struct extension / implementation
type z = struct extends y {
}
type z = struct extends x extends y {
}
type z = struct implements x extends y {
}
type z = struct extends x implements y {
}
type z = struct implements x implements y {
}
// interface declaration
type i = interface {
float x
}
type i = interface {
float p1
self p2
any p3
function a() self
function b() any
function c(self a) self
function d(any a) any
}
type i<$t> = interface {
$t a
function d($t a) any
function d(wrap<$t> a) any
function d(ref<$t> a) any
}
// ¡
type point2 = struct {
float a
float b
float[] c
i8? f
float<i8> d
float<i8[]> e
hoist float<i8[], pepe> f
float<i8[], pepe[]> f
float<i8[], readonly pepe[]> f
float<i8?> f
// sematic-error
float<xx[]> f
i8 a = 10
string b = "pepe"
ref<string> c = ""
ref<string> d = 10
ref<string> d = 10.0
ref<string> e = true
ref<string> f = false
ref<string> g = null
alias g f
get size length {
return this.f
}
set length(size value) {
this.f = value
}
new() {}
clone(point2<$t> other) {}
delete() {}
operator . () {}
operator . (i8 a) {}
operator / () {
return x
}
}
// templated struct
type templated_struct_1<$t> = struct {
$t x
}
type templated_struct_2<$t, $t2> = struct {
$t x
$t2 y
}
type templated_struct_3<$t1, $t2, $t3> = struct {
$t1 x
$t2 y
$t3 z
}
// templated struct that extends templated struct
type templated_struct_ex_1<$t> = struct extends templated_struct_1<$t> {
$t x
}
type templated_struct_ex_2<$t, $t2> = struct extends templated_struct_2<$t, $t2> {
$t x
$t2 y
}
type templated_struct_ex_3<$t1, $t2, $t3> = struct extends templated_struct_3<$t1, $t2, $t3> {
$t1 x
$t2 y
$t3 z
}
// templated interface
type templated_interface_1<$t> = interface {
$t x
}
type templated_interface_2<$t, $t2> = interface {
$t x
$t2 y
}
type templated_interface_3<$t1, $t2, $t3> = interface {
$t1 x
$t2 y
$t3 z
}
// double implements, empty interfaces
type x = interface {}
type y = interface {}
type xy = struct implements x implements y {}
//
// functions
//
// empty function
function f0() {}
// one parameter
function f1(i8 a) {
return a
}
// multiple parameters
function f2(i8 a, i8 b) {
return a + b
}
// complex parameter types
function fc3(pepe<i8> a, pepe[] b, pepe? c) {
}
// pure function
pure function pfc3(pepe<i8> a, pepe[] b, pepe? c) {
}
// variables
/*
this is the main file...
package var i8 z
package var z2 = 10
package const xxx<i8> z4 = 10
*/
global var i8 z
global var xxx<i8> z4 = 10
global const xxx<i8> z4 = 10
// operator
function check_operators() {
1 + 2 * 3 / 4
1 | 2 & 3 ^ 4 || 5 && 6 % 1 << 1 >> 1 == 1 != 1
1 |= 1
1 &= 1 %= 1 *= 1 /= 1 -= 1 += 1
++1
--1
1++
1--
a = 1
obj.access = 1
obj[1] = 1
obj(100)
obj(pepe.martin, 10.0, null, false, 1, "", obj?.safe, obj!.safe)
obj(pepe!["martin"], pepe?["martin"])
// loop
loop 10 {}
// TODO range! loop 1..10 {}
loop value {}
loop value.value() {}
loop value?.value() {}
loop key in iterable {}
loop key, value in iterable {}
outterloop: loop i in 10 {
loop j in 10 {
if j < 10 {
// this is clearer and allowed :)
continue outterloop
}
}
}
// foreach
foreach value?.value.value() {}
foreach key in iterable {}
foreach key, value in iterable {}
outterloop2: foreach key, value in iterable {
continue
restart
break
continue 10
continue 2
restart 2
break 2
continue outterloop2
restart outterloop2
break outterloop2
}
a = b + 0xFF
a = b + 0b0101
a = b + 0o0707
a = b + 0
a = b + 1
a = b + 10
a = b + 1000
a = b + 10001
a = b + 123456789
}
function defer_1() {
defer print("ok")
}
function defer_1(itn a) {
defer print(a)
++a
defer print(a)
++a
return a
}
type position = enum {
FIRST
SECOND
THRID
}
type enconding = enum {
BIN = "Binary"
ASCII = "Ascii"
}
type masky = mask {
BIN = 0x00001
ASCII = 0b10101001
}
function integers() {
const decimal_int = 98222
const hex_int = 0xff
const another_hex_int = 0xFF
const octal_int = 0o755
const binary_int = 0b11110000
const one_billion = 1_000_000_000
const binary_mask = 0b1_1111_1111
const permissions = 0o7_5_5
const big_address = 0xFF80_0000_0000_0000
}
function floating() {
const floating_point = 123.0E+77
const another_float = 123.0
const yet_another = 123.0e+77
//const hex_floating_point = 0x103.70p-5
//const another_hex_float = 0x103.70
//const yet_another_hex_float = 0x103.70P-5
const lightspeed = 299_792_458.000_000
const nanosecond = 0.000_000_001
//const more_hex = 0x1234_5678.9ABC_CDEFp-10
}