forked from renaudbedard/MuteGrammar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.mute
138 lines (115 loc) · 2.48 KB
/
demo.mute
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
#####################
# assignation tests #
#####################
# numerical
num_add[1+2]
num_neg[-25]
num_sub[5-2]
num_div[12/4]
num_mul[3*4]
num_par[(4+5+11)/10]
num_rnd[1~10]
num_rnd_2[(1~10)~20]
# references
ref_a[inA:"hello"]
ref_b[inB:ref_a]
ref_c[ref_b.inB.inA]
ref_a[inA:"goodbye"]
ref_num[2]
ref_num_2[ref_num + 3]
ref_slf[0]
ref_slf[$+1]
ref_arr[1, 2, 3]
ref_arr[2: 5]
ref_gap[1:1, 3:5]
ref_idx[ref_arr.2]
ref_clx[inner: ref_arr]
ref_mix[ref_clx.inner.2]
# strings
str_exp[("hello @", "world")]
str_mle[("hello @ @", "my", "darling")]
str_wld["world"]
str_exv[("hello @", str_wld)]
str_cat["hello" & " " & "world"]
str_sub["extraordinary" | 5]
# arrays
arr_seq[1, 2, 3]
arr_seq_2[4, 5, 6]
arr_cat[arr_seq & arr_seq_2]
arr_trm[arr_cat | 2]
arr_cpy[arr_seq]
arr_2d[arr_seq, arr_seq_2]
###################
# operation tests #
###################
# stray
{"stray operation"}
# references
[5]{"self reference : @", $}
{"external reference : @", str_exp}
{ope_ass["success!"]}
{"assignment within operation : @", ope_ass}
{ope_ass[str_wld]}
{"dereferencing for assignment within operation : @", ope_ass}
ope_nam[10]{"named self-referencing operation, current value = @", $}
ope_nam[$+1]
# arrays
ope_arr[1, 2, 3]{"array : @", $}
# carry-over
ope_car_a[1]{"operation carry-over contains : @", $}
ope_car_b[ope_car_a]
ope_car_b[2]
# overwrite
ope_ovw{"original operation"}
ope_ovw{"overwritten operation"}
###################
# condition tests #
###################
# existence
cnd_exi($){"cnd_exi exists and has a value : @", $}
cnd_exi[1]
# numerical
cnd_eq($=1){"1 = @", $}
cnd_eq[2]
cnd_eq[1]
cnd_eq[0]
cnd_gt($>1){"@ > 1", $}
cnd_gt[2]
cnd_gt[1]
cnd_gt[0]
cnd_lt($<1){"@ < 1", $}
cnd_lt[0]
cnd_lt[1]
cnd_lt[2]
cnd_lte($<=1){"@ <= 1", $}
cnd_lte[2]
cnd_lte[1]
cnd_lte[0]
cnd_gte($>=1){"@ >= 1", $}
cnd_gte[0]
cnd_gte[1]
cnd_gte[2]
# strings
cnd_seq($ = "hello"){"hello = @", $}
cnd_seq["world"]
cnd_seq["hello"]
# arrays
cnd_arr($=arr_seq){"@ = @", $, arr_seq}
cnd_arr[1, 2]
cnd_arr[1, 2, 3, 4]
cnd_arr[arr_seq]
# references
cnd_ref($.inner = arr_seq.2){"@ = @", $, arr_seq.2}
cnd_ref[1]
cnd_ref[2]
# mixed types
cnd_mix["hello"]($=1){"this shouldn't happen : @ = @", $, 1}
# carry-over
cnd_car_a($){"carried over existence predicate, value is : @", $}
cnd_car_b[cnd_car_a]
cnd_car_b[1]
# overwrite
cnd_ovw($=1){"should be 2 : @", $}
cnd_ovw($=2)
cnd_ovw[1]
cnd_ovw[2]