-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.jsonc
335 lines (279 loc) · 9.17 KB
/
template.jsonc
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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
/*
* Worldlang language template : Please contribute some languages
*
* To make language json:
* - write itms by comment descriptions
* - Delete comments
* - copy it into <languagename>.json
* - make directory <languagename> and algo copy it into directory
*
* These are loaded when engine parses the statement
* So if the language doesn't have the required syntax, just put _ in front of,
*/
{
// Language name
// ex: C++, Ruby, Lisp, JavaScript
"name": "Language name",
// Output file extension
// ex: cpp, js, rb
"ext": "",
// Output file extension - transpiled by 'import ...' statement
// ex: hpp, h, js
"h_ext": "",
// "line_end": ";"
// Enpp-every engine does not make newlines automaticly.
// If you want to write about javascript then please write ";" here
"line_end": "",
// "ident": "{{name}}",
// Identifiers except true and false
// This is need because languages like PHP and Perl
"ident": "{{name}}",
// true and false
// "true": "true",
// "false": "false",
"true": "",
"false": "",
"then": [
// External engine execution commands
// Runs sequentially
],
"bracket": {
// Opening and closing blocks
// "block_open": "{",
// "block_close": "}",
// to open blocks in the language
"block_open": "",
"block_close": "",
// Opening and closing values
// "value_open": "(",
// "value_close": ")",
"value_open": "",
"value_close": "",
// This means how [1..10] can be compiled
// if "[", "]", [1..3] will compiled as [1, 2, 3,]
"dotarray_open": "",
"dotarray_close": "",
// Opening and closing Initializer lists
// "list_open": "{",
// "list_close": "}"
"list_open": "",
"list_close": ""
},
"operator": {
// Commas of the language
// "commas" : ",",
"commas" : "",
// Example for C++
// "pointer" : "(&({{exp}}))",
// "de_pointer" : "(*({{exp}}))",
"pointer" : "",
"de_pointer" : "",
// async, await operators
// Example for javascript
// "async" : "(async {{exp}})",
// "async" : "(await {{exp}})",
"async" : "",
"await" : "",
// tenary operators
// "tenary": "({{condition}} ? {{l}} : {{r}})",
"tenary": "",
// These binary operators are designed to cover S-exp
// Write the format of expressions
// assign operators (a=b)
// "assign": "({{l}} = {{r}})",
"assign": "",
// + - operators (a=b)
// "plus" : "({{l}} + {{r}})",
// "minus" : "({{l}} - {{r}})",
"plus": "",
"minus": "",
// logical operators
// "bitor": "({{l}} | {{r}})",
// "or": "({{l}} || {{r}})",
// "bitand": "({{l}} & {{r}})",
// "and": "({{l}} && {{r}})",
"bitor": "",
"or": "",
"bitand": "",
"and": "",
// equality operators
// "eq": "({{l}} == {{r}})",
// "neq": "({{l}} != {{r}})",
"eq": "",
"neq": "",
// pair operators
// "pair": "{ {{l}} : {{r}} }",
"pair": "",
// properties
// "property": "{{object}}.{{name}}",
"property": "",
// context access
// "context": "{{context}}::{{member}}",
"context": "",
// array index
// "index": "{{exp}}[ {{at}} ]",
"index": "",
// Else...
// multiplication, divide, size comparison comes here
// todo: specialize it after
// "else": "({{l}} {{operator}} {{r}})"
"else": ""
},
"blocks": {
// If .. else if .. else blocks
// "if": "if ({{exp}}) { {{block}} }",
// "else_if": "else if ({{exp}}) { {{block}} }",
// "else": "else { {{block}} }",
"if": "",
"else_if": "",
"else": "",
// while blocks
// "while": "while ({{exp}}) { {{block}} }",
"while": "",
// repeat blocks
// "repeat": "for (int {{var}} = 0; {{var}}<{{time}}; {{var}}++) { {{block}} }",
// {{var}} will given as random token with alphabets and numbers
"repeat": "",
// repeat blocks
// "foreach": "for ({{var}} : {{collection}}) { {{block}} }"
// {{var}} will given as "iter_vars" format below
"foreach": ""
},
"calls": {
// Function calls
// Basic calls
// "call": "{{method}}({{args}})",
"call": "",
// Calls if arguments are already wrapped as brackets
// "call_wrapped": "{{method}}{{args}}",
// If you can't understand, just fill it as example
"call_wrapped": "",
// Object method calls
// "method_call" : "{{object}}.{{call}}"
// {{call}} will given as the format "call" above
"method_call" : ""
},
"types": {
// Types
// Deduce type
// "deduce_type" : "var"
"deduce_type": "",
// Constant types
// "constant" : "final"
"constant": "",
// void types
// "void_type": "void"
"void_type": "",
// integer types
// "integer": "Number"
"integer": ""
},
// blocked lambdas
// "lambda_blocks": "({{args}})=>{ {{block}} }",
"lambda_blocks": "",
// to V [prep. arg[, arg2...]] lambdas
// "to_lambdas": "(...pp) => {{function}}({{args}} ...pp)",
"to_lambdas": "",
// lambdas
// "lambdas": "({{args}}) => ({{exp}})",
"lambdas": "",
// return statements
// "returns": "return ({{exp}});",
"returns": "",
// namespaces
// "namespaces": "namespace {{name}} { {{block}} }",
"namespaces": "",
// Variable declarition in foreach statements
// {{type}} may be "deduce_type"
// "iter_vars": "{{type}} {{exp}}",
"iter_vars": "",
// Function argument format
// {{type}} may also be "deduce_type"
// "arg_vars": "{{type}} {{name}}",
"arg_vars": "",
// Header guards for C/C++
// "header_guard": "#ifndef __{{token}}_H__\n#define __{{token}}_H__\n{{contents}}\n#endif",
// just write "{{contents}}" if unnecessary
"header_guard": "",
"funcs": {
// Functions
// Basic functions
// "functions": "{{type}} {{name}}({{args}}) { {{block}} }",
"functions": "",
// Class Object constructors
// "constructor": "{{class}}({{args}}){ {{block}} }",
"constructor": "",
// Code entrypoint
// "entry": "int main(){ {{block}} }"
"entry": ""
},
"assigns": {
"reference": {
// Constant reference variables
// "const": "const {{type}}& {{name}} = {{ref}}",
"const": "",
// Mutable reference variables
// "let": "{{type}}& {{name}} = {{ref}}"
"let": "",
// Fill something same as "let"
// "make": "{{type}}& {{name}} = {{ref}}",
"make": ""
},
"copy": {
// Constant copy-initialized variable
// "const": "const {{type}} {{name}} = {{copy}}",
"const": "",
// Mutable copy-initialized variable (In heap)
// "make": "{{type}}* {{name}} = new {{type}}({{copy}})",
"make": "",
// Mutable copy-initialized variable (In stack)
// "let": "{{type}} {{name}} = {{copy}}"
"let": ""
},
"construct": {
// Constant Constructor-initialized variable
// "const": "const {{type}} {{name}}({{args}})",
"const": "",
// Mutable Constructor-initialized variable (In heap)
// "make": "{{type}}* {name} = new {type}({args})",
"make": "",
// Mutable Constructor-initialized variable
// "let": "{{type}} {{name}}({{args}})"
"let": ""
}
},
"imports": {
// Library import
// standard library, installed library...etc
// "library": "#include <{{path}}.hpp>\n",
"library": "",
// worldlib standard library
// please read stdlib_proto.md to write standard library
// "stdlib": "#include \"worldlib.hpp\"\n",
"stdlib": "",
// importing code files
// "import": "#include \"{{path}}\"\n",
"import": "",
// Where to copy worldlib at
// "targetstdlibpath": "worldlib.hpp",
"targetstdlibpath": "",
"stdlibpath": "libs/worldlib.SOME_EXT"
},
"classes": {
// class doesn't interit another class(es)
// "class": "class {{name}}{ {{block}} };"
"class": "",
// class interits another class(es)
// "inherit": "class {{name}} : {{super}} { {{block}} };"
"inherit": ""
},
"access": {
// method/property access keywords
// "protected": "protected",
"protected": "",
// "private": "private",
"private": "",
// "public": "public"
"public": ""
}
}