-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.dte
More file actions
203 lines (138 loc) · 3.81 KB
/
example.dte
File metadata and controls
203 lines (138 loc) · 3.81 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
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
//this is a comment
/*
this is a very big comment
*/
func() = {}
func(arg) = {}
func() = {
return = 1 //return to stack
}
func1() = {}
func2() = {}
func3() = {}
func4() = {}
func5() = {}
func() = {
goto_1:
[1, goto_1, 2]func1() //jumps [1, goto_1, 2], @@goto_1 = 0 in func
func2()
[1, goto_1]func3() //jumps [1, goto_1], @@goto_1 = 0 in func
goto_2:
func4()
[1, goto_2]func5() //jumps [1, goto_2], @@goto_2 = 4 in func
}
/*
unit: contains information
table: put in order information
value types: nil, int[3], float[3], cstr, void*(shared), table*(shared), unit*(shared)
value definition:
val = nil //simple, val is nil now
val = 1 //simple, val is int[3] now: [[1, 0, 0]]
val = [[1, 2, 3]] //more complex, val is int[3]: [[1, 2, 3]]
val = [[1, 2, 3, 4]] //invalid, there is no int[4]! (warn and use first possible values)
val = [[1, 2.0, "3"]] //invalid, there is no [[int, float, cstr]] (error)
val = 1.5 //simple, val is float[3] now: [[1.5, 0.0, 0.0]]
val = [[1.5, 3.0, 4.5]] //more complex, val is float[3]:[[1.5, 3.0, 4.5]]
val = "string" //simple, val is cstr now
table definition:
val = {} //empty table
let`s create table with int[3] at index 0 and int float[3] at index 1
val = {
[[1, 2, 3]],
[[1.5, 3.0, 4.5]]
}
we can also create table by simple definition
same as previos, but init only first value in int[3]/float[3]
val = {
1,
1.5
}
table is [[1, 0, 0]], [[1.5, 0.0, 0.0]]
let`s create reference to val: now it`s unit*(shared)
val = &val
if we don`t set enough value they will be set to 0
val = [[1, 2]] -> [[1, 2, 0]]
*/
/*
access to data
table["name"] or table[index]
unit[index] //allowed only for int[3], float[3]
*/
/*
@this_is_macro = "str value" //simple macro definition
func(@this_is_macro) = {} //it will unwrap to `func("str value")`
@macro_func(val) = func(val) //simple macro definition with args
@macro_func(5) = {} //it will unwrap to `func(5) = {}`
@complex_macro = { //complex macro definition
"first value",
"secode value"
}
func(@complex_macro) = {} //it will unwrap to `func("first value", "secode value") = {}`
@complex_macro_func(val) = { //complex macro definition with args
other_val = val
}
func() = { @complex_macro_func(5) } //it will unwrap to `func() = { other_val = 5 }`
*/
/*
special symbols:
, - separate values
# - get size
@ - macro start
= - set definition
[[ - complex value start
]] - complex value end
{ - complex definition start
} - complex definition end
[ - getting access start
] - getting access end
& - get reference
*/
/*
reserved words:
nil - no data
*/
//OTDATED
other_val = nil
@complex_macro_func(4) //will unwrap to "other_val = 4"
my_int = 5 //unit
my_float = 0.5 //unit
my_array = { //table with noname units
1, 2.0f, 3, 4, 5
}
my_string = "ABC" //unit
my_string = @this_is_macro
this_is_empty_table = {}
this_is_table = { a = 5 }
this_is_a = this_is_table["a"]
this_is_a = this_is_table[0]
my_float = 5 //now int (???)
my_function(a, b) = {
return a > b
}
a = my_function
a = a(5, 4)
this_is_empty_table["str_name"] = my_function
this_is_empty_table["str_name"](5,4)
a = #this_is_empty_table //will output 1
this_is_empty_table[a] = 5 //will add/set 5 at index a [begin;end], otherwise error
var_module = import("filename")
var_other_module = import(my_string) //allow loading name-formed module
a = var_module["sin"](a)
//func(...)??? use arg as Lua?
//c/c++ func: print
print("hello world!")
a = 5 //a is 5
a = &a //a is int* and points to 5
//a is [int, int, int] value
a = 5 //reset type to int
a[1] = 10 //now it`s [5, 10, int]
//a = 5 will destroy table (if it is), a[0] = won`t
//same with float & void
//strings and pointers are large to store
//so they can fit only 1 time per instance
a = 5
a[3] = 5 //will turn [int, int, int] into table with 4 units
a = {
{ 1 2 3 }
1
} //a is now empty table