-
Notifications
You must be signed in to change notification settings - Fork 0
/
rapydscript_web.js
10433 lines (10288 loc) · 427 KB
/
rapydscript_web.js
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(function(){
"use strict";
function factory(){
"use strict";
var ՐՏ_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, ՐՏ_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, ՐՏ_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;
function abs(n) {
return Math.abs(n);
}
function all(a) {
var ՐՏitr91, ՐՏidx91;
var e;
ՐՏitr91 = ՐՏ_Iterable(a);
for (ՐՏidx91 = 0; ՐՏidx91 < ՐՏitr91.length; ՐՏidx91++) {
e = ՐՏitr91[ՐՏidx91];
if (!e) {
return false;
}
}
return true;
}
function any(a) {
var ՐՏitr92, ՐՏidx92;
var e;
ՐՏitr92 = ՐՏ_Iterable(a);
for (ՐՏidx92 = 0; ՐՏidx92 < ՐՏitr92.length; ՐՏidx92++) {
e = ՐՏitr92[ՐՏidx92];
if (e) {
return true;
}
}
return false;
}
function bin(a) {
return "0b" + (a >>> 0).toString(2);
}
function ՐՏ_bind(fn, thisArg) {
var ret;
if (fn.orig) {
fn = fn.orig;
}
if (thisArg === false) {
return fn;
}
ret = function() {
return fn.apply(thisArg, arguments);
};
ret.orig = fn;
return ret;
}
function ՐՏ_rebindAll(thisArg, rebind) {
if (rebind === void 0) {
rebind = true;
}
for (var p in thisArg) {
if (thisArg[p] && thisArg[p].orig) {
if (rebind) {
thisArg[p] = ՐՏ_bind(thisArg[p], thisArg);
} else {
thisArg[p] = thisArg[p].orig;
}
}
}
}
function ՐՏ_with__name__(fn, name) {
fn.__name__ = name;
return fn;
}
function cmp(a, b) {
return a < b ? -1 : a > b ? 1 : 0;
}
var chr = String.fromCharCode;
function dir(item) {
var arr;
arr = [];
for (var i in item) {
arr.push(i);
}
return arr;
}
function enumerate(item) {
var arr, iter, i;
arr = [];
iter = ՐՏ_Iterable(item);
for (i = 0; i < iter.length; i++) {
arr[arr.length] = [ i, item[i] ];
}
return arr;
}
function ՐՏ_eslice(arr, step, start, end) {
var isString;
arr = arr.slice(0);
if (typeof arr === "string" || arr instanceof String) {
isString = true;
arr = arr.split("");
}
if (step < 0) {
step = -step;
arr.reverse();
if (typeof start !== "undefined") {
start = arr.length - start - 1;
}
if (typeof end !== "undefined") {
end = arr.length - end - 1;
}
}
if (typeof start === "undefined") {
start = 0;
}
if (typeof end === "undefined") {
end = arr.length;
}
arr = arr.slice(start, end).filter(function(e, i) {
return i % step === 0;
});
return isString ? arr.join("") : arr;
}
function ՐՏ_extends(child, parent) {
child.prototype = Object.create(parent.prototype);
child.prototype.__base__ = parent;
child.prototype.constructor = child;
}
function filter(oper, arr) {
return arr.filter(oper);
}
function hex(a) {
return "0x" + (a >>> 0).toString(16);
}
function ՐՏ_in(val, arr) {
if (typeof arr.indexOf === "function") {
return arr.indexOf(val) !== -1;
} else if (typeof arr.has === "function") {
return arr.has(val);
}
return arr.hasOwnProperty(val);
}
function ՐՏ_Iterable(iterable) {
var tmp;
if (iterable.constructor === [].constructor || iterable.constructor === "".constructor || (tmp = Array.prototype.slice.call(iterable)).length) {
return tmp || iterable;
}
if (Set && iterable.constructor === Set) {
return Array.from(iterable);
}
return Object.keys(iterable);
}
function len(obj) {
var tmp;
if (obj.constructor === [].constructor || obj.constructor === "".constructor || (tmp = Array.prototype.slice.call(obj)).length) {
return (tmp || obj).length;
}
if (Set && obj.constructor === Set) {
return obj.size;
}
return Object.keys(obj).length;
}
function map(oper, arr) {
return arr.map(oper);
}
function max(a) {
return Math.max.apply(null, Array.isArray(a) ? a : arguments);
}
function min(a) {
return Math.min.apply(null, Array.isArray(a) ? a : arguments);
}
function ՐՏ_merge(target, source, overwrite) {
var ՐՏitr93, ՐՏidx93;
var prop;
for (var i in source) {
if (source.hasOwnProperty(i) && (overwrite || typeof target[i] === "undefined")) {
target[i] = source[i];
}
}
ՐՏitr93 = ՐՏ_Iterable(Object.getOwnPropertyNames(source.prototype));
for (ՐՏidx93 = 0; ՐՏidx93 < ՐՏitr93.length; ՐՏidx93++) {
prop = ՐՏitr93[ՐՏidx93];
if (overwrite || typeof target.prototype[prop] === "undefined") {
Object.defineProperty(target.prototype, prop, Object.getOwnPropertyDescriptor(source.prototype, prop));
}
}
}
function ՐՏ_mixin() {
var classes = [].slice.call(arguments, 0);
return function(baseClass) {
var ՐՏitr94, ՐՏidx94, ՐՏitr95, ՐՏidx95;
var cls, key;
ՐՏitr94 = ՐՏ_Iterable(classes);
for (ՐՏidx94 = 0; ՐՏidx94 < ՐՏitr94.length; ՐՏidx94++) {
cls = ՐՏitr94[ՐՏidx94];
ՐՏitr95 = ՐՏ_Iterable(Object.getOwnPropertyNames(cls.prototype));
for (ՐՏidx95 = 0; ՐՏidx95 < ՐՏitr95.length; ՐՏidx95++) {
key = ՐՏitr95[ՐՏidx95];
if (!(ՐՏ_in(key, baseClass.prototype))) {
Object.defineProperty(baseClass.prototype, key, Object.getOwnPropertyDescriptor(cls.prototype, key));
}
}
}
return baseClass;
};
}
function ՐՏ_print() {
if (typeof console === "object") {
console.log.apply(console, arguments);
}
}
function range(start, stop, step) {
var length, idx, range;
if (arguments.length <= 1) {
stop = start || 0;
start = 0;
}
step = arguments[2] || 1;
length = Math.max(Math.ceil((stop - start) / step), 0);
idx = 0;
range = new Array(length);
while (idx < length) {
range[idx++] = start;
start += step;
}
return range;
}
function reduce(f, a) {
return Array.prototype.reduce.call(a, f);
}
function reversed(arr) {
var tmp;
tmp = arr.slice(0);
return tmp.reverse();
}
function sorted(arr) {
var tmp;
tmp = arr.slice(0);
return tmp.sort();
}
function sum(arr, start) {
start = start === void 0 ? 0 : start;
return arr.reduce(function(prev, cur) {
return prev + cur;
}, start);
}
function ՐՏ_type(obj) {
return obj && obj.constructor && obj.constructor.name ? obj.constructor.name : Object.prototype.toString.call(obj).slice(8, -1);
}
function zip(a, b) {
var i;
return (function() {
var ՐՏidx96, ՐՏitr96 = ՐՏ_Iterable(range(Math.min(a.length, b.length))), ՐՏres = [], i;
for (ՐՏidx96 = 0; ՐՏidx96 < ՐՏitr96.length; ՐՏidx96++) {
i = ՐՏitr96[ՐՏidx96];
ՐՏres.push([ a[i], b[i] ]);
}
return ՐՏres;
})();
}
function getattr(obj, name) {
return obj[name];
}
function setattr(obj, name, value) {
obj[name] = value;
}
function hasattr(obj, name) {
return name in obj;
}
function ՐՏ_eq(a, b) {
var ՐՏitr97, ՐՏidx97;
var i;
if (a === b) {
return true;
}
if (a === void 0 || b === void 0 || a === null || b === null) {
return false;
}
if (a.constructor !== b.constructor) {
return false;
}
if (Array.isArray(a)) {
if (a.length !== b.length) {
return false;
}
for (i = 0; i < a.length; i++) {
if (!ՐՏ_eq(a[i], b[i])) {
return false;
}
}
return true;
} else if (a.constructor === Object) {
if (Object.keys(a).length !== Object.keys(b).length) {
return false;
}
ՐՏitr97 = ՐՏ_Iterable(a);
for (ՐՏidx97 = 0; ՐՏidx97 < ՐՏitr97.length; ՐՏidx97++) {
i = ՐՏitr97[ՐՏidx97];
if (!ՐՏ_eq(a[i], b[i])) {
return false;
}
}
return true;
} else if (Set && a.constructor === Set || Map && a.constructor === Map) {
if (a.size !== b.size) {
return false;
}
for (i of a) {
if (!b.has(i)) {
return false;
}
}
return true;
} else if (a.constructor === Date) {
return a.getTime() === b.getTime();
} else if (typeof a.__eq__ === "function") {
return a.__eq__(b);
}
return false;
}
function kwargs(f) {
var argNames;
argNames = f.toString().match(/\(([^\)]+)/)[1];
if (!kwargs.memo[argNames]) {
kwargs.memo[argNames] = argNames ? argNames.split(",").map(function(s) {
return s.trim();
}) : [];
}
argNames = kwargs.memo[argNames];
return function() {
var args, kw, i;
args = [].slice.call(arguments);
if (args.length) {
kw = args[args.length-1];
if (typeof kw === "object") {
for (i = 0; i < argNames.length; i++) {
if (ՐՏ_in(argNames[i], kw)) {
args[i] = kw[argNames[i]];
}
}
} else {
args.push(kw);
}
}
try {
return f.apply(this, args);
} catch (ՐՏ_Exception) {
var e = ՐՏ_Exception;
if (/Class constructor \w+ cannot be invoked without 'new'/.test(e)) {
return new f(args);
}
throw ՐՏ_Exception;
}
};
}
kwargs.memo = {};
var AssertionError = (ՐՏ_128 = function AssertionError() {
AssertionError.prototype.__init__.apply(this, arguments);
}, ՐՏ_extends(ՐՏ_128, Error), Object.defineProperties(ՐՏ_128.prototype, {
__init__: {
enumerable: true,
writable: true,
value: function __init__(message){
var self = this;
self.name = "AssertionError";
self.message = message;
}
}
}), ՐՏ_128);
var IndexError = (ՐՏ_129 = function IndexError() {
IndexError.prototype.__init__.apply(this, arguments);
}, ՐՏ_extends(ՐՏ_129, Error), Object.defineProperties(ՐՏ_129.prototype, {
__init__: {
enumerable: true,
writable: true,
value: function __init__(message){
var self = this;
self.name = "IndexError";
self.message = message;
}
}
}), ՐՏ_129);
var KeyError = (ՐՏ_130 = function KeyError() {
KeyError.prototype.__init__.apply(this, arguments);
}, ՐՏ_extends(ՐՏ_130, Error), Object.defineProperties(ՐՏ_130.prototype, {
__init__: {
enumerable: true,
writable: true,
value: function __init__(message){
var self = this;
self.name = "KeyError";
self.message = message;
}
}
}), ՐՏ_130);
var TypeError = (ՐՏ_131 = function TypeError() {
TypeError.prototype.__init__.apply(this, arguments);
}, ՐՏ_extends(ՐՏ_131, Error), Object.defineProperties(ՐՏ_131.prototype, {
__init__: {
enumerable: true,
writable: true,
value: function __init__(message){
var self = this;
self.name = "TypeError";
self.message = message;
}
}
}), ՐՏ_131);
var ValueError = (ՐՏ_132 = function ValueError() {
ValueError.prototype.__init__.apply(this, arguments);
}, ՐՏ_extends(ՐՏ_132, Error), Object.defineProperties(ՐՏ_132.prototype, {
__init__: {
enumerable: true,
writable: true,
value: function __init__(message){
var self = this;
self.name = "ValueError";
self.message = message;
}
}
}), ՐՏ_132);
var ՐՏ_modules = {};
ՐՏ_modules["utils"] = {};
ՐՏ_modules["ast"] = {};
ՐՏ_modules["tokenizer"] = {};
ՐՏ_modules["parser"] = {};
ՐՏ_modules["_baselib"] = {};
ՐՏ_modules["stream"] = {};
ՐՏ_modules["output"] = {};
(function(){
var __name__ = "utils";
var RAPYD_PREFIX, MAP, colors;
RAPYD_PREFIX = "ՐՏ";
function slice(a, start) {
return Array.prototype.slice.call(a, start || 0);
}
function member(name, array) {
var ՐՏitr1, ՐՏidx1;
var i;
ՐՏitr1 = ՐՏ_Iterable(range(array.length - 1, -1, -1));
for (ՐՏidx1 = 0; ՐՏidx1 < ՐՏitr1.length; ՐՏidx1++) {
i = ՐՏitr1[ՐՏidx1];
if (array[i] === name) {
return true;
}
}
return false;
}
function find_if(func, array) {
var i;
for (i = 0; i < len(array); i++) {
if (func(array[i])) {
return array[i];
}
}
}
function repeat_string(str_, i) {
var d;
if (i <= 0) {
return "";
}
if (i === 1) {
return str_;
}
d = repeat_string(str_, i >> 1);
d += d;
if (i & 1) {
d += str_;
}
return d;
}
function DefaultsError(msg, defs) {
this.msg = msg;
this.defs = defs;
}
var ImportError = (ՐՏ_1 = function ImportError() {
ImportError.prototype.__init__.apply(this, arguments);
}, ՐՏ_extends(ՐՏ_1, Error), Object.defineProperties(ՐՏ_1.prototype, {
__init__: {
enumerable: true,
writable: true,
value: function __init__(message, filename, readfile_error){
var self = this;
self.message = message;
self.filename = filename;
self.readfile_error = readfile_error;
}
}
}), ՐՏ_1);
var ParseError = (ՐՏ_2 = function ParseError() {
ParseError.prototype.__init__.apply(this, arguments);
}, ՐՏ_extends(ՐՏ_2, Error), Object.defineProperties(ՐՏ_2.prototype, {
__init__: {
enumerable: true,
writable: true,
value: function __init__(message, line, col, pos, is_eof, filename){
var self = this;
self.message = message;
self.line = line;
self.col = col;
self.pos = pos;
self.stack = new Error().stack;
self.is_eof = is_eof;
self.filename = filename;
}
},
toString: {
enumerable: true,
writable: true,
value: function toString(){
var self = this;
return this.message + " (line: " + this.line + ", col: " + this.col + ", pos: " + this.pos + ")" + "\n\n" + this.stack;
}
}
}), ՐՏ_2);
function defaults(args, defs, croak) {
var ՐՏitr2, ՐՏidx2, ՐՏitr3, ՐՏidx3;
var ret, key;
if (args === true) {
args = {};
}
ret = args || {};
if (croak) {
ՐՏitr2 = ՐՏ_Iterable(ret);
for (ՐՏidx2 = 0; ՐՏidx2 < ՐՏitr2.length; ՐՏidx2++) {
key = ՐՏitr2[ՐՏidx2];
if (!(ՐՏ_in(key, defs))) {
throw new DefaultsError("`" + key + "` is not a supported option", defs);
}
}
}
ՐՏitr3 = ՐՏ_Iterable(defs);
for (ՐՏidx3 = 0; ՐՏidx3 < ՐՏitr3.length; ՐՏidx3++) {
key = ՐՏitr3[ՐՏidx3];
ret[key] = args && ՐՏ_in(key, args) ? args[key] : defs[key];
}
return ret;
}
function merge(obj, ext) {
var ՐՏitr4, ՐՏidx4;
var key;
ՐՏitr4 = ՐՏ_Iterable(ext);
for (ՐՏidx4 = 0; ՐՏidx4 < ՐՏitr4.length; ՐՏidx4++) {
key = ՐՏitr4[ՐՏidx4];
obj[key] = ext[key];
}
return obj;
}
function noop() {
}
MAP = function() {
var skip;
function MAP(a, f, backwards) {
var ՐՏitr5, ՐՏidx5;
var ret, top, i;
ret = [];
top = [];
function doit() {
var val, is_last;
val = f(a[i], i);
is_last = val instanceof Last;
if (is_last) {
val = val.v;
}
if (val instanceof AtTop) {
val = val.v;
if (val instanceof Splice) {
top.push.apply(top, backwards ? val.v.slice().reverse() : val.v);
} else {
top.push(val);
}
} else if (val !== skip) {
if (val instanceof Splice) {
ret.push.apply(ret, backwards ? val.v.slice().reverse() : val.v);
} else {
ret.push(val);
}
}
return is_last;
}
if (Array.isArray(a)) {
if (backwards) {
ՐՏitr5 = ՐՏ_Iterable(range(a.length - 1, -1, -1));
for (ՐՏidx5 = 0; ՐՏidx5 < ՐՏitr5.length; ՐՏidx5++) {
i = ՐՏitr5[ՐՏidx5];
if (doit()) {
break;
}
}
ret.reverse();
top.reverse();
} else {
for (i = 0; i < len(a); i++) {
if (doit()) {
break;
}
}
}
} else {
for (i in a) {
if (a.hasOwnProperty(i)) {
if (doit()) {
break;
}
}
}
}
return top.concat(ret);
}
MAP.at_top = function(val) {
return new AtTop(val);
};
MAP.splice = function(val) {
return new Splice(val);
};
MAP.last = function(val) {
return new Last(val);
};
skip = MAP.skip = {};
function AtTop(val) {
this.v = val;
}
function Splice(val) {
this.v = val;
}
function Last(val) {
this.v = val;
}
return MAP;
}();
function push_uniq(array, el) {
if (!(ՐՏ_in(el, array))) {
array.push(el);
}
}
function string_template(text, props) {
return text.replace(/\{(.+?)\}/g, function(str_, p) {
return props[p];
});
}
function remove(array, el) {
var ՐՏitr6, ՐՏidx6;
var idx;
ՐՏitr6 = ՐՏ_Iterable(range(array.length - 1, -1, -1));
for (ՐՏidx6 = 0; ՐՏidx6 < ՐՏitr6.length; ՐՏidx6++) {
idx = ՐՏitr6[ՐՏidx6];
if (array[idx] === el) {
array.splice(i, 1);
}
}
}
function mergeSort(array, cmp) {
if (array.length < 2) {
return array.slice();
}
function merge(a, b) {
var r, ai, bi, i;
r = [];
ai = 0;
bi = 0;
i = 0;
while (ai < a.length && bi < b.length) {
if (cmp(a[ai], b[bi]) <= 0) {
r[i] = a[ai];
++ai;
} else {
r[i] = b[bi];
++bi;
}
++i;
}
if (ai < a.length) {
r.push.apply(r, a.slice(ai));
}
if (bi < b.length) {
r.push.apply(r, b.slice(bi));
}
return r;
}
function _ms(a) {
var m, left, right;
if (a.length <= 1) {
return a;
}
m = Math.floor(a.length / 2);
left = a.slice(0, m);
right = a.slice(m);
left = _ms(left);
right = _ms(right);
return ՐՏ_merge(left, right);
}
return _ms(array);
}
function set_difference(a, b) {
return a.filter(function(el) {
return !(ՐՏ_in(el, b));
});
}
function set_intersection(a, b) {
return a.filter(function(el) {
return ՐՏ_in(el, b);
});
}
function makePredicate(words) {
var f, cats, i, skip, j, cat;
if (!Array.isArray(words)) {
words = words.split(" ");
}
f = "";
cats = [];
for (i = 0; i < len(words); i++) {
skip = false;
for (j = 0; j < len(cats); j++) {
if (cats[j][0].length === words[i].length) {
cats[j].push(words[i]);
skip = true;
break;
}
}
if (!skip) {
cats.push([ words[i] ]);
}
}
function compareTo(arr) {
var i;
if (arr.length === 1) {
return f += "return str === " + JSON.stringify(arr[0]) + ";";
}
f += "switch(str){";
for (i = 0; i < len(arr); i++) {
f += "case " + JSON.stringify(arr[i]) + ":";
}
f += "return true}return false;";
}
if (cats.length > 3) {
cats.sort(function(a, b) {
return b.length - a.length;
});
f += "switch(str.length){";
for (i = 0; i < len(cats); i++) {
cat = cats[i];
f += "case " + cat[0].length + ":";
compareTo(cat);
}
f += "}";
} else {
compareTo(words);
}
return new Function("str", f);
}
function Dictionary() {
this._values = Object.create(null);
this._size = 0;
}
Dictionary.prototype = {
set: function(key, val) {
if (!this.has(key)) {
++this._size;
}
this._values["$" + key] = val;
return this;
},
add: function(key, val) {
if (this.has(key)) {
this.get(key).push(val);
} else {
this.set(key, [ val ]);
}
return this;
},
get: function(key) {
return this._values["$" + key];
},
del_: function(key) {
if (this.has(key)) {
--this._size;
delete this._values["$" + key];
}
return this;
},
has: function(key) {
return ՐՏ_in("$" + key, this._values);
},
each: function(f) {
var i;
for (i in this._values) {
f(this._values[i], i.substr(1));
}
},
size: function() {
return this._size;
},
map: function(f) {
var ret, i;
ret = [];
for (i in this._values) {
ret.push(f(this._values[i], i.substr(1)));
}
return ret;
}
};
colors = [ "red", "green", "yellow", "blue", "magenta", "cyan", "white" ];
function ansi(code) {
code = code || 0;
return "[" + code + "m";
}
function colored(string, color, bold) {
var prefix;
prefix = [];
if (bold) {
prefix.push(ansi(1));
}
if (color) {
prefix.push(ansi(colors.indexOf(color) + 31));
}
return prefix.join("") + string + ansi(0);
}
ՐՏ_modules["utils"]["RAPYD_PREFIX"] = RAPYD_PREFIX;
ՐՏ_modules["utils"]["MAP"] = MAP;
ՐՏ_modules["utils"]["colors"] = colors;
ՐՏ_modules["utils"]["slice"] = slice;
ՐՏ_modules["utils"]["member"] = member;
ՐՏ_modules["utils"]["find_if"] = find_if;
ՐՏ_modules["utils"]["repeat_string"] = repeat_string;
ՐՏ_modules["utils"]["DefaultsError"] = DefaultsError;
ՐՏ_modules["utils"]["ImportError"] = ImportError;
ՐՏ_modules["utils"]["ParseError"] = ParseError;
ՐՏ_modules["utils"]["defaults"] = defaults;
ՐՏ_modules["utils"]["merge"] = merge;
ՐՏ_modules["utils"]["noop"] = noop;
ՐՏ_modules["utils"]["push_uniq"] = push_uniq;
ՐՏ_modules["utils"]["string_template"] = string_template;
ՐՏ_modules["utils"]["remove"] = remove;
ՐՏ_modules["utils"]["mergeSort"] = mergeSort;
ՐՏ_modules["utils"]["set_difference"] = set_difference;
ՐՏ_modules["utils"]["set_intersection"] = set_intersection;
ՐՏ_modules["utils"]["makePredicate"] = makePredicate;
ՐՏ_modules["utils"]["Dictionary"] = Dictionary;
ՐՏ_modules["utils"]["ansi"] = ansi;
ՐՏ_modules["utils"]["colored"] = colored;
})();
(function(){
var __name__ = "ast";
var noop = ՐՏ_modules["utils"].noop;
var string_template = ՐՏ_modules["utils"].string_template;
var colored = ՐՏ_modules["utils"].colored;
function memoized(f) {
return function(x) {
if (!this.computedType) {
this.computedType = f.call(this, x);
}
return this.computedType;
};
}
var AST = (ՐՏ_3 = function AST() {
AST.prototype.__init__.apply(this, arguments);
}, (function(){
var properties = {};
Object.defineProperties(ՐՏ_3.prototype, {
properties: {
enumerable: true,
writable: true,
value: properties
},
__init__: {
enumerable: true,
writable: true,
value: function __init__(initializer){
var self = this;
var obj, i;
if (initializer) {
obj = self;
while (obj) {
for (i in obj.properties) {
self[i] = initializer[i];
}
obj = Object.getPrototypeOf(obj);
}
}
}
},
clone: {
enumerable: true,
writable: true,
value: function clone(){
var self = this;
return new self.constructor(self);
}
}
}) })(), ՐՏ_3);
var Token = (ՐՏ_4 = function Token() {
AST.prototype.__init__.apply(this, arguments);
}, ՐՏ_extends(ՐՏ_4, AST), (function(){
var properties = {
"type": "The type of the token",
"subtype": "The subtype of the token",
"value": "The value of the token",
"_value": "The src value of the token",
"line": "The line number at which the token occurs",
"col": "The column number at which the token occurs",
"pos": "Absolute position of the token start, relative to document start",
"endpos": "Absolute position of the token start, relative to document start",
"newline_before": "True if there was a newline before this token",
"comments_before": "True if there were comments before this token",
"comma_expected": "True if comma was expected instead of this token",
"file": "Name of the file currently being parsed"
};
Object.defineProperties(ՐՏ_4.prototype, {
properties: {
enumerable: true,
writable: true,
value: properties
}
}) })(), ՐՏ_4);
var Node = (ՐՏ_5 = function Node() {
AST.prototype.__init__.apply(this, arguments);
}, ՐՏ_extends(ՐՏ_5, AST), (function(){
var properties = {
"start": "[Token] The first token of this node",
"end": "[Token] The last token of this node"
};
var computedType = null;
Object.defineProperties(ՐՏ_5.prototype, {
properties: {
enumerable: true,
writable: true,
value: properties
},
computedType: {
enumerable: true,
writable: true,
value: computedType
},
resolveType: {
enumerable: true,
writable: true,
value: memoized(function resolveType(){
var heap = this;
return "?";
})
},
_walk: {
enumerable: true,
writable: true,
value: function _walk(visitor){
var self = this;
return visitor._visit(self);
}
},
walk: {
enumerable: true,
writable: true,
value: function walk(visitor){
var self = this;
return self._walk(visitor);
}
},
_dump: {
enumerable: true,
writable: true,
value: function _dump(depth, omit, offset, include_name, compact){
var ՐՏitr7, ՐՏidx7, ՐՏitr8, ՐՏidx8, ՐՏitr9, ՐՏidx9, ՐՏitr10, ՐՏidx10;
var self = this;
var key, colored_key, value, element, property;
function out(string) {
var pad;
pad = new Array(offset + 1).join(" ");
console.log(pad + string);
}
if (include_name) {
out(colored(ՐՏ_type(self), "yellow"));
}
ՐՏitr7 = ՐՏ_Iterable(this);
for (ՐՏidx7 = 0; ՐՏidx7 < ՐՏitr7.length; ՐՏidx7++) {
key = ՐՏitr7[ՐՏidx7];
if (ՐՏ_in(key, omit)) {
continue;
}
colored_key = colored(key + ": ", "blue");
value = self[key];
if (Array.isArray(value)) {
if (value.length) {
out(" " + colored_key + "[");
if (depth > 1) {
ՐՏitr8 = ՐՏ_Iterable(value);
for (ՐՏidx8 = 0; ՐՏidx8 < ՐՏitr8.length; ՐՏidx8++) {
element = ՐՏitr8[ՐՏidx8];
element._dump(depth - 1, omit, offset + 1, true, compact);