@@ -16,16 +16,18 @@ data_type{index_type} m;
16
16
17
17
// ////////////////////////// BESSER:
18
18
MyLang -> C++
19
- int [16 ] -> array<int ,16 >
20
- int [*] -> int * // pointer that can hold an array
21
19
int * -> int * // pointer to a single element
20
+ int [*] -> int * // pointer that can hold an array
21
+ int [16 ] -> array<int ,16 >
22
22
int [] -> vector<int >
23
23
int [](16 ) -> vector<int >(16 )
24
24
int [](16 ,99 ) -> vector<int >(16 ,99 )
25
25
int [init:16 ] -> vector<int >(16 )
26
- int [reserve:16 ] -> vector<int > then reserve (16 )
27
- int[>16] -> vector<int> then reserve(16 )
28
- int[16+] -> vector<int> then reserve(16 )
26
+ int [reserve:16 ] -> vector<int >; v.reserve(16 )
27
+ int [>16 ] -> vector<int >; v.reserve(16 )
28
+ int [16 +] -> vector<int >; v.reserve(16 )
29
+
30
+ // TODO: find a way to make arrays that can only be indexed by specified enums
29
31
30
32
// compatibility, this from C/C++ is possible
31
33
int @[] -> int [];
@@ -47,6 +49,15 @@ string{}(16) -> unordered_set<string>(16)
47
49
string{<} -> set<string>
48
50
string{>} -> set<string,greater>
49
51
52
+ string[set] -> unordered_set<string>
53
+ string[set,16 ] -> unordered_set<string> // reserve 16 if possible
54
+ string[set,<] -> set<string>
55
+ string[set,>] -> set<string,greater>
56
+ string[<set] -> set<string>
57
+ string[>set] -> set<string,greater>
58
+ string[<+set] -> set<string>
59
+ string[>set] -> set<string,greater>
60
+
50
61
string[deque] -> deque<string>
51
62
string[heap] -> priority_queue<string>
52
63
string[list] -> list<string>
@@ -106,14 +117,40 @@ class X {
106
117
[conversion(auto ,default ,implicit,explicit )]
107
118
ctor ( OTHER other) {...}
108
119
109
- // rule file myll::magic
110
- [
120
+ string[int ] -> unordered_map<int ,string>
121
+ string[int ,hasher](16 ) -> unordered_map<int ,string,hasher<int >>(16 )
122
+ string[int ,<] -> map<int ,string,less<int >>
123
+ string[int ,>] -> map<int ,string,greater<int >>
124
+ string[int ,+](16 ) -> unordered_multimap<int ,string>(16 )
125
+ string[int ,<+](16 ) -> multimap<int ,string>(16 )
126
+
127
+ string{} -> unordered_set<string>
128
+ string{}(16 ) -> unordered_set<string>(16 )
129
+ string{<} -> set<string>
130
+ string{>} -> set<string,greater>
131
+
132
+ string[set] -> unordered_set<string>
133
+ string[set,16 ] -> unordered_set<string> // reserve 16 is possible
134
+ string[set,<] -> set<string>
135
+ string[set,>] -> set<string,greater>
136
+ string[<set] -> set<string>
137
+ string[>set] -> set<string,greater>
138
+ string[<+set] -> set<string>
139
+ string[>set] -> set<string,greater>
140
+
141
+ string[deque] -> deque<string>
142
+ string[heap] -> priority_queue<string>
143
+ string[list] -> list<string>
144
+ string[stack] -> stack<string>
145
+
146
+ [ // rule file myll::magic
111
147
magic_return_val=[ret,result],
112
148
magic_param_val=other,
113
149
magic_param_ref=other,
114
150
magic_param_ptr=that,
115
151
magic_uscore=true ,
116
152
magic_autoindex=true ,
153
+
117
154
convert_decl=true ,
118
155
default_on_semicolon=true ,
119
156
support_nullptr=warning,
@@ -122,18 +159,33 @@ struct_default=[pub,pod],
122
159
method_default=[instance],
123
160
func_default=[global,pure],
124
161
proc_default=[global],
125
- unique_pointer=std::unique_ptr,
126
- shared_pointer=std::shared_ptr,
127
- weak_pointer=std::weak_ptr,
128
- // static_array: type@[16], dynamic_array@[],
129
- static_array=std::array,
130
- dynamic_array=std::vector,
162
+
163
+ unique_pointer=std::unique_ptr<T>,
164
+ shared_pointer=std::shared_ptr<T>,
165
+ weak_pointer=std::weak_ptr<T>,
166
+
167
+ // static_array: T@[16], dynamic_array: T@[],
168
+ static_array=std::array<T,S>,
169
+ dynamic_array=std::vector<T>,
170
+ ordered_dict=std::map<K,V>, // sorted_dict
171
+ unordered_dict=std::unordered_map<K,V>,
172
+ ordered_set=std::set<T>,
173
+ unordered_set=std::unordered_set<T>,
174
+ ordered_multidict=std::multimap<K,V>,
175
+ unordered_multidict=std::unordered_multimap<K,V>,
176
+ ordered_multiset=std::multiset<T>,
177
+ unordered_multiset=std::unordered_multiset<T>,
178
+
179
+ static_cast =static_cast <T>,
180
+ dynamic_cast =dynamic_cast <T>,
181
+ const_cast =const_cast <T>,
182
+ reinterpret_cast =reinterpret_cast <T>,
183
+ bit_cast=std::bit_cast<T>,
131
184
narrowing_conversion=false , // also set related C++ compiler warnings as errors to be sure
132
185
]
133
186
class rule ::myll::magic {}
134
187
135
- // rule file myll::retro
136
- [
188
+ [ // rule file myll::retro
137
189
magic_return_val=[],
138
190
magic_param_val=[],
139
191
magic_param_ref=[],
@@ -148,13 +200,32 @@ struct_default=[pub],
148
200
method_default=[],
149
201
func_default=[],
150
202
proc_default=[],
151
- unique_pointer=std::unique_ptr,
152
- shared_pointer=std::shared_ptr,
153
- weak_pointer=std::weak_ptr,
203
+ unique_pointer=std::unique_ptr<T>,
204
+ shared_pointer=std::shared_ptr<T>,
205
+ weak_pointer=std::weak_ptr<T>,
206
+ static_array=false ,
207
+ dynamic_array=false ,
208
+ static_cast =static_cast <T>,
209
+ dynamic_cast =dynamic_cast <T>,
210
+ const_cast =const_cast <T>,
211
+ reinterpret_cast =reinterpret_cast <T>,
212
+ bit_cast=std::bit_cast<T>,
154
213
narrowing_conversion=true ,
155
214
]
156
215
class rule ::myll::retro {}
157
216
217
+ [ // rule file myll::madness
218
+ unique_pointer=T*,
219
+ shared_pointer=T*,
220
+ weak_pointer=T*,
221
+ static_cast =((T)E),
222
+ dynamic_cast =((T)E),
223
+ const_cast =((T)E),
224
+ reinterpret_cast =((T)E),
225
+ bit_cast=((T)E),
226
+ ]
227
+ class rule ::myll::madness {}
228
+
158
229
159
230
[virtual =encouraged]
160
231
class Test
0 commit comments