mystic-yard 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,23 @@
1
+ const rules = require("./rules");
2
+
3
+ function parser(tokens) {
4
+ let output = "";
5
+
6
+ for (let token of tokens) {
7
+ const rule = rules.find(
8
+ r => r.from.toLowerCase() === token.toLowerCase()
9
+ );
10
+
11
+ if (rule) {
12
+ output += rule.to;
13
+ } else {
14
+ output += token;
15
+ }
16
+
17
+ output += " ";
18
+ }
19
+
20
+ return output.trim();
21
+ }
22
+
23
+ module.exports = parser;
@@ -0,0 +1,17 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const config = require("../config");
4
+
5
+ function readFile(fileName) {
6
+ const filePath = path.join(
7
+ process.cwd(),
8
+ config.sourceFolder,
9
+ fileName
10
+ );
11
+
12
+ const code = fs.readFileSync(filePath, "utf8");
13
+
14
+ return code;
15
+ }
16
+
17
+ module.exports = readFile;
@@ -0,0 +1,552 @@
1
+ const rules = [
2
+ {
3
+ from: "c",
4
+ to: "const"
5
+ },
6
+ {
7
+ from: "f",
8
+ to: "function"
9
+ },
10
+ {
11
+ from: "cnl",
12
+ to: "console"
13
+ },
14
+ {
15
+ from: "lg",
16
+ to: "log"
17
+ },
18
+ {
19
+ from: 'aEL',
20
+ to: 'addEvantListener'
21
+ },
22
+ {
23
+ from: 'lg',
24
+ to: 'log'
25
+ },
26
+ {
27
+ from: 'sellect',
28
+ to: 'querySellector'
29
+ },
30
+ {
31
+ from: 'sellectAll',
32
+ to: 'querySellectorAll'
33
+ },
34
+ {
35
+ from: 'l',
36
+ to: 'let'
37
+ },
38
+ {
39
+ from: 'syl',
40
+ to: 'style'
41
+ },
42
+ {
43
+ from: 'gt',
44
+ to: 'get'
45
+ },
46
+ {
47
+ from: 'brk',
48
+ to: 'break'
49
+ },
50
+ {
51
+ from: 'sth',
52
+ to: 'switch'
53
+ },
54
+ {
55
+ from: 'inr',
56
+ to: 'inner'
57
+ },
58
+ {
59
+ from: 'err',
60
+ to: 'error'
61
+ },
62
+ {
63
+ from: 'wr',
64
+ to: 'warn'
65
+ },
66
+ {
67
+ from: 'cnt',
68
+ to: 'Content'
69
+ },
70
+ {
71
+ from: 'doc',
72
+ to: 'document'
73
+ },
74
+ {
75
+ from: 'add',
76
+ to: 'a'
77
+ },
78
+ {
79
+ from: 'elm',
80
+ to: 'element'
81
+ },
82
+ {
83
+ from: 'b',
84
+ to: 'by'
85
+ },
86
+ {
87
+ from: 'apnd',
88
+ to: 'append'
89
+ },
90
+ {
91
+ from: 'child',
92
+ to: 'cid'
93
+ },
94
+ {
95
+ from: 'wnd',
96
+ to: 'window'
97
+ },
98
+ {
99
+ from: 'r',
100
+ to: 're'
101
+ },
102
+ {
103
+ from: 'create',
104
+ to: 'cret'
105
+ },
106
+ {
107
+ from: 'mt',
108
+ to: 'math'
109
+ },
110
+ {
111
+ from: 'random',
112
+ to: 'ran'
113
+ },
114
+ {
115
+ from: 'cl',
116
+ to: 'ceil'
117
+ },
118
+ {
119
+ from: 'rou',
120
+ to: 'round'
121
+ },
122
+ {
123
+ from: 'ma',
124
+ to: 'max'
125
+ },
126
+ {
127
+ from: 'mi',
128
+ to: 'min'
129
+ },
130
+ {
131
+ from: 'flr',
132
+ to: 'floor'
133
+ },
134
+ {
135
+ from: 'ph',
136
+ to: 'push'
137
+ },
138
+ {
139
+ from: 'po',
140
+ to: 'pop'
141
+ },
142
+ {
143
+ from: 'sft',
144
+ to: 'shift'
145
+ },
146
+ {
147
+ from: 'un',
148
+ to: 'un'
149
+ },
150
+ {
151
+ from: 'slc',
152
+ to: 'slice'
153
+ },
154
+ {
155
+ from: 'map',
156
+ to: 'mp'
157
+ },
158
+ {
159
+ from: 'imp',
160
+ to: 'import'
161
+ },
162
+ {
163
+ from: 'exp',
164
+ to: 'export'
165
+ },
166
+ {
167
+ from: 'flt',
168
+ to: 'filter'
169
+ },
170
+ {
171
+ from: 'spc',
172
+ to: 'splice'
173
+ },
174
+ {
175
+ from: 'fn',
176
+ to: 'find'
177
+ },
178
+ {
179
+ from: 'inc',
180
+ to: 'include'
181
+ },
182
+ {
183
+ from: 'sr',
184
+ to: 'sort'
185
+ },
186
+ {
187
+ from: 'fo',
188
+ to: 'for'
189
+ },
190
+ {
191
+ from: 'eh',
192
+ to: 'each'
193
+ },
194
+ {
195
+ from: 'th',
196
+ to: 'then'
197
+ },
198
+ {
199
+ from: 'prm',
200
+ to: 'promise'
201
+ },
202
+ {
203
+ from: 'an',
204
+ to: 'aync'
205
+ },
206
+ {
207
+ from: 'cat',
208
+ to: 'catch'
209
+ },
210
+ {
211
+ from: 'ti',
212
+ to: 'this'
213
+ },
214
+ {
215
+ from: 'cls',
216
+ to: 'class'
217
+ },
218
+ {
219
+ from: 'ctt',
220
+ to: 'construction'
221
+ },
222
+ {
223
+ from: 'fal',
224
+ to: 'false'
225
+ },
226
+ {
227
+ from: 'etd',
228
+ to: 'extend'
229
+ },
230
+ {
231
+ from: 'sup',
232
+ to: 'super'
233
+ },
234
+ {
235
+ from: 'nw',
236
+ to: 'new'
237
+ },
238
+ {
239
+ from: 'fnl',
240
+ to: 'finaly'
241
+ },
242
+ {
243
+ from: 'thr',
244
+ to: 'throw'
245
+ },
246
+ {
247
+ from: 'ty',
248
+ to: 'try'
249
+ },
250
+ {
251
+ from: 'rtn',
252
+ to: 'return'
253
+ },
254
+ {
255
+ from: 'd',
256
+ to: 'do'
257
+ },
258
+ {
259
+ from: 'whl',
260
+ to: 'while'
261
+ },
262
+ {
263
+ from: 'o',
264
+ to: 'of'
265
+ },
266
+ {
267
+ from: 'in',
268
+ to: 'in'
269
+ },
270
+ {
271
+ from: 'awa',
272
+ to: 'await'
273
+ },
274
+ {
275
+ from: 'i',
276
+ to: 'if'
277
+ },
278
+ {
279
+ from: 'es',
280
+ to: 'else'
281
+ },
282
+ {
283
+ from: 'cas',
284
+ to: 'case'
285
+ },
286
+ {
287
+ from: 'dfl',
288
+ to: 'default'
289
+ },
290
+ {
291
+ from: 'inf',
292
+ to: 'info'
293
+ },
294
+ {
295
+ from: 'tab',
296
+ to: 'table'
297
+ },
298
+ {
299
+ from: 'tim',
300
+ to: 'time'
301
+ },
302
+ {
303
+ from: 'en',
304
+ to: 'end'
305
+ },
306
+ {
307
+ from: 'cnt',
308
+ to: 'continue'
309
+ },
310
+ {
311
+ from: 'dlt',
312
+ to: 'delete'
313
+ },
314
+ {
315
+ from: 'tp',
316
+ to: 'type'
317
+ },
318
+ {
319
+ from: 'isn',
320
+ to: 'instance'
321
+ },
322
+ {
323
+ from: 'vd',
324
+ to: 'void'
325
+ },
326
+ {
327
+ from: 'dbg',
328
+ to: 'debugger'
329
+ },
330
+ {
331
+ from: 'yed',
332
+ to: 'yield'
333
+ },
334
+ {
335
+ from: 'tpl',
336
+ to: 'replace'
337
+ },
338
+ {
339
+ from: 'chk',
340
+ to: 'chacked'
341
+ },
342
+ {
343
+ from: 'val',
344
+ to: 'value'
345
+ },
346
+ {
347
+ from: 'prn',
348
+ to: 'parent'
349
+ },
350
+ {
351
+ from: 'hs',
352
+ to: 'has'
353
+ },
354
+ {
355
+ from: 'atb',
356
+ to: 'attribute'
357
+ },
358
+ {
359
+ from: 'st',
360
+ to: 'set'
361
+ },
362
+ {
363
+ from: 'cun',
364
+ to: 'count'
365
+ },
366
+ {
367
+ from: 'trc',
368
+ to: 'trace'
369
+ },
370
+ {
371
+ from: 'clk',
372
+ to: 'click'
373
+ },
374
+ {
375
+ from: 'cng',
376
+ to: 'change'
377
+ },
378
+ {
379
+ from: 'inp',
380
+ to: 'input'
381
+ },
382
+ {
383
+ from: 'ld',
384
+ to: 'load'
385
+ },
386
+ {
387
+ from: 'sum',
388
+ to: 'submit'
389
+ },
390
+ {
391
+ from: 'ky',
392
+ to: 'key'
393
+ },
394
+ {
395
+ from: 'dw',
396
+ to: 'down'
397
+ },
398
+ {
399
+ from: 'u',
400
+ to: 'up'
401
+ },
402
+ {
403
+ from: 'prs',
404
+ to: 'press'
405
+ },
406
+ {
407
+ from: 'mos',
408
+ to: 'mouse'
409
+ },
410
+ {
411
+ from: 'or',
412
+ to: 'over'
413
+ },
414
+ {
415
+ from: 'ot',
416
+ to: 'out'
417
+ },
418
+ {
419
+ from: 'move',
420
+ to: 'mv'
421
+ },
422
+ {
423
+ from: 'fcs',
424
+ to: 'focus'
425
+ },
426
+ {
427
+ from: 'bl',
428
+ to: 'blur'
429
+ },
430
+ {
431
+ from: 'sz',
432
+ to: 'size'
433
+ },
434
+ {
435
+ from: 'scr',
436
+ to: 'scroll'
437
+ },
438
+ {
439
+ from: 'cnc',
440
+ to: 'concat'
441
+ },
442
+ {
443
+ from: 'ji',
444
+ to: 'join'
445
+ },
446
+ {
447
+ from: 'vrs',
448
+ to: 'verse'
449
+ },
450
+ {
451
+ from: 'fl',
452
+ to: 'fill'
453
+ },
454
+ {
455
+ from: 'cp',
456
+ to: 'copy'
457
+ },
458
+ {
459
+ from: 'wt',
460
+ to: 'with'
461
+ },
462
+ {
463
+ from: 'evr',
464
+ to: 'every'
465
+ },
466
+ {
467
+ from: 'sm',
468
+ to: 'some'
469
+ },
470
+ {
471
+ from: 'rdc',
472
+ to: 'reduce'
473
+ },
474
+ {
475
+ from: 'rgt',
476
+ to: 'right'
477
+ },
478
+ {
479
+ from: 'fat',
480
+ to: 'flat'
481
+ },
482
+ {
483
+ from: 'idx',
484
+ to: 'index'
485
+ },
486
+ {
487
+ from: 'ls',
488
+ to: 'last'
489
+ },
490
+ {
491
+ from: 'chr',
492
+ to: 'char'
493
+ },
494
+ {
495
+ from: 'cd',
496
+ to: 'code'
497
+ },
498
+ {
499
+ from: 'pit',
500
+ to: 'point'
501
+ },
502
+ {
503
+ from: 'sat',
504
+ to: 'start'
505
+ },
506
+ {
507
+ from: 'pd',
508
+ to: 'pad'
509
+ },
510
+ {
511
+ from: 'srn',
512
+ to: 'string'
513
+ },
514
+ {
515
+ from: 'mtc',
516
+ to: 'match'
517
+ },
518
+ {
519
+ from: 'srh',
520
+ to: 'search'
521
+ },
522
+ {
523
+ from: '',
524
+ to: ''
525
+ },
526
+ {
527
+ from: '',
528
+ to: ''
529
+ },
530
+ {
531
+ from: '',
532
+ to: ''
533
+ },
534
+ {
535
+ from: '',
536
+ to: ''
537
+ },
538
+ {
539
+ from: '',
540
+ to: ''
541
+ },
542
+ {
543
+ from: '',
544
+ to: ''
545
+ },
546
+ {
547
+ from: '',
548
+ to: ''
549
+ },
550
+ ];
551
+
552
+ module.exports = rules;
@@ -0,0 +1,29 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const config = require("../config");
4
+
5
+ function scanner() {
6
+ const sourcePath = path.join(process.cwd(), config.sourceFolder);
7
+
8
+ if (!fs.existsSync(sourcePath)) {
9
+ throw new Error(`Source folder not found: ${sourcePath}`);
10
+ }
11
+
12
+ const files = fs.readdirSync(sourcePath);
13
+
14
+ const sourceFiles = files.filter(file => {
15
+ return path.extname(file) === config.sourceExtension;
16
+ });
17
+
18
+ return sourceFiles.map(file => {
19
+ const fullPath = path.join(sourcePath, file);
20
+
21
+ return {
22
+ name: file,
23
+ path: fullPath,
24
+ code: fs.readFileSync(fullPath, "utf8")
25
+ };
26
+ });
27
+ }
28
+
29
+ module.exports = scanner;
@@ -0,0 +1,8 @@
1
+ const fs = require("fs");
2
+
3
+ function writer(code, fileName) {
4
+ fs.writeFileSync(fileName, code);
5
+ console.log("File created:", fileName);
6
+ }
7
+
8
+ module.exports = writer;
package/compiler.js ADDED
@@ -0,0 +1,22 @@
1
+ const scanner = require("./compiler/scanner");
2
+ const parser = require("./compiler/parser");
3
+ const writer = require("./compiler/writer");
4
+
5
+ const files = scanner();
6
+
7
+ console.log("Files:", files);
8
+
9
+ for (const file of files) {
10
+ console.log("Reading:", file.name);
11
+ console.log("Code:", file.code);
12
+
13
+ const tokens = file.code.split(/\s+/);
14
+ console.log("Tokens:", tokens);
15
+
16
+ const jsCode = parser(tokens);
17
+ console.log("Generated JS:", jsCode);
18
+
19
+ writer(jsCode, "./dist/output.js");
20
+ }
21
+
22
+ console.log("Compilation complete!");
package/config.js ADDED
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ sourceFolder: "src",
3
+ outputFolder: "dist",
4
+ sourceExtension: ".my",
5
+ outputExtension: ".js"
6
+ };
package/dist/output.js ADDED
@@ -0,0 +1 @@
1
+ const name0 = 'siam124'; const name1 = 'rafiq'; const name2 = 'karim'; const name3 = 'mincraft'; const name4 = 'raian'; const name5 = 'saymon';
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "mystic-yard",
3
+ "version": "2.0.0",
4
+ "description": "It is total best a framework, become it have a very shortcut",
5
+ "main": "compiler.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [
10
+ "my",
11
+ "yard",
12
+ "framework"
13
+ ],
14
+ "author": "muhammad raian al-siam",
15
+ "license": "ISC"
16
+ }
package/src/main.my ADDED
@@ -0,0 +1,6 @@
1
+ C name0 = 'siam124';
2
+ c name1 = 'rafiq';
3
+ c name2 = 'karim';
4
+ c name3 = 'mincraft';
5
+ c name4 = 'raian';
6
+ c name5 = 'saymon';