blob: cdf4b65b631cb804173c123618ec9538c00363bb [file] [log] [blame]
fpizlo@apple.com9f1dad42014-07-18 04:34:16 +00001try {
2// This file is automatically generated by scheme2js, except for the
3// benchmark harness code at the beginning and end of the file.
4
5/************* GENERATED FILE - DO NOT EDIT *************/
6/************* GENERATED FILE - DO NOT EDIT *************/
7/************* GENERATED FILE - DO NOT EDIT *************/
8/************* GENERATED FILE - DO NOT EDIT *************/
9/************* GENERATED FILE - DO NOT EDIT *************/
10/************* GENERATED FILE - DO NOT EDIT *************/
11/************* GENERATED FILE - DO NOT EDIT *************/
12/************* GENERATED FILE - DO NOT EDIT *************/
13/*
14 * To use write/prints/... the default-output port has to be set first.
15 * Simply setting SC_DEFAULT_OUT and SC_ERROR_OUT to the desired values
16 * should do the trick.
17 * In the following example the std-out and error-port are redirected to
18 * a DIV.
19function initRuntime() {
20 function escapeHTML(s) {
21 var tmp = s;
22 tmp = tmp.replace(/&/g, "&");
23 tmp = tmp.replace(/</g, "&lt;");
24 tmp = tmp.replace(/>/g, "&gt;");
25 tmp = tmp.replace(/ /g, "&nbsp;");
26 tmp = tmp.replace(/\n/g, "<br />");
27 tmp = tmp.replace(/\t/g, "&nbsp;&nbsp;&nbsp;&nbsp");
28 return tmp;
29
30 }
31
32 document.write("<div id='stdout'></div>");
33 SC_DEFAULT_OUT = new sc_GenericOutputPort(
34 function(s) {
35 var stdout = document.getElementById('stdout');
36 stdout.innerHTML = stdout.innerHTML + escapeHTML(s);
37 });
38 SC_ERROR_OUT = SC_DEFAULT_OUT;
39}
40*/
41
42
43function sc_print_debug() {
44 sc_print.apply(null, arguments);
45}
46/*** META ((export *js*)) */
47var sc_JS_GLOBALS = this;
48
49var __sc_LINE=-1;
50var __sc_FILE="";
51
52/*** META ((export #t)) */
53function sc_alert() {
54 var len = arguments.length;
55 var s = "";
56 var i;
57
58 for( i = 0; i < len; i++ ) {
59 s += sc_toDisplayString(arguments[ i ]);
60 }
61
62 return alert( s );
63}
64
65/*** META ((export #t)) */
66function sc_typeof( x ) {
67 return typeof x;
68}
69
70/*** META ((export #t)) */
71function sc_error() {
72 var a = [sc_jsstring2symbol("*error*")];
73 for (var i = 0; i < arguments.length; i++) {
74 a[i+1] = arguments[i];
75 }
76 throw a;
77}
78
79/*** META ((export #t)
80 (peephole (prefix "throw ")))
81*/
82function sc_raise(obj) {
83 throw obj;
84}
85
86/*** META ((export with-handler-lambda)) */
87function sc_withHandlerLambda(handler, body) {
88 try {
89 return body();
90 } catch(e) {
91 if (!e._internalException)
92 return handler(e);
93 else
94 throw e;
95 }
96}
97
98var sc_properties = new Object();
99
100/*** META ((export #t)) */
101function sc_putpropBang(sym, key, val) {
102 var ht = sc_properties[sym];
103 if (!ht) {
104 ht = new Object();
105 sc_properties[sym] = ht;
106 }
107 ht[key] = val;
108}
109
110/*** META ((export #t)) */
111function sc_getprop(sym, key) {
112 var ht = sc_properties[sym];
113 if (ht) {
114 if (key in ht)
115 return ht[key];
116 else
117 return false;
118 } else
119 return false;
120}
121
122/*** META ((export #t)) */
123function sc_rempropBang(sym, key) {
124 var ht = sc_properties[sym];
125 if (ht)
126 delete ht[key];
127}
128
129/*** META ((export #t)) */
130function sc_any2String(o) {
131 return jsstring2string(sc_toDisplayString(o));
132}
133
134/*** META ((export #t)
135 (peephole (infix 2 2 "==="))
136 (type bool))
137*/
138function sc_isEqv(o1, o2) {
139 return (o1 === o2);
140}
141
142/*** META ((export #t)
143 (peephole (infix 2 2 "==="))
144 (type bool))
145*/
146function sc_isEq(o1, o2) {
147 return (o1 === o2);
148}
149
150/*** META ((export #t)
151 (type bool))
152*/
153function sc_isNumber(n) {
154 return (typeof n === "number");
155}
156
157/*** META ((export #t)
158 (type bool))
159*/
160function sc_isComplex(n) {
161 return sc_isNumber(n);
162}
163
164/*** META ((export #t)
165 (type bool))
166*/
167function sc_isReal(n) {
168 return sc_isNumber(n);
169}
170
171/*** META ((export #t)
172 (type bool))
173*/
174function sc_isRational(n) {
175 return sc_isReal(n);
176}
177
178/*** META ((export #t)
179 (type bool))
180*/
181function sc_isInteger(n) {
182 return (parseInt(n) === n);
183}
184
185/*** META ((export #t)
186 (type bool)
187 (peephole (postfix ", false")))
188*/
189// we don't have exact numbers...
190function sc_isExact(n) {
191 return false;
192}
193
194/*** META ((export #t)
195 (peephole (postfix ", true"))
196 (type bool))
197*/
198function sc_isInexact(n) {
199 return true;
200}
201
202/*** META ((export = =fx =fl)
203 (type bool)
204 (peephole (infix 2 2 "===")))
205*/
206function sc_equal(x) {
207 for (var i = 1; i < arguments.length; i++)
208 if (x !== arguments[i])
209 return false;
210 return true;
211}
212
213/*** META ((export < <fx <fl)
214 (type bool)
215 (peephole (infix 2 2 "<")))
216*/
217function sc_less(x) {
218 for (var i = 1; i < arguments.length; i++) {
219 if (x >= arguments[i])
220 return false;
221 x = arguments[i];
222 }
223 return true;
224}
225
226/*** META ((export > >fx >fl)
227 (type bool)
228 (peephole (infix 2 2 ">")))
229*/
230function sc_greater(x, y) {
231 for (var i = 1; i < arguments.length; i++) {
232 if (x <= arguments[i])
233 return false;
234 x = arguments[i];
235 }
236 return true;
237}
238
239/*** META ((export <= <=fx <=fl)
240 (type bool)
241 (peephole (infix 2 2 "<=")))
242*/
243function sc_lessEqual(x, y) {
244 for (var i = 1; i < arguments.length; i++) {
245 if (x > arguments[i])
246 return false;
247 x = arguments[i];
248 }
249 return true;
250}
251
252/*** META ((export >= >=fl >=fx)
253 (type bool)
254 (peephole (infix 2 2 ">=")))
255*/
256function sc_greaterEqual(x, y) {
257 for (var i = 1; i < arguments.length; i++) {
258 if (x < arguments[i])
259 return false;
260 x = arguments[i];
261 }
262 return true;
263}
264
265/*** META ((export #t)
266 (type bool)
267 (peephole (postfix "=== 0")))
268*/
269function sc_isZero(x) {
270 return (x === 0);
271}
272
273/*** META ((export #t)
274 (type bool)
275 (peephole (postfix "> 0")))
276*/
277function sc_isPositive(x) {
278 return (x > 0);
279}
280
281/*** META ((export #t)
282 (type bool)
283 (peephole (postfix "< 0")))
284*/
285function sc_isNegative(x) {
286 return (x < 0);
287}
288
289/*** META ((export #t)
290 (type bool)
291 (peephole (postfix "%2===1")))
292*/
293function sc_isOdd(x) {
294 return (x % 2 === 1);
295}
296
297/*** META ((export #t)
298 (type bool)
299 (peephole (postfix "%2===0")))
300*/
301function sc_isEven(x) {
302 return (x % 2 === 0);
303}
304
305/*** META ((export #t)) */
306var sc_max = Math.max;
307/*** META ((export #t)) */
308var sc_min = Math.min;
309
310/*** META ((export + +fx +fl)
311 (peephole (infix 0 #f "+" "0")))
312*/
313function sc_plus() {
314 var sum = 0;
315 for (var i = 0; i < arguments.length; i++)
316 sum += arguments[i];
317 return sum;
318}
319
320/*** META ((export * *fx *fl)
321 (peephole (infix 0 #f "*" "1")))
322*/
323function sc_multi() {
324 var product = 1;
325 for (var i = 0; i < arguments.length; i++)
326 product *= arguments[i];
327 return product;
328}
329
330/*** META ((export - -fx -fl)
331 (peephole (minus)))
332*/
333function sc_minus(x) {
334 if (arguments.length === 1)
335 return -x;
336 else {
337 var res = x;
338 for (var i = 1; i < arguments.length; i++)
339 res -= arguments[i];
340 return res;
341 }
342}
343
344/*** META ((export / /fl)
345 (peephole (div)))
346*/
347function sc_div(x) {
348 if (arguments.length === 1)
349 return 1/x;
350 else {
351 var res = x;
352 for (var i = 1; i < arguments.length; i++)
353 res /= arguments[i];
354 return res;
355 }
356}
357
358/*** META ((export #t)) */
359var sc_abs = Math.abs;
360
361/*** META ((export quotient /fx)
362 (peephole (hole 2 "parseInt(" x "/" y ")")))
363*/
364function sc_quotient(x, y) {
365 return parseInt(x / y);
366}
367
368/*** META ((export #t)
369 (peephole (infix 2 2 "%")))
370*/
371function sc_remainder(x, y) {
372 return x % y;
373}
374
375/*** META ((export #t)
376 (peephole (modulo)))
377*/
378function sc_modulo(x, y) {
379 var remainder = x % y;
380 // if they don't have the same sign
381 if ((remainder * y) < 0)
382 return remainder + y;
383 else
384 return remainder;
385}
386
387function sc_euclid_gcd(a, b) {
388 var temp;
389 if (a === 0) return b;
390 if (b === 0) return a;
391 if (a < 0) {a = -a;};
392 if (b < 0) {b = -b;};
393 if (b > a) {temp = a; a = b; b = temp;};
394 while (true) {
395 a %= b;
396 if(a === 0) {return b;};
397 b %= a;
398 if(b === 0) {return a;};
399 };
400 return b;
401}
402
403/*** META ((export #t)) */
404function sc_gcd() {
405 var gcd = 0;
406 for (var i = 0; i < arguments.length; i++)
407 gcd = sc_euclid_gcd(gcd, arguments[i]);
408 return gcd;
409}
410
411/*** META ((export #t)) */
412function sc_lcm() {
413 var lcm = 1;
414 for (var i = 0; i < arguments.length; i++) {
415 var f = Math.round(arguments[i] / sc_euclid_gcd(arguments[i], lcm));
416 lcm *= Math.abs(f);
417 }
418 return lcm;
419}
420
421// LIMITATION: numerator and denominator don't make sense in floating point world.
422//var SC_MAX_DECIMALS = 1000000
423//
424// function sc_numerator(x) {
425// var rounded = Math.round(x * SC_MAX_DECIMALS);
426// return Math.round(rounded / sc_euclid_gcd(rounded, SC_MAX_DECIMALS));
427// }
428
429// function sc_denominator(x) {
430// var rounded = Math.round(x * SC_MAX_DECIMALS);
431// return Math.round(SC_MAX_DECIMALS / sc_euclid_gcd(rounded, SC_MAX_DECIMALS));
432// }
433
434/*** META ((export #t)) */
435var sc_floor = Math.floor;
436/*** META ((export #t)) */
437var sc_ceiling = Math.ceil;
438/*** META ((export #t)) */
439var sc_truncate = parseInt;
440/*** META ((export #t)) */
441var sc_round = Math.round;
442
443// LIMITATION: sc_rationalize doesn't make sense in a floating point world.
444
445/*** META ((export #t)) */
446var sc_exp = Math.exp;
447/*** META ((export #t)) */
448var sc_log = Math.log;
449/*** META ((export #t)) */
450var sc_sin = Math.sin;
451/*** META ((export #t)) */
452var sc_cos = Math.cos;
453/*** META ((export #t)) */
454var sc_tan = Math.tan;
455/*** META ((export #t)) */
456var sc_asin = Math.asin;
457/*** META ((export #t)) */
458var sc_acos = Math.acos;
459/*** META ((export #t)) */
460var sc_atan = Math.atan;
461
462/*** META ((export #t)) */
463var sc_sqrt = Math.sqrt;
464/*** META ((export #t)) */
465var sc_expt = Math.pow;
466
467// LIMITATION: we don't have complex numbers.
468// LIMITATION: the following functions are hence not implemented.
469// LIMITATION: make-rectangular, make-polar, real-part, imag-part, magnitude, angle
470// LIMITATION: 2 argument atan
471
472/*** META ((export #t)
473 (peephole (id)))
474*/
475function sc_exact2inexact(x) {
476 return x;
477}
478
479/*** META ((export #t)
480 (peephole (id)))
481*/
482function sc_inexact2exact(x) {
483 return x;
484}
485
486function sc_number2jsstring(x, radix) {
487 if (radix)
488 return x.toString(radix);
489 else
490 return x.toString();
491}
492
493function sc_jsstring2number(s, radix) {
494 if (s === "") return false;
495
496 if (radix) {
497 var t = parseInt(s, radix);
498 if (!t && t !== 0) return false;
499 // verify that each char is in range. (parseInt ignores leading
500 // white and trailing chars)
501 var allowedChars = "01234567890abcdefghijklmnopqrstuvwxyz".substring(0, radix+1);
502 if ((new RegExp("^["+allowedChars+"]*$", "i")).test(s))
503 return t;
504 else return false;
505 } else {
506 var t = +s; // does not ignore trailing chars.
507 if (!t && t !== 0) return false;
508 // simply verify that first char is not whitespace.
509 var c = s.charAt(0);
510 // if +c is 0, but the char is not "0", then we have a whitespace.
511 if (+c === 0 && c !== "0") return false;
512 return t;
513 }
514}
515
516/*** META ((export #t)
517 (type bool)
518 (peephole (not)))
519*/
520function sc_not(b) {
521 return b === false;
522}
523
524/*** META ((export #t)
525 (type bool))
526*/
527function sc_isBoolean(b) {
528 return (b === true) || (b === false);
529}
530
531function sc_Pair(car, cdr) {
532 this.car = car;
533 this.cdr = cdr;
534}
535
536sc_Pair.prototype.toString = function() {
537 return sc_toDisplayString(this);
538};
539sc_Pair.prototype.sc_toWriteOrDisplayString = function(writeOrDisplay) {
540 var current = this;
541
542 var res = "(";
543
544 while(true) {
545 res += writeOrDisplay(current.car);
546 if (sc_isPair(current.cdr)) {
547 res += " ";
548 current = current.cdr;
549 } else if (current.cdr !== null) {
550 res += " . " + writeOrDisplay(current.cdr);
551 break;
552 } else // current.cdr == null
553 break;
554 }
555
556 res += ")";
557
558 return res;
559};
560sc_Pair.prototype.sc_toDisplayString = function() {
561 return this.sc_toWriteOrDisplayString(sc_toDisplayString);
562};
563sc_Pair.prototype.sc_toWriteString = function() {
564 return this.sc_toWriteOrDisplayString(sc_toWriteString);
565};
566// sc_Pair.prototype.sc_toWriteCircleString in IO.js
567
568/*** META ((export #t)
569 (type bool)
570 (peephole (postfix " instanceof sc_Pair")))
571*/
572function sc_isPair(p) {
573 return (p instanceof sc_Pair);
574}
575
576function sc_isPairEqual(p1, p2, comp) {
577 return (comp(p1.car, p2.car) && comp(p1.cdr, p2.cdr));
578}
579
580/*** META ((export #t)
581 (peephole (hole 2 "new sc_Pair(" car ", " cdr ")")))
582*/
583function sc_cons(car, cdr) {
584 return new sc_Pair(car, cdr);
585}
586
587/*** META ((export cons*)) */
588function sc_consStar() {
589 var res = arguments[arguments.length - 1];
590 for (var i = arguments.length-2; i >= 0; i--)
591 res = new sc_Pair(arguments[i], res);
592 return res;
593}
594
595/*** META ((export #t)
596 (peephole (postfix ".car")))
597*/
598function sc_car(p) {
599 return p.car;
600}
601
602/*** META ((export #t)
603 (peephole (postfix ".cdr")))
604*/
605function sc_cdr(p) {
606 return p.cdr;
607}
608
609/*** META ((export #t)
610 (peephole (hole 2 p ".car = " val)))
611*/
612function sc_setCarBang(p, val) {
613 p.car = val;
614}
615
616/*** META ((export #t)
617 (peephole (hole 2 p ".cdr = " val)))
618*/
619function sc_setCdrBang(p, val) {
620 p.cdr = val;
621}
622
623/*** META ((export #t)
624 (peephole (postfix ".car.car")))
625*/
626function sc_caar(p) { return p.car.car; }
627/*** META ((export #t)
628 (peephole (postfix ".cdr.car")))
629*/
630function sc_cadr(p) { return p.cdr.car; }
631/*** META ((export #t)
632 (peephole (postfix ".car.cdr")))
633*/
634function sc_cdar(p) { return p.car.cdr; }
635/*** META ((export #t)
636 (peephole (postfix ".cdr.cdr")))
637*/
638function sc_cddr(p) { return p.cdr.cdr; }
639/*** META ((export #t)
640 (peephole (postfix ".car.car.car")))
641*/
642function sc_caaar(p) { return p.car.car.car; }
643/*** META ((export #t)
644 (peephole (postfix ".car.cdr.car")))
645*/
646function sc_cadar(p) { return p.car.cdr.car; }
647/*** META ((export #t)
648 (peephole (postfix ".cdr.car.car")))
649*/
650function sc_caadr(p) { return p.cdr.car.car; }
651/*** META ((export #t)
652 (peephole (postfix ".cdr.cdr.car")))
653*/
654function sc_caddr(p) { return p.cdr.cdr.car; }
655/*** META ((export #t)
656 (peephole (postfix ".car.car.cdr")))
657*/
658function sc_cdaar(p) { return p.car.car.cdr; }
659/*** META ((export #t)
660 (peephole (postfix ".cdr.car.cdr")))
661*/
662function sc_cdadr(p) { return p.cdr.car.cdr; }
663/*** META ((export #t)
664 (peephole (postfix ".car.cdr.cdr")))
665*/
666function sc_cddar(p) { return p.car.cdr.cdr; }
667/*** META ((export #t)
668 (peephole (postfix ".cdr.cdr.cdr")))
669*/
670function sc_cdddr(p) { return p.cdr.cdr.cdr; }
671/*** META ((export #t)
672 (peephole (postfix ".car.car.car.car")))
673*/
674function sc_caaaar(p) { return p.car.car.car.car; }
675/*** META ((export #t)
676 (peephole (postfix ".car.cdr.car.car")))
677*/
678function sc_caadar(p) { return p.car.cdr.car.car; }
679/*** META ((export #t)
680 (peephole (postfix ".cdr.car.car.car")))
681*/
682function sc_caaadr(p) { return p.cdr.car.car.car; }
683/*** META ((export #t)
684 (peephole (postfix ".cdr.cdr.car.car")))
685*/
686function sc_caaddr(p) { return p.cdr.cdr.car.car; }
687/*** META ((export #t)
688 (peephole (postfix ".car.car.car.cdr")))
689*/
690function sc_cdaaar(p) { return p.car.car.car.cdr; }
691/*** META ((export #t)
692 (peephole (postfix ".car.cdr.car.cdr")))
693*/
694function sc_cdadar(p) { return p.car.cdr.car.cdr; }
695/*** META ((export #t)
696 (peephole (postfix ".cdr.car.car.cdr")))
697*/
698function sc_cdaadr(p) { return p.cdr.car.car.cdr; }
699/*** META ((export #t)
700 (peephole (postfix ".cdr.cdr.car.cdr")))
701*/
702function sc_cdaddr(p) { return p.cdr.cdr.car.cdr; }
703/*** META ((export #t)
704 (peephole (postfix ".car.car.cdr.car")))
705*/
706function sc_cadaar(p) { return p.car.car.cdr.car; }
707/*** META ((export #t)
708 (peephole (postfix ".car.cdr.cdr.car")))
709*/
710function sc_caddar(p) { return p.car.cdr.cdr.car; }
711/*** META ((export #t)
712 (peephole (postfix ".cdr.car.cdr.car")))
713*/
714function sc_cadadr(p) { return p.cdr.car.cdr.car; }
715/*** META ((export #t)
716 (peephole (postfix ".cdr.cdr.cdr.car")))
717*/
718function sc_cadddr(p) { return p.cdr.cdr.cdr.car; }
719/*** META ((export #t)
720 (peephole (postfix ".car.car.cdr.cdr")))
721*/
722function sc_cddaar(p) { return p.car.car.cdr.cdr; }
723/*** META ((export #t)
724 (peephole (postfix ".car.cdr.cdr.cdr")))
725*/
726function sc_cdddar(p) { return p.car.cdr.cdr.cdr; }
727/*** META ((export #t)
728 (peephole (postfix ".cdr.car.cdr.cdr")))
729*/
730function sc_cddadr(p) { return p.cdr.car.cdr.cdr; }
731/*** META ((export #t)
732 (peephole (postfix ".cdr.cdr.cdr.cdr")))
733*/
734function sc_cddddr(p) { return p.cdr.cdr.cdr.cdr; }
735
736/*** META ((export #t)) */
737function sc_lastPair(l) {
738 if (!sc_isPair(l)) sc_error("sc_lastPair: pair expected");
739 var res = l;
740 var cdr = l.cdr;
741 while (sc_isPair(cdr)) {
742 res = cdr;
743 cdr = res.cdr;
744 }
745 return res;
746}
747
748/*** META ((export #t)
749 (type bool)
750 (peephole (postfix " === null")))
751*/
752function sc_isNull(o) {
753 return (o === null);
754}
755
756/*** META ((export #t)
757 (type bool))
758*/
759function sc_isList(o) {
760 var rabbit;
761 var turtle;
762
763 var rabbit = o;
764 var turtle = o;
765 while (true) {
766 if (rabbit === null ||
767 (rabbit instanceof sc_Pair && rabbit.cdr === null))
768 return true; // end of list
769 else if ((rabbit instanceof sc_Pair) &&
770 (rabbit.cdr instanceof sc_Pair)) {
771 rabbit = rabbit.cdr.cdr;
772 turtle = turtle.cdr;
773 if (rabbit === turtle) return false; // cycle
774 } else
775 return false; // not pair
776 }
777}
778
779/*** META ((export #t)) */
780function sc_list() {
781 var res = null;
782 var a = arguments;
783 for (var i = a.length-1; i >= 0; i--)
784 res = new sc_Pair(a[i], res);
785 return res;
786}
787
788/*** META ((export #t)) */
789function sc_iota(num, init) {
790 var res = null;
791 if (!init) init = 0;
792 for (var i = num - 1; i >= 0; i--)
793 res = new sc_Pair(i + init, res);
794 return res;
795}
796
797/*** META ((export #t)) */
798function sc_makeList(nbEls, fill) {
799 var res = null;
800 for (var i = 0; i < nbEls; i++)
801 res = new sc_Pair(fill, res);
802 return res;
803}
804
805/*** META ((export #t)) */
806function sc_length(l) {
807 var res = 0;
808 while (l !== null) {
809 res++;
810 l = l.cdr;
811 }
812 return res;
813}
814
815/*** META ((export #t)) */
816function sc_remq(o, l) {
817 var dummy = { cdr : null };
818 var tail = dummy;
819 while (l !== null) {
820 if (l.car !== o) {
821 tail.cdr = sc_cons(l.car, null);
822 tail = tail.cdr;
823 }
824 l = l.cdr;
825 }
826 return dummy.cdr;
827}
828
829/*** META ((export #t)) */
830function sc_remqBang(o, l) {
831 var dummy = { cdr : null };
832 var tail = dummy;
833 var needsAssig = true;
834 while (l !== null) {
835 if (l.car === o) {
836 needsAssig = true;
837 } else {
838 if (needsAssig) {
839 tail.cdr = l;
840 needsAssig = false;
841 }
842 tail = l;
843 }
844 l = l.cdr;
845 }
846 tail.cdr = null;
847 return dummy.cdr;
848}
849
850/*** META ((export #t)) */
851function sc_delete(o, l) {
852 var dummy = { cdr : null };
853 var tail = dummy;
854 while (l !== null) {
855 if (!sc_isEqual(l.car, o)) {
856 tail.cdr = sc_cons(l.car, null);
857 tail = tail.cdr;
858 }
859 l = l.cdr;
860 }
861 return dummy.cdr;
862}
863
864/*** META ((export #t)) */
865function sc_deleteBang(o, l) {
866 var dummy = { cdr : null };
867 var tail = dummy;
868 var needsAssig = true;
869 while (l !== null) {
870 if (sc_isEqual(l.car, o)) {
871 needsAssig = true;
872 } else {
873 if (needsAssig) {
874 tail.cdr = l;
875 needsAssig = false;
876 }
877 tail = l;
878 }
879 l = l.cdr;
880 }
881 tail.cdr = null;
882 return dummy.cdr;
883}
884
885function sc_reverseAppendBang(l1, l2) {
886 var res = l2;
887 while (l1 !== null) {
888 var tmp = res;
889 res = l1;
890 l1 = l1.cdr;
891 res.cdr = tmp;
892 }
893 return res;
894}
895
896function sc_dualAppend(l1, l2) {
897 if (l1 === null) return l2;
898 if (l2 === null) return l1;
899 var rev = sc_reverse(l1);
900 return sc_reverseAppendBang(rev, l2);
901}
902
903/*** META ((export #t)) */
904function sc_append() {
905 if (arguments.length === 0)
906 return null;
907 var res = arguments[arguments.length - 1];
908 for (var i = arguments.length - 2; i >= 0; i--)
909 res = sc_dualAppend(arguments[i], res);
910 return res;
911}
912
913function sc_dualAppendBang(l1, l2) {
914 if (l1 === null) return l2;
915 if (l2 === null) return l1;
916 var tmp = l1;
917 while (tmp.cdr !== null) tmp=tmp.cdr;
918 tmp.cdr = l2;
919 return l1;
920}
921
922/*** META ((export #t)) */
923function sc_appendBang() {
924 var res = null;
925 for (var i = 0; i < arguments.length; i++)
926 res = sc_dualAppendBang(res, arguments[i]);
927 return res;
928}
929
930/*** META ((export #t)) */
931function sc_reverse(l1) {
932 var res = null;
933 while (l1 !== null) {
934 res = sc_cons(l1.car, res);
935 l1 = l1.cdr;
936 }
937 return res;
938}
939
940/*** META ((export #t)) */
941function sc_reverseBang(l) {
942 return sc_reverseAppendBang(l, null);
943}
944
945/*** META ((export #t)) */
946function sc_listTail(l, k) {
947 var res = l;
948 for (var i = 0; i < k; i++) {
949 res = res.cdr;
950 }
951 return res;
952}
953
954/*** META ((export #t)) */
955function sc_listRef(l, k) {
956 return sc_listTail(l, k).car;
957}
958
959/* // unoptimized generic versions
960function sc_memX(o, l, comp) {
961 while (l != null) {
962 if (comp(l.car, o))
963 return l;
964 l = l.cdr;
965 }
966 return false;
967}
968function sc_memq(o, l) { return sc_memX(o, l, sc_isEq); }
969function sc_memv(o, l) { return sc_memX(o, l, sc_isEqv); }
970function sc_member(o, l) { return sc_memX(o, l, sc_isEqual); }
971*/
972
973/* optimized versions */
974/*** META ((export #t)) */
975function sc_memq(o, l) {
976 while (l !== null) {
977 if (l.car === o)
978 return l;
979 l = l.cdr;
980 }
981 return false;
982}
983/*** META ((export #t)) */
984function sc_memv(o, l) {
985 while (l !== null) {
986 if (l.car === o)
987 return l;
988 l = l.cdr;
989 }
990 return false;
991}
992/*** META ((export #t)) */
993function sc_member(o, l) {
994 while (l !== null) {
995 if (sc_isEqual(l.car,o))
996 return l;
997 l = l.cdr;
998 }
999 return false;
1000}
1001
1002/* // generic unoptimized versions
1003function sc_assX(o, al, comp) {
1004 while (al != null) {
1005 if (comp(al.car.car, o))
1006 return al.car;
1007 al = al.cdr;
1008 }
1009 return false;
1010}
1011function sc_assq(o, al) { return sc_assX(o, al, sc_isEq); }
1012function sc_assv(o, al) { return sc_assX(o, al, sc_isEqv); }
1013function sc_assoc(o, al) { return sc_assX(o, al, sc_isEqual); }
1014*/
1015// optimized versions
1016/*** META ((export #t)) */
1017function sc_assq(o, al) {
1018 while (al !== null) {
1019 if (al.car.car === o)
1020 return al.car;
1021 al = al.cdr;
1022 }
1023 return false;
1024}
1025/*** META ((export #t)) */
1026function sc_assv(o, al) {
1027 while (al !== null) {
1028 if (al.car.car === o)
1029 return al.car;
1030 al = al.cdr;
1031 }
1032 return false;
1033}
1034/*** META ((export #t)) */
1035function sc_assoc(o, al) {
1036 while (al !== null) {
1037 if (sc_isEqual(al.car.car, o))
1038 return al.car;
1039 al = al.cdr;
1040 }
1041 return false;
1042}
1043
1044/* can be used for mutable strings and characters */
1045function sc_isCharStringEqual(cs1, cs2) { return cs1.val === cs2.val; }
1046function sc_isCharStringLess(cs1, cs2) { return cs1.val < cs2.val; }
1047function sc_isCharStringGreater(cs1, cs2) { return cs1.val > cs2.val; }
1048function sc_isCharStringLessEqual(cs1, cs2) { return cs1.val <= cs2.val; }
1049function sc_isCharStringGreaterEqual(cs1, cs2) { return cs1.val >= cs2.val; }
1050function sc_isCharStringCIEqual(cs1, cs2)
1051 { return cs1.val.toLowerCase() === cs2.val.toLowerCase(); }
1052function sc_isCharStringCILess(cs1, cs2)
1053 { return cs1.val.toLowerCase() < cs2.val.toLowerCase(); }
1054function sc_isCharStringCIGreater(cs1, cs2)
1055 { return cs1.val.toLowerCase() > cs2.val.toLowerCase(); }
1056function sc_isCharStringCILessEqual(cs1, cs2)
1057 { return cs1.val.toLowerCase() <= cs2.val.toLowerCase(); }
1058function sc_isCharStringCIGreaterEqual(cs1, cs2)
1059 { return cs1.val.toLowerCase() >= cs2.val.toLowerCase(); }
1060
1061
1062
1063
1064function sc_Char(c) {
1065 var cached = sc_Char.lazy[c];
1066 if (cached)
1067 return cached;
1068 this.val = c;
1069 sc_Char.lazy[c] = this;
1070 // add return, so FF does not complain.
1071 return undefined;
1072}
1073sc_Char.lazy = new Object();
1074// thanks to Eric
1075sc_Char.char2readable = {
1076 "\000": "#\\null",
1077 "\007": "#\\bell",
1078 "\010": "#\\backspace",
1079 "\011": "#\\tab",
1080 "\012": "#\\newline",
1081 "\014": "#\\page",
1082 "\015": "#\\return",
1083 "\033": "#\\escape",
1084 "\040": "#\\space",
1085 "\177": "#\\delete",
1086
1087 /* poeticless names */
1088 "\001": "#\\soh",
1089 "\002": "#\\stx",
1090 "\003": "#\\etx",
1091 "\004": "#\\eot",
1092 "\005": "#\\enq",
1093 "\006": "#\\ack",
1094
1095 "\013": "#\\vt",
1096 "\016": "#\\so",
1097 "\017": "#\\si",
1098
1099 "\020": "#\\dle",
1100 "\021": "#\\dc1",
1101 "\022": "#\\dc2",
1102 "\023": "#\\dc3",
1103 "\024": "#\\dc4",
1104 "\025": "#\\nak",
1105 "\026": "#\\syn",
1106 "\027": "#\\etb",
1107
1108 "\030": "#\\can",
1109 "\031": "#\\em",
1110 "\032": "#\\sub",
1111 "\033": "#\\esc",
1112 "\034": "#\\fs",
1113 "\035": "#\\gs",
1114 "\036": "#\\rs",
1115 "\037": "#\\us"};
1116
1117sc_Char.readable2char = {
1118 "null": "\000",
1119 "bell": "\007",
1120 "backspace": "\010",
1121 "tab": "\011",
1122 "newline": "\012",
1123 "page": "\014",
1124 "return": "\015",
1125 "escape": "\033",
1126 "space": "\040",
1127 "delete": "\000",
1128 "soh": "\001",
1129 "stx": "\002",
1130 "etx": "\003",
1131 "eot": "\004",
1132 "enq": "\005",
1133 "ack": "\006",
1134 "bel": "\007",
1135 "bs": "\010",
1136 "ht": "\011",
1137 "nl": "\012",
1138 "vt": "\013",
1139 "np": "\014",
1140 "cr": "\015",
1141 "so": "\016",
1142 "si": "\017",
1143 "dle": "\020",
1144 "dc1": "\021",
1145 "dc2": "\022",
1146 "dc3": "\023",
1147 "dc4": "\024",
1148 "nak": "\025",
1149 "syn": "\026",
1150 "etb": "\027",
1151 "can": "\030",
1152 "em": "\031",
1153 "sub": "\032",
1154 "esc": "\033",
1155 "fs": "\034",
1156 "gs": "\035",
1157 "rs": "\036",
1158 "us": "\037",
1159 "sp": "\040",
1160 "del": "\177"};
1161
1162sc_Char.prototype.toString = function() {
1163 return this.val;
1164};
1165// sc_toDisplayString == toString
1166sc_Char.prototype.sc_toWriteString = function() {
1167 var entry = sc_Char.char2readable[this.val];
1168 if (entry)
1169 return entry;
1170 else
1171 return "#\\" + this.val;
1172};
1173
1174/*** META ((export #t)
1175 (type bool)
1176 (peephole (postfix "instanceof sc_Char")))
1177*/
1178function sc_isChar(c) {
1179 return (c instanceof sc_Char);
1180}
1181
1182/*** META ((export char=?)
1183 (type bool)
1184 (peephole (hole 2 c1 ".val === " c2 ".val")))
1185*/
1186var sc_isCharEqual = sc_isCharStringEqual;
1187/*** META ((export char<?)
1188 (type bool)
1189 (peephole (hole 2 c1 ".val < " c2 ".val")))
1190*/
1191var sc_isCharLess = sc_isCharStringLess;
1192/*** META ((export char>?)
1193 (type bool)
1194 (peephole (hole 2 c1 ".val > " c2 ".val")))
1195*/
1196var sc_isCharGreater = sc_isCharStringGreater;
1197/*** META ((export char<=?)
1198 (type bool)
1199 (peephole (hole 2 c1 ".val <= " c2 ".val")))
1200*/
1201var sc_isCharLessEqual = sc_isCharStringLessEqual;
1202/*** META ((export char>=?)
1203 (type bool)
1204 (peephole (hole 2 c1 ".val >= " c2 ".val")))
1205*/
1206var sc_isCharGreaterEqual = sc_isCharStringGreaterEqual;
1207/*** META ((export char-ci=?)
1208 (type bool)
1209 (peephole (hole 2 c1 ".val.toLowerCase() === " c2 ".val.toLowerCase()")))
1210*/
1211var sc_isCharCIEqual = sc_isCharStringCIEqual;
1212/*** META ((export char-ci<?)
1213 (type bool)
1214 (peephole (hole 2 c1 ".val.toLowerCase() < " c2 ".val.toLowerCase()")))
1215*/
1216var sc_isCharCILess = sc_isCharStringCILess;
1217/*** META ((export char-ci>?)
1218 (type bool)
1219 (peephole (hole 2 c1 ".val.toLowerCase() > " c2 ".val.toLowerCase()")))
1220*/
1221var sc_isCharCIGreater = sc_isCharStringCIGreater;
1222/*** META ((export char-ci<=?)
1223 (type bool)
1224 (peephole (hole 2 c1 ".val.toLowerCase() <= " c2 ".val.toLowerCase()")))
1225*/
1226var sc_isCharCILessEqual = sc_isCharStringCILessEqual;
1227/*** META ((export char-ci>=?)
1228 (type bool)
1229 (peephole (hole 2 c1 ".val.toLowerCase() >= " c2 ".val.toLowerCase()")))
1230*/
1231var sc_isCharCIGreaterEqual = sc_isCharStringCIGreaterEqual;
1232
1233var SC_NUMBER_CLASS = "0123456789";
1234var SC_WHITESPACE_CLASS = ' \r\n\t\f';
1235var SC_LOWER_CLASS = 'abcdefghijklmnopqrstuvwxyz';
1236var SC_UPPER_CLASS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
1237
1238function sc_isCharOfClass(c, cl) { return (cl.indexOf(c) != -1); }
1239/*** META ((export #t)
1240 (type bool))
1241*/
1242function sc_isCharAlphabetic(c)
1243 { return sc_isCharOfClass(c.val, SC_LOWER_CLASS) ||
1244 sc_isCharOfClass(c.val, SC_UPPER_CLASS); }
1245/*** META ((export #t)
1246 (type bool)
1247 (peephole (hole 1 "SC_NUMBER_CLASS.indexOf(" c ".val) != -1")))
1248*/
1249function sc_isCharNumeric(c)
1250 { return sc_isCharOfClass(c.val, SC_NUMBER_CLASS); }
1251/*** META ((export #t)
1252 (type bool))
1253*/
1254function sc_isCharWhitespace(c) {
1255 var tmp = c.val;
1256 return tmp === " " || tmp === "\r" || tmp === "\n" || tmp === "\t" || tmp === "\f";
1257}
1258/*** META ((export #t)
1259 (type bool)
1260 (peephole (hole 1 "SC_UPPER_CLASS.indexOf(" c ".val) != -1")))
1261*/
1262function sc_isCharUpperCase(c)
1263 { return sc_isCharOfClass(c.val, SC_UPPER_CLASS); }
1264/*** META ((export #t)
1265 (type bool)
1266 (peephole (hole 1 "SC_LOWER_CLASS.indexOf(" c ".val) != -1")))
1267*/
1268function sc_isCharLowerCase(c)
1269 { return sc_isCharOfClass(c.val, SC_LOWER_CLASS); }
1270
1271/*** META ((export #t)
1272 (peephole (postfix ".val.charCodeAt(0)")))
1273*/
1274function sc_char2integer(c)
1275 { return c.val.charCodeAt(0); }
1276/*** META ((export #t)
1277 (peephole (hole 1 "new sc_Char(String.fromCharCode(" n "))")))
1278*/
1279function sc_integer2char(n)
1280 { return new sc_Char(String.fromCharCode(n)); }
1281
1282/*** META ((export #t)
1283 (peephole (hole 1 "new sc_Char(" c ".val.toUpperCase())")))
1284*/
1285function sc_charUpcase(c)
1286 { return new sc_Char(c.val.toUpperCase()); }
1287/*** META ((export #t)
1288 (peephole (hole 1 "new sc_Char(" c ".val.toLowerCase())")))
1289*/
1290function sc_charDowncase(c)
1291 { return new sc_Char(c.val.toLowerCase()); }
1292
1293function sc_makeJSStringOfLength(k, c) {
1294 var fill;
1295 if (c === undefined)
1296 fill = " ";
1297 else
1298 fill = c;
1299 var res = "";
1300 var len = 1;
1301 // every round doubles the size of fill.
1302 while (k >= len) {
1303 if (k & len)
1304 res = res.concat(fill);
1305 fill = fill.concat(fill);
1306 len *= 2;
1307 }
1308 return res;
1309}
1310
1311function sc_makejsString(k, c) {
1312 var fill;
1313 if (c)
1314 fill = c.val;
1315 else
1316 fill = " ";
1317 return sc_makeJSStringOfLength(k, fill);
1318}
1319
1320function sc_jsstring2list(s) {
1321 var res = null;
1322 for (var i = s.length - 1; i >= 0; i--)
1323 res = sc_cons(new sc_Char(s.charAt(i)), res);
1324 return res;
1325}
1326
1327function sc_list2jsstring(l) {
1328 var a = new Array();
1329 while(l !== null) {
1330 a.push(l.car.val);
1331 l = l.cdr;
1332 }
1333 return "".concat.apply("", a);
1334}
1335
1336var sc_Vector = Array;
1337
1338sc_Vector.prototype.sc_toWriteOrDisplayString = function(writeOrDisplay) {
1339 if (this.length === 0) return "#()";
1340
1341 var res = "#(" + writeOrDisplay(this[0]);
1342 for (var i = 1; i < this.length; i++)
1343 res += " " + writeOrDisplay(this[i]);
1344 res += ")";
1345 return res;
1346};
1347sc_Vector.prototype.sc_toDisplayString = function() {
1348 return this.sc_toWriteOrDisplayString(sc_toDisplayString);
1349};
1350sc_Vector.prototype.sc_toWriteString = function() {
1351 return this.sc_toWriteOrDisplayString(sc_toWriteString);
1352};
1353
1354/*** META ((export vector? array?)
1355 (type bool)
1356 (peephole (postfix " instanceof sc_Vector")))
1357*/
1358function sc_isVector(v) {
1359 return (v instanceof sc_Vector);
1360}
1361
1362// only applies to vectors
1363function sc_isVectorEqual(v1, v2, comp) {
1364 if (v1.length !== v2.length) return false;
1365 for (var i = 0; i < v1.length; i++)
1366 if (!comp(v1[i], v2[i])) return false;
1367 return true;
1368}
1369
1370/*** META ((export make-vector make-array)) */
1371function sc_makeVector(size, fill) {
1372 var a = new sc_Vector(size);
1373 if (fill !== undefined)
1374 sc_vectorFillBang(a, fill);
1375 return a;
1376}
1377
1378/*** META ((export vector array)
1379 (peephole (vector)))
1380*/
1381function sc_vector() {
1382 var a = new sc_Vector();
1383 for (var i = 0; i < arguments.length; i++)
1384 a.push(arguments[i]);
1385 return a;
1386}
1387
1388/*** META ((export vector-length array-length)
1389 (peephole (postfix ".length")))
1390*/
1391function sc_vectorLength(v) {
1392 return v.length;
1393}
1394
1395/*** META ((export vector-ref array-ref)
1396 (peephole (hole 2 v "[" pos "]")))
1397*/
1398function sc_vectorRef(v, pos) {
1399 return v[pos];
1400}
1401
1402/*** META ((export vector-set! array-set!)
1403 (peephole (hole 3 v "[" pos "] = " val)))
1404*/
1405function sc_vectorSetBang(v, pos, val) {
1406 v[pos] = val;
1407}
1408
1409/*** META ((export vector->list array->list)) */
1410function sc_vector2list(a) {
1411 var res = null;
1412 for (var i = a.length-1; i >= 0; i--)
1413 res = sc_cons(a[i], res);
1414 return res;
1415}
1416
1417/*** META ((export list->vector list->array)) */
1418function sc_list2vector(l) {
1419 var a = new sc_Vector();
1420 while(l !== null) {
1421 a.push(l.car);
1422 l = l.cdr;
1423 }
1424 return a;
1425}
1426
1427/*** META ((export vector-fill! array-fill!)) */
1428function sc_vectorFillBang(a, fill) {
1429 for (var i = 0; i < a.length; i++)
1430 a[i] = fill;
1431}
1432
1433
1434/*** META ((export #t)) */
1435function sc_copyVector(a, len) {
1436 if (len <= a.length)
1437 return a.slice(0, len);
1438 else {
1439 var tmp = a.concat();
1440 tmp.length = len;
1441 return tmp;
1442 }
1443}
1444
1445/*** META ((export #t)
1446 (peephole (hole 3 a ".slice(" start "," end ")")))
1447*/
1448function sc_vectorCopy(a, start, end) {
1449 return a.slice(start, end);
1450}
1451
1452/*** META ((export #t)) */
1453function sc_vectorCopyBang(target, tstart, source, sstart, send) {
1454 if (!sstart) sstart = 0;
1455 if (!send) send = source.length;
1456
1457 // if target == source we don't want to overwrite not yet copied elements.
1458 if (tstart <= sstart) {
1459 for (var i = tstart, j = sstart; j < send; i++, j++) {
1460 target[i] = source[j];
1461 }
1462 } else {
1463 var diff = send - sstart;
1464 for (var i = tstart + diff - 1, j = send - 1;
1465 j >= sstart;
1466 i--, j--) {
1467 target[i] = source[j];
1468 }
1469 }
1470 return target;
1471}
1472
1473/*** META ((export #t)
1474 (type bool)
1475 (peephole (hole 1 "typeof " o " === 'function'")))
1476*/
1477function sc_isProcedure(o) {
1478 return (typeof o === "function");
1479}
1480
1481/*** META ((export #t)) */
1482function sc_apply(proc) {
1483 var args = new Array();
1484 // first part of arguments are not in list-form.
1485 for (var i = 1; i < arguments.length - 1; i++)
1486 args.push(arguments[i]);
1487 var l = arguments[arguments.length - 1];
1488 while (l !== null) {
1489 args.push(l.car);
1490 l = l.cdr;
1491 }
1492 return proc.apply(null, args);
1493}
1494
1495/*** META ((export #t)) */
1496function sc_map(proc, l1) {
1497 if (l1 === undefined)
1498 return null;
1499 // else
1500 var nbApplyArgs = arguments.length - 1;
1501 var applyArgs = new Array(nbApplyArgs);
1502 var revres = null;
1503 while (l1 !== null) {
1504 for (var i = 0; i < nbApplyArgs; i++) {
1505 applyArgs[i] = arguments[i + 1].car;
1506 arguments[i + 1] = arguments[i + 1].cdr;
1507 }
1508 revres = sc_cons(proc.apply(null, applyArgs), revres);
1509 }
1510 return sc_reverseAppendBang(revres, null);
1511}
1512
1513/*** META ((export #t)) */
1514function sc_mapBang(proc, l1) {
1515 if (l1 === undefined)
1516 return null;
1517 // else
1518 var l1_orig = l1;
1519 var nbApplyArgs = arguments.length - 1;
1520 var applyArgs = new Array(nbApplyArgs);
1521 while (l1 !== null) {
1522 var tmp = l1;
1523 for (var i = 0; i < nbApplyArgs; i++) {
1524 applyArgs[i] = arguments[i + 1].car;
1525 arguments[i + 1] = arguments[i + 1].cdr;
1526 }
1527 tmp.car = proc.apply(null, applyArgs);
1528 }
1529 return l1_orig;
1530}
1531
1532/*** META ((export #t)) */
1533function sc_forEach(proc, l1) {
1534 if (l1 === undefined)
1535 return undefined;
1536 // else
1537 var nbApplyArgs = arguments.length - 1;
1538 var applyArgs = new Array(nbApplyArgs);
1539 while (l1 !== null) {
1540 for (var i = 0; i < nbApplyArgs; i++) {
1541 applyArgs[i] = arguments[i + 1].car;
1542 arguments[i + 1] = arguments[i + 1].cdr;
1543 }
1544 proc.apply(null, applyArgs);
1545 }
1546 // add return so FF does not complain.
1547 return undefined;
1548}
1549
1550/*** META ((export #t)) */
1551function sc_filter(proc, l1) {
1552 var dummy = { cdr : null };
1553 var tail = dummy;
1554 while (l1 !== null) {
1555 if (proc(l1.car) !== false) {
1556 tail.cdr = sc_cons(l1.car, null);
1557 tail = tail.cdr;
1558 }
1559 l1 = l1.cdr;
1560 }
1561 return dummy.cdr;
1562}
1563
1564/*** META ((export #t)) */
1565function sc_filterBang(proc, l1) {
1566 var head = sc_cons("dummy", l1);
1567 var it = head;
1568 var next = l1;
1569 while (next !== null) {
1570 if (proc(next.car) !== false) {
1571 it.cdr = next
1572 it = next;
1573 }
1574 next = next.cdr;
1575 }
1576 it.cdr = null;
1577 return head.cdr;
1578}
1579
1580function sc_filterMap1(proc, l1) {
1581 var revres = null;
1582 while (l1 !== null) {
1583 var tmp = proc(l1.car)
1584 if (tmp !== false) revres = sc_cons(tmp, revres);
1585 l1 = l1.cdr;
1586 }
1587 return sc_reverseAppendBang(revres, null);
1588}
1589function sc_filterMap2(proc, l1, l2) {
1590 var revres = null;
1591 while (l1 !== null) {
1592 var tmp = proc(l1.car, l2.car);
1593 if(tmp !== false) revres = sc_cons(tmp, revres);
1594 l1 = l1.cdr;
1595 l2 = l2.cdr
1596 }
1597 return sc_reverseAppendBang(revres, null);
1598}
1599
1600/*** META ((export #t)) */
1601function sc_filterMap(proc, l1, l2, l3) {
1602 if (l2 === undefined)
1603 return sc_filterMap1(proc, l1);
1604 else if (l3 === undefined)
1605 return sc_filterMap2(proc, l1, l2);
1606 // else
1607 var nbApplyArgs = arguments.length - 1;
1608 var applyArgs = new Array(nbApplyArgs);
1609 var revres = null;
1610 while (l1 !== null) {
1611 for (var i = 0; i < nbApplyArgs; i++) {
1612 applyArgs[i] = arguments[i + 1].car;
1613 arguments[i + 1] = arguments[i + 1].cdr;
1614 }
1615 var tmp = proc.apply(null, applyArgs);
1616 if(tmp !== false) revres = sc_cons(tmp, revres);
1617 }
1618 return sc_reverseAppendBang(revres, null);
1619}
1620
1621/*** META ((export #t)) */
1622function sc_any(proc, l) {
1623 var revres = null;
1624 while (l !== null) {
1625 var tmp = proc(l.car);
1626 if(tmp !== false) return tmp;
1627 l = l.cdr;
1628 }
1629 return false;
1630}
1631
1632/*** META ((export any?)
1633 (peephole (hole 2 "sc_any(" proc "," l ") !== false")))
1634*/
1635function sc_anyPred(proc, l) {
1636 return sc_any(proc, l)!== false;
1637}
1638
1639/*** META ((export #t)) */
1640function sc_every(proc, l) {
1641 var revres = null;
1642 var tmp = true;
1643 while (l !== null) {
1644 tmp = proc(l.car);
1645 if (tmp === false) return false;
1646 l = l.cdr;
1647 }
1648 return tmp;
1649}
1650
1651/*** META ((export every?)
1652 (peephole (hole 2 "sc_every(" proc "," l ") !== false")))
1653*/
1654function sc_everyPred(proc, l) {
1655 var tmp = sc_every(proc, l);
1656 if (tmp !== false) return true;
1657 return false;
1658}
1659
1660/*** META ((export #t)
1661 (peephole (postfix "()")))
1662*/
1663function sc_force(o) {
1664 return o();
1665}
1666
1667/*** META ((export #t)) */
1668function sc_makePromise(proc) {
1669 var isResultReady = false;
1670 var result = undefined;
1671 return function() {
1672 if (!isResultReady) {
1673 var tmp = proc();
1674 if (!isResultReady) {
1675 isResultReady = true;
1676 result = tmp;
1677 }
1678 }
1679 return result;
1680 };
1681}
1682
1683function sc_Values(values) {
1684 this.values = values;
1685}
1686
1687/*** META ((export #t)
1688 (peephole (values)))
1689*/
1690function sc_values() {
1691 if (arguments.length === 1)
1692 return arguments[0];
1693 else
1694 return new sc_Values(arguments);
1695}
1696
1697/*** META ((export #t)) */
1698function sc_callWithValues(producer, consumer) {
1699 var produced = producer();
1700 if (produced instanceof sc_Values)
1701 return consumer.apply(null, produced.values);
1702 else
1703 return consumer(produced);
1704}
1705
1706/*** META ((export #t)) */
1707function sc_dynamicWind(before, thunk, after) {
1708 before();
1709 try {
1710 var res = thunk();
1711 return res;
1712 } finally {
1713 after();
1714 }
1715}
1716
1717
1718// TODO: eval/scheme-report-environment/null-environment/interaction-environment
1719
1720// LIMITATION: 'load' doesn't exist without files.
1721// LIMITATION: transcript-on/transcript-off doesn't exist without files.
1722
1723
1724function sc_Struct(name) {
1725 this.name = name;
1726}
1727sc_Struct.prototype.sc_toDisplayString = function() {
1728 return "#<struct" + sc_hash(this) + ">";
1729};
1730sc_Struct.prototype.sc_toWriteString = sc_Struct.prototype.sc_toDisplayString;
1731
1732/*** META ((export #t)
1733 (peephole (hole 1 "new sc_Struct(" name ")")))
1734*/
1735function sc_makeStruct(name) {
1736 return new sc_Struct(name);
1737}
1738
1739/*** META ((export #t)
1740 (type bool)
1741 (peephole (postfix " instanceof sc_Struct")))
1742*/
1743function sc_isStruct(o) {
1744 return (o instanceof sc_Struct);
1745}
1746
1747/*** META ((export #t)
1748 (type bool)
1749 (peephole (hole 2 "(" 1 " instanceof sc_Struct) && ( " 1 ".name === " 0 ")")))
1750*/
1751function sc_isStructNamed(name, s) {
1752 return ((s instanceof sc_Struct) && (s.name === name));
1753}
1754
1755/*** META ((export struct-field)
1756 (peephole (hole 3 0 "[" 2 "]")))
1757*/
1758function sc_getStructField(s, name, field) {
1759 return s[field];
1760}
1761
1762/*** META ((export struct-field-set!)
1763 (peephole (hole 4 0 "[" 2 "] = " 3)))
1764*/
1765function sc_setStructFieldBang(s, name, field, val) {
1766 s[field] = val;
1767}
1768
1769/*** META ((export #t)
1770 (peephole (prefix "~")))
1771*/
1772function sc_bitNot(x) {
1773 return ~x;
1774}
1775
1776/*** META ((export #t)
1777 (peephole (infix 2 2 "&")))
1778*/
1779function sc_bitAnd(x, y) {
1780 return x & y;
1781}
1782
1783/*** META ((export #t)
1784 (peephole (infix 2 2 "|")))
1785*/
1786function sc_bitOr(x, y) {
1787 return x | y;
1788}
1789
1790/*** META ((export #t)
1791 (peephole (infix 2 2 "^")))
1792*/
1793function sc_bitXor(x, y) {
1794 return x ^ y;
1795}
1796
1797/*** META ((export #t)
1798 (peephole (infix 2 2 "<<")))
1799*/
1800function sc_bitLsh(x, y) {
1801 return x << y;
1802}
1803
1804/*** META ((export #t)
1805 (peephole (infix 2 2 ">>")))
1806*/
1807function sc_bitRsh(x, y) {
1808 return x >> y;
1809}
1810
1811/*** META ((export #t)
1812 (peephole (infix 2 2 ">>>")))
1813*/
1814function sc_bitUrsh(x, y) {
1815 return x >>> y;
1816}
1817
1818/*** META ((export js-field js-property)
1819 (peephole (hole 2 o "[" field "]")))
1820*/
1821function sc_jsField(o, field) {
1822 return o[field];
1823}
1824
1825/*** META ((export js-field-set! js-property-set!)
1826 (peephole (hole 3 o "[" field "] = " val)))
1827*/
1828function sc_setJsFieldBang(o, field, val) {
1829 return o[field] = val;
1830}
1831
1832/*** META ((export js-field-delete! js-property-delete!)
1833 (peephole (hole 2 "delete" o "[" field "]")))
1834*/
1835function sc_deleteJsFieldBang(o, field) {
1836 delete o[field];
1837}
1838
1839/*** META ((export #t)
1840 (peephole (jsCall)))
1841*/
1842function sc_jsCall(o, fun) {
1843 var args = new Array();
1844 for (var i = 2; i < arguments.length; i++)
1845 args[i-2] = arguments[i];
1846 return fun.apply(o, args);
1847}
1848
1849/*** META ((export #t)
1850 (peephole (jsMethodCall)))
1851*/
1852function sc_jsMethodCall(o, field) {
1853 var args = new Array();
1854 for (var i = 2; i < arguments.length; i++)
1855 args[i-2] = arguments[i];
1856 return o[field].apply(o, args);
1857}
1858
1859/*** META ((export new js-new)
1860 (peephole (jsNew)))
1861*/
1862function sc_jsNew(c) {
1863 var evalStr = "new c(";
1864 evalStr +=arguments.length > 1? "arguments[1]": "";
1865 for (var i = 2; i < arguments.length; i++)
1866 evalStr += ", arguments[" + i + "]";
1867 evalStr +=")";
1868 return eval(evalStr);
1869}
1870
1871// ======================== RegExp ====================
1872/*** META ((export #t)) */
1873function sc_pregexp(re) {
1874 return new RegExp(sc_string2jsstring(re));
1875}
1876
1877/*** META ((export #t)) */
1878function sc_pregexpMatch(re, s) {
1879 var reg = (re instanceof RegExp) ? re : sc_pregexp(re);
1880 var tmp = reg.exec(sc_string2jsstring(s));
1881
1882 if (tmp == null) return false;
1883
1884 var res = null;
1885 for (var i = tmp.length-1; i >= 0; i--) {
1886 if (tmp[i] !== null) {
1887 res = sc_cons(sc_jsstring2string(tmp[i]), res);
1888 } else {
1889 res = sc_cons(false, res);
1890 }
1891 }
1892 return res;
1893}
1894
1895/*** META ((export #t)) */
1896function sc_pregexpReplace(re, s1, s2) {
1897 var reg;
1898 var jss1 = sc_string2jsstring(s1);
1899 var jss2 = sc_string2jsstring(s2);
1900
1901 if (re instanceof RegExp) {
1902 if (re.global)
1903 reg = re;
1904 else
1905 reg = new RegExp(re.source);
1906 } else {
1907 reg = new RegExp(sc_string2jsstring(re));
1908 }
1909
1910 return jss1.replace(reg, jss2);
1911}
1912
1913/*** META ((export pregexp-replace*)) */
1914function sc_pregexpReplaceAll(re, s1, s2) {
1915 var reg;
1916 var jss1 = sc_string2jsstring(s1);
1917 var jss2 = sc_string2jsstring(s2);
1918
1919 if (re instanceof RegExp) {
1920 if (re.global)
1921 reg = re;
1922 else
1923 reg = new RegExp(re.source, "g");
1924 } else {
1925 reg = new RegExp(sc_string2jsstring(re), "g");
1926 }
1927
1928 return jss1.replace(reg, jss2);
1929}
1930
1931/*** META ((export #t)) */
1932function sc_pregexpSplit(re, s) {
1933 var reg = ((re instanceof RegExp) ?
1934 re :
1935 new RegExp(sc_string2jsstring(re)));
1936 var jss = sc_string2jsstring(s);
1937 var tmp = jss.split(reg);
1938
1939 if (tmp == null) return false;
1940
1941 return sc_vector2list(tmp);
1942}
1943
1944
1945/* =========================================================================== */
1946/* Other library stuff */
1947/* =========================================================================== */
1948
1949/*** META ((export #t)
1950 (peephole (hole 1 "Math.floor(Math.random()*" 'n ")")))
1951*/
1952function sc_random(n) {
1953 return Math.floor(Math.random()*n);
1954}
1955
1956/*** META ((export current-date)
1957 (peephole (hole 0 "new Date()")))
1958*/
1959function sc_currentDate() {
1960 return new Date();
1961}
1962
1963function sc_Hashtable() {
1964}
1965sc_Hashtable.prototype.toString = function() {
1966 return "#{%hashtable}";
1967};
1968// sc_toWriteString == sc_toDisplayString == toString
1969
1970function sc_HashtableElement(key, val) {
1971 this.key = key;
1972 this.val = val;
1973}
1974
1975/*** META ((export #t)
1976 (peephole (hole 0 "new sc_Hashtable()")))
1977*/
1978function sc_makeHashtable() {
1979 return new sc_Hashtable();
1980}
1981
1982/*** META ((export #t)) */
1983function sc_hashtablePutBang(ht, key, val) {
1984 var hash = sc_hash(key);
1985 ht[hash] = new sc_HashtableElement(key, val);
1986}
1987
1988/*** META ((export #t)) */
1989function sc_hashtableGet(ht, key) {
1990 var hash = sc_hash(key);
1991 if (hash in ht)
1992 return ht[hash].val;
1993 else
1994 return false;
1995}
1996
1997/*** META ((export #t)) */
1998function sc_hashtableForEach(ht, f) {
1999 for (var v in ht) {
2000 if (ht[v] instanceof sc_HashtableElement)
2001 f(ht[v].key, ht[v].val);
2002 }
2003}
2004
2005/*** META ((export hashtable-contains?)
2006 (peephole (hole 2 "sc_hash(" 1 ") in " 0)))
2007*/
2008function sc_hashtableContains(ht, key) {
2009 var hash = sc_hash(key);
2010 if (hash in ht)
2011 return true;
2012 else
2013 return false;
2014}
2015
2016var SC_HASH_COUNTER = 0;
2017
2018function sc_hash(o) {
2019 if (o === null)
2020 return "null";
2021 else if (o === undefined)
2022 return "undefined";
2023 else if (o === true)
2024 return "true";
2025 else if (o === false)
2026 return "false";
2027 else if (typeof o === "number")
2028 return "num-" + o;
2029 else if (typeof o === "string")
2030 return "jsstr-" + o;
2031 else if (o.sc_getHash)
2032 return o.sc_getHash();
2033 else
2034 return sc_counterHash.call(o);
2035}
2036function sc_counterHash() {
2037 if (!this.sc_hash) {
2038 this.sc_hash = "hash-" + SC_HASH_COUNTER;
2039 SC_HASH_COUNTER++;
2040 }
2041 return this.sc_hash;
2042}
2043
2044function sc_Trampoline(args, maxTailCalls) {
2045 this['__trampoline return__'] = true;
2046 this.args = args;
2047 this.MAX_TAIL_CALLs = maxTailCalls;
2048}
2049// TODO: call/cc stuff
2050sc_Trampoline.prototype.restart = function() {
2051 var o = this;
2052 while (true) {
2053 // set both globals.
2054 SC_TAIL_OBJECT.calls = o.MAX_TAIL_CALLs-1;
2055 var fun = o.args.callee;
2056 var res = fun.apply(SC_TAIL_OBJECT, o.args);
2057 if (res instanceof sc_Trampoline)
2058 o = res;
2059 else
2060 return res;
2061 }
2062}
2063
2064/*** META ((export bind-exit-lambda)) */
2065function sc_bindExitLambda(proc) {
2066 var escape_obj = new sc_BindExitException();
2067 var escape = function(res) {
2068 escape_obj.res = res;
2069 throw escape_obj;
2070 };
2071 try {
2072 return proc(escape);
2073 } catch(e) {
2074 if (e === escape_obj) {
2075 return e.res;
2076 }
2077 throw e;
2078 }
2079}
2080function sc_BindExitException() {
2081 this._internalException = true;
2082}
2083
2084var SC_SCM2JS_GLOBALS = new Object();
2085
2086// default tail-call depth.
2087// normally the program should set it again. but just in case...
2088var SC_TAIL_OBJECT = new Object();
2089SC_SCM2JS_GLOBALS.TAIL_OBJECT = SC_TAIL_OBJECT;
2090// ======================== I/O =======================
2091
2092/*------------------------------------------------------------------*/
2093
2094function sc_EOF() {
2095}
2096var SC_EOF_OBJECT = new sc_EOF();
2097
2098function sc_Port() {
2099}
2100
2101/* --------------- Input ports -------------------------------------*/
2102
2103function sc_InputPort() {
2104}
2105sc_InputPort.prototype = new sc_Port();
2106
2107sc_InputPort.prototype.peekChar = function() {
2108 if (!("peeked" in this))
2109 this.peeked = this.getNextChar();
2110 return this.peeked;
2111}
2112sc_InputPort.prototype.readChar = function() {
2113 var tmp = this.peekChar();
2114 delete this.peeked;
2115 return tmp;
2116}
2117sc_InputPort.prototype.isCharReady = function() {
2118 return true;
2119}
2120sc_InputPort.prototype.close = function() {
2121 // do nothing
2122}
2123
2124/* .............. String port ..........................*/
2125function sc_ErrorInputPort() {
2126};
2127sc_ErrorInputPort.prototype = new sc_InputPort();
2128sc_ErrorInputPort.prototype.getNextChar = function() {
2129 throw "can't read from error-port.";
2130};
2131sc_ErrorInputPort.prototype.isCharReady = function() {
2132 return false;
2133};
2134
2135
2136/* .............. String port ..........................*/
2137
2138function sc_StringInputPort(jsStr) {
2139 // we are going to do some charAts on the str.
2140 // instead of recreating all the time a String-object, we
2141 // create one in the beginning. (not sure, if this is really an optim)
2142 this.str = new String(jsStr);
2143 this.pos = 0;
2144}
2145sc_StringInputPort.prototype = new sc_InputPort();
2146sc_StringInputPort.prototype.getNextChar = function() {
2147 if (this.pos >= this.str.length)
2148 return SC_EOF_OBJECT;
2149 return this.str.charAt(this.pos++);
2150};
2151
2152/* ------------- Read and other lib-funs -------------------------------*/
2153function sc_Token(type, val, pos) {
2154 this.type = type;
2155 this.val = val;
2156 this.pos = pos;
2157}
2158sc_Token.EOF = 0/*EOF*/;
2159sc_Token.OPEN_PAR = 1/*OPEN_PAR*/;
2160sc_Token.CLOSE_PAR = 2/*CLOSE_PAR*/;
2161sc_Token.OPEN_BRACE = 3/*OPEN_BRACE*/;
2162sc_Token.CLOSE_BRACE = 4/*CLOSE_BRACE*/;
2163sc_Token.OPEN_BRACKET = 5/*OPEN_BRACKET*/;
2164sc_Token.CLOSE_BRACKET = 6/*CLOSE_BRACKET*/;
2165sc_Token.WHITESPACE = 7/*WHITESPACE*/;
2166sc_Token.QUOTE = 8/*QUOTE*/;
2167sc_Token.ID = 9/*ID*/;
2168sc_Token.DOT = 10/*DOT*/;
2169sc_Token.STRING = 11/*STRING*/;
2170sc_Token.NUMBER = 12/*NUMBER*/;
2171sc_Token.ERROR = 13/*ERROR*/;
2172sc_Token.VECTOR_BEGIN = 14/*VECTOR_BEGIN*/;
2173sc_Token.TRUE = 15/*TRUE*/;
2174sc_Token.FALSE = 16/*FALSE*/;
2175sc_Token.UNSPECIFIED = 17/*UNSPECIFIED*/;
2176sc_Token.REFERENCE = 18/*REFERENCE*/;
2177sc_Token.STORE = 19/*STORE*/;
2178sc_Token.CHAR = 20/*CHAR*/;
2179
2180var SC_ID_CLASS = SC_LOWER_CLASS + SC_UPPER_CLASS + "!$%*+-./:<=>?@^_~";
2181function sc_Tokenizer(port) {
2182 this.port = port;
2183}
2184sc_Tokenizer.prototype.peekToken = function() {
2185 if (this.peeked)
2186 return this.peeked;
2187 var newToken = this.nextToken();
2188 this.peeked = newToken;
2189 return newToken;
2190};
2191sc_Tokenizer.prototype.readToken = function() {
2192 var tmp = this.peekToken();
2193 delete this.peeked;
2194 return tmp;
2195};
2196sc_Tokenizer.prototype.nextToken = function() {
2197 var port = this.port;
2198
2199 function isNumberChar(c) {
2200 return (c >= "0" && c <= "9");
2201 };
2202 function isIdOrNumberChar(c) {
2203 return SC_ID_CLASS.indexOf(c) != -1 || // ID-char
2204 (c >= "0" && c <= "9");
2205 }
2206 function isWhitespace(c) {
2207 return c === " " || c === "\r" || c === "\n" || c === "\t" || c === "\f";
2208 };
2209 function isWhitespaceOrEOF(c) {
2210 return isWhitespace(c) || c === SC_EOF_OBJECT;
2211 };
2212
2213 function readString() {
2214 res = "";
2215 while (true) {
2216 var c = port.readChar();
2217 switch (c) {
2218 case '"':
2219 return new sc_Token(11/*STRING*/, res);
2220 case "\\":
2221 var tmp = port.readChar();
2222 switch (tmp) {
2223 case '0': res += "\0"; break;
2224 case 'a': res += "\a"; break;
2225 case 'b': res += "\b"; break;
2226 case 'f': res += "\f"; break;
2227 case 'n': res += "\n"; break;
2228 case 'r': res += "\r"; break;
2229 case 't': res += "\t"; break;
2230 case 'v': res += "\v"; break;
2231 case '"': res += '"'; break;
2232 case '\\': res += '\\'; break;
2233 case 'x':
2234 /* hexa-number */
2235 var nb = 0;
2236 while (true) {
2237 var hexC = port.peekChar();
2238 if (hexC >= '0' && hexC <= '9') {
2239 port.readChar();
2240 nb = nb * 16 + hexC.charCodeAt(0) - '0'.charCodeAt(0);
2241 } else if (hexC >= 'a' && hexC <= 'f') {
2242 port.readChar();
2243 nb = nb * 16 + hexC.charCodeAt(0) - 'a'.charCodeAt(0);
2244 } else if (hexC >= 'A' && hexC <= 'F') {
2245 port.readChar();
2246 nb = nb * 16 + hexC.charCodeAt(0) - 'A'.charCodeAt(0);
2247 } else {
2248 // next char isn't part of hex.
2249 res += String.fromCharCode(nb);
2250 break;
2251 }
2252 }
2253 break;
2254 default:
2255 if (tmp === SC_EOF_OBJECT) {
2256 return new sc_Token(13/*ERROR*/, "unclosed string-literal" + res);
2257 }
2258 res += tmp;
2259 }
2260 break;
2261 default:
2262 if (c === SC_EOF_OBJECT) {
2263 return new sc_Token(13/*ERROR*/, "unclosed string-literal" + res);
2264 }
2265 res += c;
2266 }
2267 }
2268 };
2269 function readIdOrNumber(firstChar) {
2270 var res = firstChar;
2271 while (isIdOrNumberChar(port.peekChar()))
2272 res += port.readChar();
2273 if (isNaN(res))
2274 return new sc_Token(9/*ID*/, res);
2275 else
2276 return new sc_Token(12/*NUMBER*/, res - 0);
2277 };
2278
2279 function skipWhitespaceAndComments() {
2280 var done = false;
2281 while (!done) {
2282 done = true;
2283 while (isWhitespace(port.peekChar()))
2284 port.readChar();
2285 if (port.peekChar() === ';') {
2286 port.readChar();
2287 done = false;
2288 while (true) {
2289 curChar = port.readChar();
2290 if (curChar === SC_EOF_OBJECT ||
2291 curChar === '\n')
2292 break;
2293 }
2294 }
2295 }
2296 };
2297
2298 function readDot() {
2299 if (isWhitespace(port.peekChar()))
2300 return new sc_Token(10/*DOT*/);
2301 else
2302 return readIdOrNumber(".");
2303 };
2304
2305 function readSharp() {
2306 var c = port.readChar();
2307 if (isWhitespace(c))
2308 return new sc_Token(13/*ERROR*/, "bad #-pattern0.");
2309
2310 // reference
2311 if (isNumberChar(c)) {
2312 var nb = c - 0;
2313 while (isNumberChar(port.peekChar()))
2314 nb = nb*10 + (port.readChar() - 0);
2315 switch (port.readChar()) {
2316 case '#':
2317 return new sc_Token(18/*REFERENCE*/, nb);
2318 case '=':
2319 return new sc_Token(19/*STORE*/, nb);
2320 default:
2321 return new sc_Token(13/*ERROR*/, "bad #-pattern1." + nb);
2322 }
2323 }
2324
2325 if (c === "(")
2326 return new sc_Token(14/*VECTOR_BEGIN*/);
2327
2328 if (c === "\\") { // character
2329 var tmp = ""
2330 while (!isWhitespaceOrEOF(port.peekChar()))
2331 tmp += port.readChar();
2332 switch (tmp.length) {
2333 case 0: // it's escaping a whitespace char:
2334 if (sc_isEOFObject(port.peekChar))
2335 return new sc_Token(13/*ERROR*/, "bad #-pattern2.");
2336 else
2337 return new sc_Token(20/*CHAR*/, port.readChar());
2338 case 1:
2339 return new sc_Token(20/*CHAR*/, tmp);
2340 default:
2341 var entry = sc_Char.readable2char[tmp.toLowerCase()];
2342 if (entry)
2343 return new sc_Token(20/*CHAR*/, entry);
2344 else
2345 return new sc_Token(13/*ERROR*/, "unknown character description: #\\" + tmp);
2346 }
2347 }
2348
2349 // some constants (#t, #f, #unspecified)
2350 var res;
2351 var needing;
2352 switch (c) {
2353 case 't': res = new sc_Token(15/*TRUE*/, true); needing = ""; break;
2354 case 'f': res = new sc_Token(16/*FALSE*/, false); needing = ""; break;
2355 case 'u': res = new sc_Token(17/*UNSPECIFIED*/, undefined); needing = "nspecified"; break;
2356 default:
2357 return new sc_Token(13/*ERROR*/, "bad #-pattern3: " + c);
2358 }
2359 while(true) {
2360 c = port.peekChar();
2361 if ((isWhitespaceOrEOF(c) || c === ')') &&
2362 needing == "")
2363 return res;
2364 else if (isWhitespace(c) || needing == "")
2365 return new sc_Token(13/*ERROR*/, "bad #-pattern4 " + c + " " + needing);
2366 else if (needing.charAt(0) == c) {
2367 port.readChar(); // consume
2368 needing = needing.slice(1);
2369 } else
2370 return new sc_Token(13/*ERROR*/, "bad #-pattern5");
2371 }
2372
2373 };
2374
2375 skipWhitespaceAndComments();
2376 var curChar = port.readChar();
2377 if (curChar === SC_EOF_OBJECT)
2378 return new sc_Token(0/*EOF*/, curChar);
2379 switch (curChar)
2380 {
2381 case " ":
2382 case "\n":
2383 case "\t":
2384 return readWhitespace();
2385 case "(":
2386 return new sc_Token(1/*OPEN_PAR*/);
2387 case ")":
2388 return new sc_Token(2/*CLOSE_PAR*/);
2389 case "{":
2390 return new sc_Token(3/*OPEN_BRACE*/);
2391 case "}":
2392 return new sc_Token(4/*CLOSE_BRACE*/);
2393 case "[":
2394 return new sc_Token(5/*OPEN_BRACKET*/);
2395 case "]":
2396 return new sc_Token(6/*CLOSE_BRACKET*/);
2397 case "'":
2398 return new sc_Token(8/*QUOTE*/);
2399 case "#":
2400 return readSharp();
2401 case ".":
2402 return readDot();
2403 case '"':
2404 return readString();
2405 default:
2406 if (isIdOrNumberChar(curChar))
2407 return readIdOrNumber(curChar);
2408 throw "unexpected character: " + curChar;
2409 }
2410};
2411
2412function sc_Reader(tokenizer) {
2413 this.tokenizer = tokenizer;
2414 this.backref = new Array();
2415}
2416sc_Reader.prototype.read = function() {
2417 function readList(listBeginType) {
2418 function matchesPeer(open, close) {
2419 return open === 1/*OPEN_PAR*/ && close === 2/*CLOSE_PAR*/
2420 || open === 3/*OPEN_BRACE*/ && close === 4/*CLOSE_BRACE*/
2421 || open === 5/*OPEN_BRACKET*/ && close === 6/*CLOSE_BRACKET*/;
2422 };
2423 var res = null;
2424
2425 while (true) {
2426 var token = tokenizer.peekToken();
2427
2428 switch (token.type) {
2429 case 2/*CLOSE_PAR*/:
2430 case 4/*CLOSE_BRACE*/:
2431 case 6/*CLOSE_BRACKET*/:
2432 if (matchesPeer(listBeginType, token.type)) {
2433 tokenizer.readToken(); // consume token
2434 return sc_reverseBang(res);
2435 } else
2436 throw "closing par doesn't match: " + listBeginType
2437 + " " + listEndType;
2438
2439 case 0/*EOF*/:
2440 throw "unexpected end of file";
2441
2442 case 10/*DOT*/:
2443 tokenizer.readToken(); // consume token
2444 var cdr = this.read();
2445 var par = tokenizer.readToken();
2446 if (!matchesPeer(listBeginType, par.type))
2447 throw "closing par doesn't match: " + listBeginType
2448 + " " + par.type;
2449 else
2450 return sc_reverseAppendBang(res, cdr);
2451
2452
2453 default:
2454 res = sc_cons(this.read(), res);
2455 }
2456 }
2457 };
2458 function readQuote() {
2459 return sc_cons("quote", sc_cons(this.read(), null));
2460 };
2461 function readVector() {
2462 // opening-parenthesis is already consumed
2463 var a = new Array();
2464 while (true) {
2465 var token = tokenizer.peekToken();
2466 switch (token.type) {
2467 case 2/*CLOSE_PAR*/:
2468 tokenizer.readToken();
2469 return a;
2470
2471 default:
2472 a.push(this.read());
2473 }
2474 }
2475 };
2476
2477 function storeRefence(nb) {
2478 var tmp = this.read();
2479 this.backref[nb] = tmp;
2480 return tmp;
2481 };
2482
2483 function readReference(nb) {
2484 if (nb in this.backref)
2485 return this.backref[nb];
2486 else
2487 throw "bad reference: " + nb;
2488 };
2489
2490 var tokenizer = this.tokenizer;
2491
2492 var token = tokenizer.readToken();
2493
2494 // handle error
2495 if (token.type === 13/*ERROR*/)
2496 throw token.val;
2497
2498 switch (token.type) {
2499 case 1/*OPEN_PAR*/:
2500 case 3/*OPEN_BRACE*/:
2501 case 5/*OPEN_BRACKET*/:
2502 return readList.call(this, token.type);
2503 case 8/*QUOTE*/:
2504 return readQuote.call(this);
2505 case 11/*STRING*/:
2506 return sc_jsstring2string(token.val);
2507 case 20/*CHAR*/:
2508 return new sc_Char(token.val);
2509 case 14/*VECTOR_BEGIN*/:
2510 return readVector.call(this);
2511 case 18/*REFERENCE*/:
2512 return readReference.call(this, token.val);
2513 case 19/*STORE*/:
2514 return storeRefence.call(this, token.val);
2515 case 9/*ID*/:
2516 return sc_jsstring2symbol(token.val);
2517 case 0/*EOF*/:
2518 case 12/*NUMBER*/:
2519 case 15/*TRUE*/:
2520 case 16/*FALSE*/:
2521 case 17/*UNSPECIFIED*/:
2522 return token.val;
2523 default:
2524 throw "unexpected token " + token.type + " " + token.val;
2525 }
2526};
2527
2528/*** META ((export #t)) */
2529function sc_read(port) {
2530 if (port === undefined) // we assume the port hasn't been given.
2531 port = SC_DEFAULT_IN; // THREAD: shared var...
2532 var reader = new sc_Reader(new sc_Tokenizer(port));
2533 return reader.read();
2534}
2535/*** META ((export #t)) */
2536function sc_readChar(port) {
2537 if (port === undefined) // we assume the port hasn't been given.
2538 port = SC_DEFAULT_IN; // THREAD: shared var...
2539 var t = port.readChar();
2540 return t === SC_EOF_OBJECT? t: new sc_Char(t);
2541}
2542/*** META ((export #t)) */
2543function sc_peekChar(port) {
2544 if (port === undefined) // we assume the port hasn't been given.
2545 port = SC_DEFAULT_IN; // THREAD: shared var...
2546 var t = port.peekChar();
2547 return t === SC_EOF_OBJECT? t: new sc_Char(t);
2548}
2549/*** META ((export #t)
2550 (type bool))
2551*/
2552function sc_isCharReady(port) {
2553 if (port === undefined) // we assume the port hasn't been given.
2554 port = SC_DEFAULT_IN; // THREAD: shared var...
2555 return port.isCharReady();
2556}
2557/*** META ((export #t)
2558 (peephole (postfix ".close()")))
2559*/
2560function sc_closeInputPort(p) {
2561 return p.close();
2562}
2563
2564/*** META ((export #t)
2565 (type bool)
2566 (peephole (postfix " instanceof sc_InputPort")))
2567*/
2568function sc_isInputPort(o) {
2569 return (o instanceof sc_InputPort);
2570}
2571
2572/*** META ((export eof-object?)
2573 (type bool)
2574 (peephole (postfix " === SC_EOF_OBJECT")))
2575*/
2576function sc_isEOFObject(o) {
2577 return o === SC_EOF_OBJECT;
2578}
2579
2580/*** META ((export #t)
2581 (peephole (hole 0 "SC_DEFAULT_IN")))
2582*/
2583function sc_currentInputPort() {
2584 return SC_DEFAULT_IN;
2585}
2586
2587/* ------------ file operations are not supported -----------*/
2588/*** META ((export #t)) */
2589function sc_callWithInputFile(s, proc) {
2590 throw "can't open " + s;
2591}
2592
2593/*** META ((export #t)) */
2594function sc_callWithOutputFile(s, proc) {
2595 throw "can't open " + s;
2596}
2597
2598/*** META ((export #t)) */
2599function sc_withInputFromFile(s, thunk) {
2600 throw "can't open " + s;
2601}
2602
2603/*** META ((export #t)) */
2604function sc_withOutputToFile(s, thunk) {
2605 throw "can't open " + s;
2606}
2607
2608/*** META ((export #t)) */
2609function sc_openInputFile(s) {
2610 throw "can't open " + s;
2611}
2612
2613/*** META ((export #t)) */
2614function sc_openOutputFile(s) {
2615 throw "can't open " + s;
2616}
2617
2618/* ----------------------------------------------------------------------------*/
2619/*** META ((export #t)) */
2620function sc_basename(p) {
2621 var i = p.lastIndexOf('/');
2622
2623 if(i >= 0)
2624 return p.substring(i + 1, p.length);
2625 else
2626 return '';
2627}
2628
2629/*** META ((export #t)) */
2630function sc_dirname(p) {
2631 var i = p.lastIndexOf('/');
2632
2633 if(i >= 0)
2634 return p.substring(0, i);
2635 else
2636 return '';
2637}
2638
2639/* ----------------------------------------------------------------------------*/
2640
2641/*** META ((export #t)) */
2642function sc_withInputFromPort(p, thunk) {
2643 try {
2644 var tmp = SC_DEFAULT_IN; // THREAD: shared var.
2645 SC_DEFAULT_IN = p;
2646 return thunk();
2647 } finally {
2648 SC_DEFAULT_IN = tmp;
2649 }
2650}
2651
2652/*** META ((export #t)) */
2653function sc_withInputFromString(s, thunk) {
2654 return sc_withInputFromPort(new sc_StringInputPort(sc_string2jsstring(s)), thunk);
2655}
2656
2657/*** META ((export #t)) */
2658function sc_withOutputToPort(p, thunk) {
2659 try {
2660 var tmp = SC_DEFAULT_OUT; // THREAD: shared var.
2661 SC_DEFAULT_OUT = p;
2662 return thunk();
2663 } finally {
2664 SC_DEFAULT_OUT = tmp;
2665 }
2666}
2667
2668/*** META ((export #t)) */
2669function sc_withOutputToString(thunk) {
2670 var p = new sc_StringOutputPort();
2671 sc_withOutputToPort(p, thunk);
2672 return p.close();
2673}
2674
2675/*** META ((export #t)) */
2676function sc_withOutputToProcedure(proc, thunk) {
2677 var t = function(s) { proc(sc_jsstring2string(s)); };
2678 return sc_withOutputToPort(new sc_GenericOutputPort(t), thunk);
2679}
2680
2681/*** META ((export #t)
2682 (peephole (hole 0 "new sc_StringOutputPort()")))
2683*/
2684function sc_openOutputString() {
2685 return new sc_StringOutputPort();
2686}
2687
2688/*** META ((export #t)) */
2689function sc_openInputString(str) {
2690 return new sc_StringInputPort(sc_string2jsstring(str));
2691}
2692
2693/* ----------------------------------------------------------------------------*/
2694
2695function sc_OutputPort() {
2696}
2697sc_OutputPort.prototype = new sc_Port();
2698sc_OutputPort.prototype.appendJSString = function(obj) {
2699 /* do nothing */
2700}
2701sc_OutputPort.prototype.close = function() {
2702 /* do nothing */
2703}
2704
2705function sc_StringOutputPort() {
2706 this.res = "";
2707}
2708sc_StringOutputPort.prototype = new sc_OutputPort();
2709sc_StringOutputPort.prototype.appendJSString = function(s) {
2710 this.res += s;
2711}
2712sc_StringOutputPort.prototype.close = function() {
2713 return sc_jsstring2string(this.res);
2714}
2715
2716/*** META ((export #t)) */
2717function sc_getOutputString(sp) {
2718 return sc_jsstring2string(sp.res);
2719}
2720
2721
2722function sc_ErrorOutputPort() {
2723}
2724sc_ErrorOutputPort.prototype = new sc_OutputPort();
2725sc_ErrorOutputPort.prototype.appendJSString = function(s) {
2726 throw "don't write on ErrorPort!";
2727}
2728sc_ErrorOutputPort.prototype.close = function() {
2729 /* do nothing */
2730}
2731
2732function sc_GenericOutputPort(appendJSString, close) {
2733 this.appendJSString = appendJSString;
2734 if (close)
2735 this.close = close;
2736}
2737sc_GenericOutputPort.prototype = new sc_OutputPort();
2738
2739/*** META ((export #t)
2740 (type bool)
2741 (peephole (postfix " instanceof sc_OutputPort")))
2742*/
2743function sc_isOutputPort(o) {
2744 return (o instanceof sc_OutputPort);
2745}
2746
2747/*** META ((export #t)
2748 (peephole (postfix ".close()")))
2749*/
2750function sc_closeOutputPort(p) {
2751 return p.close();
2752}
2753
2754/* ------------------ write ---------------------------------------------------*/
2755
2756/*** META ((export #t)) */
2757function sc_write(o, p) {
2758 if (p === undefined) // we assume not given
2759 p = SC_DEFAULT_OUT;
2760 p.appendJSString(sc_toWriteString(o));
2761}
2762
2763function sc_toWriteString(o) {
2764 if (o === null)
2765 return "()";
2766 else if (o === true)
2767 return "#t";
2768 else if (o === false)
2769 return "#f";
2770 else if (o === undefined)
2771 return "#unspecified";
2772 else if (typeof o === 'function')
2773 return "#<procedure " + sc_hash(o) + ">";
2774 else if (o.sc_toWriteString)
2775 return o.sc_toWriteString();
2776 else
2777 return o.toString();
2778}
2779
2780function sc_escapeWriteString(s) {
2781 var res = "";
2782 var j = 0;
2783 for (i = 0; i < s.length; i++) {
2784 switch (s.charAt(i)) {
2785 case "\0": res += s.substring(j, i) + "\\0"; j = i + 1; break;
2786 case "\b": res += s.substring(j, i) + "\\b"; j = i + 1; break;
2787 case "\f": res += s.substring(j, i) + "\\f"; j = i + 1; break;
2788 case "\n": res += s.substring(j, i) + "\\n"; j = i + 1; break;
2789 case "\r": res += s.substring(j, i) + "\\r"; j = i + 1; break;
2790 case "\t": res += s.substring(j, i) + "\\t"; j = i + 1; break;
2791 case "\v": res += s.substring(j, i) + "\\v"; j = i + 1; break;
2792 case '"': res += s.substring(j, i) + '\\"'; j = i + 1; break;
2793 case "\\": res += s.substring(j, i) + "\\\\"; j = i + 1; break;
2794 default:
2795 var c = s.charAt(i);
2796 if ("\a" !== "a" && c == "\a") {
2797 res += s.substring(j, i) + "\\a"; j = i + 1; continue;
2798 }
2799 if ("\v" !== "v" && c == "\v") {
2800 res += s.substring(j, i) + "\\v"; j = i + 1; continue;
2801 }
2802 //if (s.charAt(i) < ' ' || s.charCodeAt(i) > 127) {
2803 // CARE: Manuel is this OK with HOP?
2804 if (s.charAt(i) < ' ') {
2805 /* non printable character and special chars */
2806 res += s.substring(j, i) + "\\x" + s.charCodeAt(i).toString(16);
2807 j = i + 1;
2808 }
2809 // else just let i increase...
2810 }
2811 }
2812 res += s.substring(j, i);
2813 return res;
2814}
2815
2816/* ------------------ display ---------------------------------------------------*/
2817
2818/*** META ((export #t)) */
2819function sc_display(o, p) {
2820 if (p === undefined) // we assume not given
2821 p = SC_DEFAULT_OUT;
2822 p.appendJSString(sc_toDisplayString(o));
2823}
2824
2825function sc_toDisplayString(o) {
2826 if (o === null)
2827 return "()";
2828 else if (o === true)
2829 return "#t";
2830 else if (o === false)
2831 return "#f";
2832 else if (o === undefined)
2833 return "#unspecified";
2834 else if (typeof o === 'function')
2835 return "#<procedure " + sc_hash(o) + ">";
2836 else if (o.sc_toDisplayString)
2837 return o.sc_toDisplayString();
2838 else
2839 return o.toString();
2840}
2841
2842/* ------------------ newline ---------------------------------------------------*/
2843
2844/*** META ((export #t)) */
2845function sc_newline(p) {
2846 if (p === undefined) // we assume not given
2847 p = SC_DEFAULT_OUT;
2848 p.appendJSString("\n");
2849}
2850
2851/* ------------------ write-char ---------------------------------------------------*/
2852
2853/*** META ((export #t)) */
2854function sc_writeChar(c, p) {
2855 if (p === undefined) // we assume not given
2856 p = SC_DEFAULT_OUT;
2857 p.appendJSString(c.val);
2858}
2859
2860/* ------------------ write-circle ---------------------------------------------------*/
2861
2862/*** META ((export #t)) */
2863function sc_writeCircle(o, p) {
2864 if (p === undefined) // we assume not given
2865 p = SC_DEFAULT_OUT;
2866 p.appendJSString(sc_toWriteCircleString(o));
2867}
2868
2869function sc_toWriteCircleString(o) {
2870 var symb = sc_gensym("writeCircle");
2871 var nbPointer = new Object();
2872 nbPointer.nb = 0;
2873 sc_prepWriteCircle(o, symb, nbPointer);
2874 return sc_genToWriteCircleString(o, symb);
2875}
2876
2877function sc_prepWriteCircle(o, symb, nbPointer) {
2878 // TODO sc_Struct
2879 if (o instanceof sc_Pair ||
2880 o instanceof sc_Vector) {
2881 if (o[symb] !== undefined) {
2882 // not the first visit.
2883 o[symb]++;
2884 // unless there is already a number, assign one.
2885 if (!o[symb + "nb"]) o[symb + "nb"] = nbPointer.nb++;
2886 return;
2887 }
2888 o[symb] = 0;
2889 if (o instanceof sc_Pair) {
2890 sc_prepWriteCircle(o.car, symb, nbPointer);
2891 sc_prepWriteCircle(o.cdr, symb, nbPointer);
2892 } else {
2893 for (var i = 0; i < o.length; i++)
2894 sc_prepWriteCircle(o[i], symb, nbPointer);
2895 }
2896 }
2897}
2898
2899function sc_genToWriteCircleString(o, symb) {
2900 if (!(o instanceof sc_Pair ||
2901 o instanceof sc_Vector))
2902 return sc_toWriteString(o);
2903 return o.sc_toWriteCircleString(symb);
2904}
2905sc_Pair.prototype.sc_toWriteCircleString = function(symb, inList) {
2906 if (this[symb + "use"]) { // use-flag is set. Just use it.
2907 var nb = this[symb + "nb"];
2908 if (this[symb]-- === 0) { // if we are the last use. remove all fields.
2909 delete this[symb];
2910 delete this[symb + "nb"];
2911 delete this[symb + "use"];
2912 }
2913 if (inList)
2914 return '. #' + nb + '#';
2915 else
2916 return '#' + nb + '#';
2917 }
2918 if (this[symb]-- === 0) { // if we are the last use. remove all fields.
2919 delete this[symb];
2920 delete this[symb + "nb"];
2921 delete this[symb + "use"];
2922 }
2923
2924 var res = "";
2925
2926 if (this[symb] !== undefined) { // implies > 0
2927 this[symb + "use"] = true;
2928 if (inList)
2929 res += '. #' + this[symb + "nb"] + '=';
2930 else
2931 res += '#' + this[symb + "nb"] + '=';
2932 inList = false;
2933 }
2934
2935 if (!inList)
2936 res += "(";
2937
2938 // print car
2939 res += sc_genToWriteCircleString(this.car, symb);
2940
2941 if (sc_isPair(this.cdr)) {
2942 res += " " + this.cdr.sc_toWriteCircleString(symb, true);
2943 } else if (this.cdr !== null) {
2944 res += " . " + sc_genToWriteCircleString(this.cdr, symb);
2945 }
2946 if (!inList)
2947 res += ")";
2948 return res;
2949};
2950sc_Vector.prototype.sc_toWriteCircleString = function(symb) {
2951 if (this[symb + "use"]) { // use-flag is set. Just use it.
2952 var nb = this[symb + "nb"];
2953 if (this[symb]-- === 0) { // if we are the last use. remove all fields.
2954 delete this[symb];
2955 delete this[symb + "nb"];
2956 delete this[symb + "use"];
2957 }
2958 return '#' + nb + '#';
2959 }
2960 if (this[symb]-- === 0) { // if we are the last use. remove all fields.
2961 delete this[symb];
2962 delete this[symb + "nb"];
2963 delete this[symb + "use"];
2964 }
2965
2966 var res = "";
2967 if (this[symb] !== undefined) { // implies > 0
2968 this[symb + "use"] = true;
2969 res += '#' + this[symb + "nb"] + '=';
2970 }
2971 res += "#(";
2972 for (var i = 0; i < this.length; i++) {
2973 res += sc_genToWriteCircleString(this[i], symb);
2974 if (i < this.length - 1) res += " ";
2975 }
2976 res += ")";
2977 return res;
2978};
2979
2980
2981/* ------------------ print ---------------------------------------------------*/
2982
2983/*** META ((export #t)) */
2984function sc_print(s) {
2985 if (arguments.length === 1) {
2986 sc_display(s);
2987 sc_newline();
2988 }
2989 else {
2990 for (var i = 0; i < arguments.length; i++)
2991 sc_display(arguments[i]);
2992 sc_newline();
2993 }
2994}
2995
2996/* ------------------ format ---------------------------------------------------*/
2997/*** META ((export #t)) */
2998function sc_format(s, args) {
2999 var len = s.length;
3000 var p = new sc_StringOutputPort();
3001 var i = 0, j = 1;
3002
3003 while( i < len ) {
3004 var i2 = s.indexOf("~", i);
3005
3006 if (i2 == -1) {
3007 p.appendJSString( s.substring( i, len ) );
3008 return p.close();
3009 } else {
3010 if (i2 > i) {
3011 if (i2 == (len - 1)) {
3012 p.appendJSString(s.substring(i, len));
3013 return p.close();
3014 } else {
3015 p.appendJSString(s.substring(i, i2));
3016 i = i2;
3017 }
3018 }
3019
3020 switch(s.charCodeAt(i2 + 1)) {
3021 case 65:
3022 case 97:
3023 // a
3024 sc_display(arguments[j], p);
3025 i += 2; j++;
3026 break;
3027
3028 case 83:
3029 case 115:
3030 // s
3031 sc_write(arguments[j], p);
3032 i += 2; j++;
3033 break;
3034
3035 case 86:
3036 case 118:
3037 // v
3038 sc_display(arguments[j], p);
3039 p.appendJSString("\n");
3040 i += 2; j++;
3041 break;
3042
3043 case 67:
3044 case 99:
3045 // c
3046 p.appendJSString(String.fromCharCode(arguments[j]));
3047 i += 2; j++;
3048 break;
3049
3050 case 88:
3051 case 120:
3052 // x
3053 p.appendJSString(arguments[j].toString(6));
3054 i += 2; j++;
3055 break;
3056
3057 case 79:
3058 case 111:
3059 // o
3060 p.appendJSString(arguments[j].toString(8));
3061 i += 2; j++;
3062 break;
3063
3064 case 66:
3065 case 98:
3066 // b
3067 p.appendJSString(arguments[j].toString(2));
3068 i += 2; j++;
3069 break;
3070
3071 case 37:
3072 case 110:
3073 // %, n
3074 p.appendJSString("\n");
3075 i += 2; break;
3076
3077 case 114:
3078 // r
3079 p.appendJSString("\r");
3080 i += 2; break;
3081
3082 case 126:
3083 // ~
3084 p.appendJSString("~");
3085 i += 2; break;
3086
3087 default:
3088 sc_error( "format: illegal ~"
3089 + String.fromCharCode(s.charCodeAt(i2 + 1))
3090 + " sequence" );
3091 return "";
3092 }
3093 }
3094 }
3095
3096 return p.close();
3097}
3098
3099/* ------------------ global ports ---------------------------------------------------*/
3100
3101var SC_DEFAULT_IN = new sc_ErrorInputPort();
3102var SC_DEFAULT_OUT = new sc_ErrorOutputPort();
3103var SC_ERROR_OUT = new sc_ErrorOutputPort();
3104
3105var sc_SYMBOL_PREFIX = "\u1E9C";
3106var sc_KEYWORD_PREFIX = "\u1E9D";
3107
3108/*** META ((export #t)
3109 (peephole (id))) */
3110function sc_jsstring2string(s) {
3111 return s;
3112}
3113
3114/*** META ((export #t)
3115 (peephole (prefix "'\\u1E9C' +")))
3116*/
3117function sc_jsstring2symbol(s) {
3118 return sc_SYMBOL_PREFIX + s;
3119}
3120
3121/*** META ((export #t)
3122 (peephole (id)))
3123*/
3124function sc_string2jsstring(s) {
3125 return s;
3126}
3127
3128/*** META ((export #t)
3129 (peephole (symbol2jsstring_immutable)))
3130*/
3131function sc_symbol2jsstring(s) {
3132 return s.slice(1);
3133}
3134
3135/*** META ((export #t)
3136 (peephole (postfix ".slice(1)")))
3137*/
3138function sc_keyword2jsstring(k) {
3139 return k.slice(1);
3140}
3141
3142/*** META ((export #t)
3143 (peephole (prefix "'\\u1E9D' +")))
3144*/
3145function sc_jsstring2keyword(s) {
3146 return sc_KEYWORD_PREFIX + s;
3147}
3148
3149/*** META ((export #t)
3150 (type bool))
3151*/
3152function sc_isKeyword(s) {
3153 return (typeof s === "string") &&
3154 (s.charAt(0) === sc_KEYWORD_PREFIX);
3155}
3156
3157
3158/*** META ((export #t)) */
3159var sc_gensym = function() {
3160 var counter = 1000;
3161 return function(sym) {
3162 counter++;
3163 if (!sym) sym = sc_SYMBOL_PREFIX;
3164 return sym + "s" + counter + "~" + "^sC-GeNsYm ";
3165 };
3166}();
3167
3168
3169/*** META ((export #t)
3170 (type bool))
3171*/
3172function sc_isEqual(o1, o2) {
3173 return ((o1 === o2) ||
3174 (sc_isPair(o1) && sc_isPair(o2)
3175 && sc_isPairEqual(o1, o2, sc_isEqual)) ||
3176 (sc_isVector(o1) && sc_isVector(o2)
3177 && sc_isVectorEqual(o1, o2, sc_isEqual)));
3178}
3179
3180/*** META ((export number->symbol integer->symbol)) */
3181function sc_number2symbol(x, radix) {
3182 return sc_SYMBOL_PREFIX + sc_number2jsstring(x, radix);
3183}
3184
3185/*** META ((export number->string integer->string)) */
3186var sc_number2string = sc_number2jsstring;
3187
3188/*** META ((export #t)) */
3189function sc_symbol2number(s, radix) {
3190 return sc_jsstring2number(s.slice(1), radix);
3191}
3192
3193/*** META ((export #t)) */
3194var sc_string2number = sc_jsstring2number;
3195
3196/*** META ((export #t)
3197 (peephole (prefix "+" s)))
3198 ;; peephole will only apply if no radix is given.
3199*/
3200function sc_string2integer(s, radix) {
3201 if (!radix) return +s;
3202 return parseInt(s, radix);
3203}
3204
3205/*** META ((export #t)
3206 (peephole (prefix "+")))
3207*/
3208function sc_string2real(s) {
3209 return +s;
3210}
3211
3212
3213/*** META ((export #t)
3214 (type bool))
3215*/
3216function sc_isSymbol(s) {
3217 return (typeof s === "string") &&
3218 (s.charAt(0) === sc_SYMBOL_PREFIX);
3219}
3220
3221/*** META ((export #t)
3222 (peephole (symbol2string_immutable)))
3223*/
3224function sc_symbol2string(s) {
3225 return s.slice(1);
3226}
3227
3228/*** META ((export #t)
3229 (peephole (prefix "'\\u1E9C' +")))
3230*/
3231function sc_string2symbol(s) {
3232 return sc_SYMBOL_PREFIX + s;
3233}
3234
3235/*** META ((export symbol-append)
3236 (peephole (symbolAppend_immutable)))
3237*/
3238function sc_symbolAppend() {
3239 var res = sc_SYMBOL_PREFIX;
3240 for (var i = 0; i < arguments.length; i++)
3241 res += arguments[i].slice(1);
3242 return res;
3243}
3244
3245/*** META ((export #t)
3246 (peephole (postfix ".val")))
3247*/
3248function sc_char2string(c) { return c.val; }
3249
3250/*** META ((export #t)
3251 (peephole (hole 1 "'\\u1E9C' + " c ".val")))
3252*/
3253function sc_char2symbol(c) { return sc_SYMBOL_PREFIX + c.val; }
3254
3255/*** META ((export #t)
3256 (type bool))
3257*/
3258function sc_isString(s) {
3259 return (typeof s === "string") &&
3260 (s.charAt(0) !== sc_SYMBOL_PREFIX);
3261}
3262
3263/*** META ((export #t)) */
3264var sc_makeString = sc_makejsString;
3265
3266
3267/*** META ((export #t)) */
3268function sc_string() {
3269 for (var i = 0; i < arguments.length; i++)
3270 arguments[i] = arguments[i].val;
3271 return "".concat.apply("", arguments);
3272}
3273
3274/*** META ((export #t)
3275 (peephole (postfix ".length")))
3276*/
3277function sc_stringLength(s) { return s.length; }
3278
3279/*** META ((export #t)) */
3280function sc_stringRef(s, k) {
3281 return new sc_Char(s.charAt(k));
3282}
3283
3284/* there's no stringSet in the immutable version
3285function sc_stringSet(s, k, c)
3286*/
3287
3288
3289/*** META ((export string=?)
3290 (type bool)
3291 (peephole (hole 2 str1 " === " str2)))
3292*/
3293function sc_isStringEqual(s1, s2) {
3294 return s1 === s2;
3295}
3296/*** META ((export string<?)
3297 (type bool)
3298 (peephole (hole 2 str1 " < " str2)))
3299*/
3300function sc_isStringLess(s1, s2) {
3301 return s1 < s2;
3302}
3303/*** META ((export string>?)
3304 (type bool)
3305 (peephole (hole 2 str1 " > " str2)))
3306*/
3307function sc_isStringGreater(s1, s2) {
3308 return s1 > s2;
3309}
3310/*** META ((export string<=?)
3311 (type bool)
3312 (peephole (hole 2 str1 " <= " str2)))
3313*/
3314function sc_isStringLessEqual(s1, s2) {
3315 return s1 <= s2;
3316}
3317/*** META ((export string>=?)
3318 (type bool)
3319 (peephole (hole 2 str1 " >= " str2)))
3320*/
3321function sc_isStringGreaterEqual(s1, s2) {
3322 return s1 >= s2;
3323}
3324/*** META ((export string-ci=?)
3325 (type bool)
3326 (peephole (hole 2 str1 ".toLowerCase() === " str2 ".toLowerCase()")))
3327*/
3328function sc_isStringCIEqual(s1, s2) {
3329 return s1.toLowerCase() === s2.toLowerCase();
3330}
3331/*** META ((export string-ci<?)
3332 (type bool)
3333 (peephole (hole 2 str1 ".toLowerCase() < " str2 ".toLowerCase()")))
3334*/
3335function sc_isStringCILess(s1, s2) {
3336 return s1.toLowerCase() < s2.toLowerCase();
3337}
3338/*** META ((export string-ci>?)
3339 (type bool)
3340 (peephole (hole 2 str1 ".toLowerCase() > " str2 ".toLowerCase()")))
3341*/
3342function sc_isStringCIGreater(s1, s2) {
3343 return s1.toLowerCase() > s2.toLowerCase();
3344}
3345/*** META ((export string-ci<=?)
3346 (type bool)
3347 (peephole (hole 2 str1 ".toLowerCase() <= " str2 ".toLowerCase()")))
3348*/
3349function sc_isStringCILessEqual(s1, s2) {
3350 return s1.toLowerCase() <= s2.toLowerCase();
3351}
3352/*** META ((export string-ci>=?)
3353 (type bool)
3354 (peephole (hole 2 str1 ".toLowerCase() >= " str2 ".toLowerCase()")))
3355*/
3356function sc_isStringCIGreaterEqual(s1, s2) {
3357 return s1.toLowerCase() >= s2.toLowerCase();
3358}
3359
3360/*** META ((export #t)
3361 (peephole (hole 3 s ".substring(" start ", " end ")")))
3362*/
3363function sc_substring(s, start, end) {
3364 return s.substring(start, end);
3365}
3366
3367/*** META ((export #t))
3368*/
3369function sc_isSubstring_at(s1, s2, i) {
3370 return s2 == s1.substring(i, i+ s2.length);
3371}
3372
3373/*** META ((export #t)
3374 (peephole (infix 0 #f "+" "''")))
3375*/
3376function sc_stringAppend() {
3377 return "".concat.apply("", arguments);
3378}
3379
3380/*** META ((export #t)) */
3381var sc_string2list = sc_jsstring2list;
3382
3383/*** META ((export #t)) */
3384var sc_list2string = sc_list2jsstring;
3385
3386/*** META ((export #t)
3387 (peephole (id)))
3388*/
3389function sc_stringCopy(s) {
3390 return s;
3391}
3392
3393/* there's no string-fill in the immutable version
3394function sc_stringFill(s, c)
3395*/
3396
3397/*** META ((export #t)
3398 (peephole (postfix ".slice(1)")))
3399*/
3400function sc_keyword2string(o) {
3401 return o.slice(1);
3402}
3403
3404/*** META ((export #t)
3405 (peephole (prefix "'\\u1E9D' +")))
3406*/
3407function sc_string2keyword(o) {
3408 return sc_KEYWORD_PREFIX + o;
3409}
3410
3411String.prototype.sc_toDisplayString = function() {
3412 if (this.charAt(0) === sc_SYMBOL_PREFIX)
3413 // TODO: care for symbols with spaces (escape-chars symbols).
3414 return this.slice(1);
3415 else if (this.charAt(0) === sc_KEYWORD_PREFIX)
3416 return ":" + this.slice(1);
3417 else
3418 return this.toString();
3419};
3420
3421String.prototype.sc_toWriteString = function() {
3422 if (this.charAt(0) === sc_SYMBOL_PREFIX)
3423 // TODO: care for symbols with spaces (escape-chars symbols).
3424 return this.slice(1);
3425 else if (this.charAt(0) === sc_KEYWORD_PREFIX)
3426 return ":" + this.slice(1);
3427 else
3428 return '"' + sc_escapeWriteString(this) + '"';
3429};
3430/* Exported Variables */
3431var BgL_testzd2boyerzd2;
3432var BgL_nboyerzd2benchmarkzd2;
3433var BgL_setupzd2boyerzd2;
3434/* End Exports */
3435
3436var translate_term_nboyer;
3437var translate_args_nboyer;
3438var untranslate_term_nboyer;
3439var BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer;
3440var BgL_sc_za2symbolzd2recordszd2alistza2_2z00_nboyer;
3441var translate_alist_nboyer;
3442var apply_subst_nboyer;
3443var apply_subst_lst_nboyer;
3444var tautologyp_nboyer;
3445var if_constructor_nboyer;
3446var rewrite_count_nboyer;
3447var rewrite_nboyer;
3448var rewrite_args_nboyer;
3449var unify_subst_nboyer;
3450var one_way_unify1_nboyer;
3451var false_term_nboyer;
3452var true_term_nboyer;
3453var trans_of_implies1_nboyer;
3454var is_term_equal_nboyer;
3455var is_term_member_nboyer;
3456var const_nboyer;
3457var sc_const_3_nboyer;
3458var sc_const_4_nboyer;
3459{
3460 (sc_const_4_nboyer = (new sc_Pair("\u1E9Cimplies",(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cz",(new sc_Pair("\u1E9Cu",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cu",(new sc_Pair("\u1E9Cw",null)))))),null)))))),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cw",null)))))),null)))))));
3461 (sc_const_3_nboyer = sc_list((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ccompile",(new sc_Pair("\u1E9Cform",null)))),(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair((new sc_Pair("\u1E9Ccodegen",(new sc_Pair((new sc_Pair("\u1E9Coptimize",(new sc_Pair("\u1E9Cform",null)))),(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ceqp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cy",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgreaterp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clesseqp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgreatereqp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cboolean",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cf",null)),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ciff",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ceven1",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Ct",null)),(new sc_Pair((new sc_Pair("\u1E9Codd",(new sc_Pair((new sc_Pair("\u1E9Csub1",(new sc_Pair("\u1E9Cx",null)))),null)))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ccountps-",(new sc_Pair("\u1E9Cl",(new sc_Pair("\u1E9Cpred",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ccountps-loop",(new sc_Pair("\u1E9Cl",(new sc_Pair("\u1E9Cpred",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cfact-",(new sc_Pair("\u1E9Ci",null)))),(new sc_Pair((new sc_Pair("\u1E9Cfact-loop",(new sc_Pair("\u1E9Ci",(new sc_Pair((1),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Creverse-",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Creverse-loop",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdivides",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cassume-true",(new sc_Pair("\u1E9Cvar",(new sc_Pair("\u1E9Calist",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cvar",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),null)))))),(new sc_Pair("\u1E9Calist",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cassume-false",(new sc_Pair("\u1E9Cvar",(new sc_Pair("\u1E9Calist",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cvar",(new sc_Pair((new sc_Pair("\u1E9Cf",null)),null)))))),(new sc_Pair("\u1E9Calist",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctautology-checker",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Ctautologyp",(new sc_Pair((new sc_Pair("\u1E9Cnormalize",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cfalsify",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cfalsify1",(new sc_Pair((new sc_Pair("\u1E9Cnormalize",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cprime",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))),null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cprime1",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Csub1",(new sc_Pair("\u1E9Cx",null)))),null)))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair("\u1E9Cp",(new sc_Pair("\u1E9Cq",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cp",(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cq",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),(new sc_Pair((new sc_Pair("\u1E9Cf",null)),null)))))))),(new sc_Pair((new sc_Pair("\u1E9Cf",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair("\u1E9Cp",(new sc_Pair("\u1E9Cq",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cp",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cq",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),(new sc_Pair((new sc_Pair("\u1E9Cf",null)),null)))))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair("\u1E9Cp",null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cp",(new sc_Pair((new sc_Pair("\u1E9Cf",null)),(new sc_Pair((new sc_Pair("\u1E9Ct",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cp",(new sc_Pair("\u1E9Cq",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cp",(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cq",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),(new sc_Pair((new sc_Pair("\u1E9Cf",null)),null)))))))),(new sc_Pair((new sc_Pair("\u1E9Ct",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",(new sc_Pair("\u1E9Cc",null)))))))),(new sc_Pair("\u1E9Cd",(new sc_Pair("\u1E9Ce",null)))))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Ca",(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cb",(new sc_Pair("\u1E9Cd",(new sc_Pair("\u1E9Ce",null)))))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cc",(new sc_Pair("\u1E9Cd",(new sc_Pair("\u1E9Ce",null)))))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cx",null)))),null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Ca",null)))),(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cb",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cc",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cb",null)))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cc",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair("\u1E9Ca",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair((new sc_Pair("\u1E9Cplus-fringe",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Ca",null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair("\u1E9Cb",null)))),(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair("\u1E9Ca",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cz",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cexec",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cpds",(new sc_Pair("\u1E9Cenvrn",null)))))))),(new sc_Pair((new sc_Pair("\u1E9Cexec",(new sc_Pair("\u1E9Cy",(new sc_Pair((new sc_Pair("\u1E9Cexec",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cpds",(new sc_Pair("\u1E9Cenvrn",null)))))))),(new sc_Pair("\u1E9Cenvrn",null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmc-flatten",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair("\u1E9Cy",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cb",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair("\u1E9Cy",null)))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair("\u1E9Cx",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Ca",(new sc_Pair((new sc_Pair("\u1E9Cintersect",(new sc_Pair("\u1E9Cb",(new sc_Pair("\u1E9Cc",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cc",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cnth",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cexp",(new sc_Pair("\u1E9Ci",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cj",(new sc_Pair("\u1E9Ck",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair((new sc_Pair("\u1E9Cexp",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cj",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cexp",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Ck",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cexp",(new sc_Pair("\u1E9Ci",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cj",(new sc_Pair("\u1E9Ck",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cexp",(new sc_Pair((new sc_Pair("\u1E9Cexp",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cj",null)))))),(new sc_Pair("\u1E9Ck",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Creverse-loop",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair("\u1E9Cy",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Creverse-loop",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair("\u1E9Cx",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ccount-list",(new sc_Pair("\u1E9Cz",(new sc_Pair((new sc_Pair("\u1E9Csort-lp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Ccount-list",(new sc_Pair("\u1E9Cz",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ccount-list",(new sc_Pair("\u1E9Cz",(new sc_Pair("\u1E9Cy",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cc",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cb",(new sc_Pair("\u1E9Cc",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cy",(new sc_Pair((new sc_Pair("\u1E9Cquotient",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair((new sc_Pair("\u1E9Cbig-plus1",(new sc_Pair("\u1E9Cl",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cbase",null)))))))),(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair("\u1E9Cl",(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair("\u1E9Ci",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair((new sc_Pair("\u1E9Cbig-plus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cbase",null)))))))))),(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ci",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cbase",null)))))),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Cy",(new sc_Pair((1),null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Cquotient",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cj",null)))))),(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Ci",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cj",null)))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cj",(new sc_Pair((1),null)))))),null)))),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair((new sc_Pair("\u1E9Cpower-rep",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Ci",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair((new sc_Pair("\u1E9Cbig-plus",(new sc_Pair((new sc_Pair("\u1E9Cpower-rep",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cpower-rep",(new sc_Pair("\u1E9Cj",(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),(new sc_Pair("\u1E9Cbase",null)))))))))),(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cj",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgcd",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cgcd",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cnth",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair((new sc_Pair("\u1E9Cnth",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnth",(new sc_Pair("\u1E9Cb",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Ci",(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair("\u1E9Ca",null)))),null)))))),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cy",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cy",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cz",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cc",(new sc_Pair("\u1E9Cw",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cc",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cw",(new sc_Pair("\u1E9Cx",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cb",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cc",null)))))),null)))))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cb",(new sc_Pair("\u1E9Cc",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair("\u1E9Cy",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cz",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cz",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cx",null)))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgcd",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cz",(new sc_Pair((new sc_Pair("\u1E9Cgcd",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cvalue",(new sc_Pair((new sc_Pair("\u1E9Cnormalize",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cvalue",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Ca",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cy",(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnlistp",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clistp",(new sc_Pair((new sc_Pair("\u1E9Cgopher",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Clistp",(new sc_Pair("\u1E9Cx",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Csamefringe",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair("\u1E9Cy",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgreatest-factor",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cy",(new sc_Pair((1),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgreatest-factor",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((1),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((1),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair((new sc_Pair("\u1E9Cgreatest-factor",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cy",(new sc_Pair((1),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cx",null)))),null)))),null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes-list",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair((new sc_Pair("\u1E9Ctimes-list",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Ctimes-list",(new sc_Pair("\u1E9Cy",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cprime-list",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cprime-list",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cprime-list",(new sc_Pair("\u1E9Cy",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cz",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cw",(new sc_Pair("\u1E9Cz",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cz",null)))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cz",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cw",(new sc_Pair((1),null)))))),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgreatereqp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cy",(new sc_Pair((1),null)))))),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((1),null)))))),(new sc_Pair(sc_list("\u1E9Cand", (new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Ca",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),null)))), (new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cb",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),null)))), (new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Ca",null)))), (new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cb",null)))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Csub1",(new sc_Pair("\u1E9Ca",null)))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Csub1",(new sc_Pair("\u1E9Cb",null)))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair((new sc_Pair("\u1E9Cdelete",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cl",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair("\u1E9Cl",null)))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cl",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Csort2",(new sc_Pair((new sc_Pair("\u1E9Cdelete",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cl",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cdelete",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Csort2",(new sc_Pair("\u1E9Cl",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdsort",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Csort2",(new sc_Pair("\u1E9Cx",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cx1",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cx2",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cx3",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cx4",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cx5",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cx6",(new sc_Pair("\u1E9Cx7",null)))))),null)))))),null)))))),null)))))),null)))))),null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((6),(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair("\u1E9Cx7",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((2),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cquotient",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((2),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cquotient",(new sc_Pair("\u1E9Cy",(new sc_Pair((2),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Csigma",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cquotient",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Ci",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair("\u1E9Ci",null)))),null)))))),(new sc_Pair((2),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair("\u1E9Cy",null)))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair("\u1E9Cx",null)))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cz",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cz",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cz",null)))),null)))))),null)))))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair((new sc_Pair("\u1E9Cdelete",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Ca",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair("\u1E9Ca",null)))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair("\u1E9Cy",null)))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cnth",(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Ci",null)))),(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clast",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clistp",(new sc_Pair("\u1E9Cb",null)))),(new sc_Pair((new sc_Pair("\u1E9Clast",(new sc_Pair("\u1E9Cb",null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clistp",(new sc_Pair("\u1E9Ca",null)))),(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair((new sc_Pair("\u1E9Ccar",(new sc_Pair((new sc_Pair("\u1E9Clast",(new sc_Pair("\u1E9Ca",null)))),null)))),(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair("\u1E9Cb",null)))))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cf",null)),(new sc_Pair("\u1E9Cz",null)))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cassignment",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Cassignedp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cassignment",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cassignment",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cb",null)))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ccar",(new sc_Pair((new sc_Pair("\u1E9Cgopher",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clistp",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Ccar",(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair((new sc_Pair("\u1E9Ccdr",(new sc_Pair((new sc_Pair("\u1E9Cgopher",(new sc_Pair("\u1E9Cx",null)))),null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clistp",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Ccdr",(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cquotient",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cget",(new sc_Pair("\u1E9Cj",(new sc_Pair((new sc_Pair("\u1E9Cset",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cval",(new sc_Pair("\u1E9Cmem",null)))))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Ceqp",(new sc_Pair("\u1E9Cj",(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair("\u1E9Cval",(new sc_Pair((new sc_Pair("\u1E9Cget",(new sc_Pair("\u1E9Cj",(new sc_Pair("\u1E9Cmem",null)))))),null)))))))),null))))))));
3462 (const_nboyer = (new sc_Pair((new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cf",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cc",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cf",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cc",(new sc_Pair("\u1E9Cd",null)))))),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cz",(new sc_Pair("\u1E9Cf",(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cu",(new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))))),(new sc_Pair((new sc_Pair("\u1E9Cw",(new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Ca",(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair("\u1E9Cb",null)))),null)))))),null)))))))),null)))))))))));
3463 BgL_nboyerzd2benchmarkzd2 = function() {
3464 var args = null;
3465 for (var sc_tmp = arguments.length - 1; sc_tmp >= 0; sc_tmp--) {
3466 args = sc_cons(arguments[sc_tmp], args);
3467 }
3468 var n;
3469 return ((n = ((args === null)?(0):(args.car))), (BgL_setupzd2boyerzd2()), (BgL_runzd2benchmarkzd2(("nboyer"+(sc_number2string(n))), (1), function() {
3470 return (BgL_testzd2boyerzd2(n));
3471 }, function(rewrites) {
3472 if ((sc_isNumber(rewrites)))
3473 switch (n) {
3474 case (0):
3475 return (rewrites===(95024));
3476 break;
3477 case (1):
3478 return (rewrites===(591777));
3479 break;
3480 case (2):
3481 return (rewrites===(1813975));
3482 break;
3483 case (3):
3484 return (rewrites===(5375678));
3485 break;
3486 case (4):
3487 return (rewrites===(16445406));
3488 break;
3489 case (5):
3490 return (rewrites===(51507739));
3491 break;
3492 default:
3493 return true;
3494 break;
3495 }
3496 else
3497 return false;
3498 })));
3499 };
3500 BgL_setupzd2boyerzd2 = function() {
3501 return true;
3502 };
3503 BgL_testzd2boyerzd2 = function() {
3504 return true;
3505 };
3506 translate_term_nboyer = function(term) {
3507 var lst;
3508 return (!(term instanceof sc_Pair)?term:(new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((term.car))), ((lst = (term.cdr)), ((lst === null)?null:(new sc_Pair((translate_term_nboyer((lst.car))), (translate_args_nboyer((lst.cdr))))))))));
3509 };
3510 translate_args_nboyer = function(lst) {
3511 var sc_lst_5;
3512 var term;
3513 return ((lst === null)?null:(new sc_Pair(((term = (lst.car)), (!(term instanceof sc_Pair)?term:(new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((term.car))), (translate_args_nboyer((term.cdr))))))), ((sc_lst_5 = (lst.cdr)), ((sc_lst_5 === null)?null:(new sc_Pair((translate_term_nboyer((sc_lst_5.car))), (translate_args_nboyer((sc_lst_5.cdr))))))))));
3514 };
3515 untranslate_term_nboyer = function(term) {
3516 var optrOpnd;
3517 var tail1131;
3518 var L1127;
3519 var falseHead1130;
3520 var symbol_record;
3521 if (!(term instanceof sc_Pair))
3522 return term;
3523 else
3524 {
3525 (falseHead1130 = (new sc_Pair(null, null)));
3526 (L1127 = (term.cdr));
3527 (tail1131 = falseHead1130);
3528 while (!(L1127 === null)) {
3529 {
3530 (tail1131.cdr = (new sc_Pair((untranslate_term_nboyer((L1127.car))), null)));
3531 (tail1131 = (tail1131.cdr));
3532 (L1127 = (L1127.cdr));
3533 }
3534 }
3535 (optrOpnd = (falseHead1130.cdr));
3536 return (new sc_Pair(((symbol_record = (term.car)), (symbol_record[(0)])), optrOpnd));
3537 }
3538 };
3539 BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer = function(sym) {
3540 var r;
3541 var x;
3542 return ((x = (sc_assq(sym, BgL_sc_za2symbolzd2recordszd2alistza2_2z00_nboyer))), ((x!== false)?(x.cdr):((r = [sym, null]), (BgL_sc_za2symbolzd2recordszd2alistza2_2z00_nboyer = (new sc_Pair((new sc_Pair(sym, r)), BgL_sc_za2symbolzd2recordszd2alistza2_2z00_nboyer))), r)));
3543 };
3544 (BgL_sc_za2symbolzd2recordszd2alistza2_2z00_nboyer = null);
3545 translate_alist_nboyer = function(alist) {
3546 var sc_alist_6;
3547 var term;
3548 return ((alist === null)?null:(new sc_Pair((new sc_Pair((alist.car.car), ((term = (alist.car.cdr)), (!(term instanceof sc_Pair)?term:(new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((term.car))), (translate_args_nboyer((term.cdr))))))))), ((sc_alist_6 = (alist.cdr)), ((sc_alist_6 === null)?null:(new sc_Pair((new sc_Pair((sc_alist_6.car.car), (translate_term_nboyer((sc_alist_6.car.cdr))))), (translate_alist_nboyer((sc_alist_6.cdr))))))))));
3549 };
3550 apply_subst_nboyer = function(alist, term) {
3551 var lst;
3552 var temp_temp;
3553 return (!(term instanceof sc_Pair)?((temp_temp = (sc_assq(term, alist))), ((temp_temp!== false)?(temp_temp.cdr):term)):(new sc_Pair((term.car), ((lst = (term.cdr)), ((lst === null)?null:(new sc_Pair((apply_subst_nboyer(alist, (lst.car))), (apply_subst_lst_nboyer(alist, (lst.cdr))))))))));
3554 };
3555 apply_subst_lst_nboyer = function(alist, lst) {
3556 var sc_lst_7;
3557 return ((lst === null)?null:(new sc_Pair((apply_subst_nboyer(alist, (lst.car))), ((sc_lst_7 = (lst.cdr)), ((sc_lst_7 === null)?null:(new sc_Pair((apply_subst_nboyer(alist, (sc_lst_7.car))), (apply_subst_lst_nboyer(alist, (sc_lst_7.cdr))))))))));
3558 };
3559 tautologyp_nboyer = function(sc_x_11, true_lst, false_lst) {
3560 var tmp1125;
3561 var x;
3562 var tmp1126;
3563 var sc_x_8;
3564 var sc_tmp1125_9;
3565 var sc_tmp1126_10;
3566 var sc_x_11;
3567 var true_lst;
3568 var false_lst;
3569 while (true) {
3570 if ((((sc_tmp1126_10 = (is_term_equal_nboyer(sc_x_11, true_term_nboyer))), ((sc_tmp1126_10!== false)?sc_tmp1126_10:(is_term_member_nboyer(sc_x_11, true_lst))))!== false))
3571 return true;
3572 else
3573 if ((((sc_tmp1125_9 = (is_term_equal_nboyer(sc_x_11, false_term_nboyer))), ((sc_tmp1125_9!== false)?sc_tmp1125_9:(is_term_member_nboyer(sc_x_11, false_lst))))!== false))
3574 return false;
3575 else
3576 if (!(sc_x_11 instanceof sc_Pair))
3577 return false;
3578 else
3579 if (((sc_x_11.car)===if_constructor_nboyer))
3580 if ((((sc_x_8 = (sc_x_11.cdr.car)), (tmp1126 = (is_term_equal_nboyer(sc_x_8, true_term_nboyer))), ((tmp1126!== false)?tmp1126:(is_term_member_nboyer(sc_x_8, true_lst))))!== false))
3581 (sc_x_11 = (sc_x_11.cdr.cdr.car));
3582 else
3583 if ((((x = (sc_x_11.cdr.car)), (tmp1125 = (is_term_equal_nboyer(x, false_term_nboyer))), ((tmp1125!== false)?tmp1125:(is_term_member_nboyer(x, false_lst))))!== false))
3584 (sc_x_11 = (sc_x_11.cdr.cdr.cdr.car));
3585 else
3586 if (((tautologyp_nboyer((sc_x_11.cdr.cdr.car), (new sc_Pair((sc_x_11.cdr.car), true_lst)), false_lst))!== false))
3587 {
3588 (false_lst = (new sc_Pair((sc_x_11.cdr.car), false_lst)));
3589 (sc_x_11 = (sc_x_11.cdr.cdr.cdr.car));
3590 }
3591 else
3592 return false;
3593 else
3594 return false;
3595 }
3596 };
3597 (if_constructor_nboyer = "\u1E9C*");
3598 (rewrite_count_nboyer = (0));
3599 rewrite_nboyer = function(term) {
3600 var term2;
3601 var sc_term_12;
3602 var lst;
3603 var symbol_record;
3604 var sc_lst_13;
3605 {
3606 (++rewrite_count_nboyer);
3607 if (!(term instanceof sc_Pair))
3608 return term;
3609 else
3610 {
3611 (sc_term_12 = (new sc_Pair((term.car), ((sc_lst_13 = (term.cdr)), ((sc_lst_13 === null)?null:(new sc_Pair((rewrite_nboyer((sc_lst_13.car))), (rewrite_args_nboyer((sc_lst_13.cdr))))))))));
3612 (lst = ((symbol_record = (term.car)), (symbol_record[(1)])));
3613 while (true) {
3614 if ((lst === null))
3615 return sc_term_12;
3616 else
3617 if ((((term2 = ((lst.car).cdr.car)), (unify_subst_nboyer = null), (one_way_unify1_nboyer(sc_term_12, term2)))!== false))
3618 return (rewrite_nboyer((apply_subst_nboyer(unify_subst_nboyer, ((lst.car).cdr.cdr.car)))));
3619 else
3620 (lst = (lst.cdr));
3621 }
3622 }
3623 }
3624 };
3625 rewrite_args_nboyer = function(lst) {
3626 var sc_lst_14;
3627 return ((lst === null)?null:(new sc_Pair((rewrite_nboyer((lst.car))), ((sc_lst_14 = (lst.cdr)), ((sc_lst_14 === null)?null:(new sc_Pair((rewrite_nboyer((sc_lst_14.car))), (rewrite_args_nboyer((sc_lst_14.cdr))))))))));
3628 };
3629 (unify_subst_nboyer = "\u1E9C*");
3630 one_way_unify1_nboyer = function(term1, term2) {
3631 var lst1;
3632 var lst2;
3633 var temp_temp;
3634 if (!(term2 instanceof sc_Pair))
3635 {
3636 (temp_temp = (sc_assq(term2, unify_subst_nboyer)));
3637 if ((temp_temp!== false))
3638 return (is_term_equal_nboyer(term1, (temp_temp.cdr)));
3639 else
3640 if ((sc_isNumber(term2)))
3641 return (sc_isEqual(term1, term2));
3642 else
3643 {
3644 (unify_subst_nboyer = (new sc_Pair((new sc_Pair(term2, term1)), unify_subst_nboyer)));
3645 return true;
3646 }
3647 }
3648 else
3649 if (!(term1 instanceof sc_Pair))
3650 return false;
3651 else
3652 if (((term1.car)===(term2.car)))
3653 {
3654 (lst1 = (term1.cdr));
3655 (lst2 = (term2.cdr));
3656 while (true) {
3657 if ((lst1 === null))
3658 return (lst2 === null);
3659 else
3660 if ((lst2 === null))
3661 return false;
3662 else
3663 if (((one_way_unify1_nboyer((lst1.car), (lst2.car)))!== false))
3664 {
3665 (lst1 = (lst1.cdr));
3666 (lst2 = (lst2.cdr));
3667 }
3668 else
3669 return false;
3670 }
3671 }
3672 else
3673 return false;
3674 };
3675 (false_term_nboyer = "\u1E9C*");
3676 (true_term_nboyer = "\u1E9C*");
3677 trans_of_implies1_nboyer = function(n) {
3678 var sc_n_15;
3679 return ((sc_isEqual(n, (1)))?(sc_list("\u1E9Cimplies", (0), (1))):(sc_list("\u1E9Cand", (sc_list("\u1E9Cimplies", (n-(1)), n)), ((sc_n_15 = (n-(1))), ((sc_isEqual(sc_n_15, (1)))?(sc_list("\u1E9Cimplies", (0), (1))):(sc_list("\u1E9Cand", (sc_list("\u1E9Cimplies", (sc_n_15-(1)), sc_n_15)), (trans_of_implies1_nboyer((sc_n_15-(1)))))))))));
3680 };
3681 is_term_equal_nboyer = function(x, y) {
3682 var lst1;
3683 var lst2;
3684 var r2;
3685 var r1;
3686 if ((x instanceof sc_Pair))
3687 if ((y instanceof sc_Pair))
3688 if ((((r1 = (x.car)), (r2 = (y.car)), (r1===r2))!== false))
3689 {
3690 (lst1 = (x.cdr));
3691 (lst2 = (y.cdr));
3692 while (true) {
3693 if ((lst1 === null))
3694 return (lst2 === null);
3695 else
3696 if ((lst2 === null))
3697 return false;
3698 else
3699 if (((is_term_equal_nboyer((lst1.car), (lst2.car)))!== false))
3700 {
3701 (lst1 = (lst1.cdr));
3702 (lst2 = (lst2.cdr));
3703 }
3704 else
3705 return false;
3706 }
3707 }
3708 else
3709 return false;
3710 else
3711 return false;
3712 else
3713 return (sc_isEqual(x, y));
3714 };
3715 is_term_member_nboyer = function(x, lst) {
3716 var x;
3717 var lst;
3718 while (true) {
3719 if ((lst === null))
3720 return false;
3721 else
3722 if (((is_term_equal_nboyer(x, (lst.car)))!== false))
3723 return true;
3724 else
3725 (lst = (lst.cdr));
3726 }
3727 };
3728 BgL_setupzd2boyerzd2 = function() {
3729 var symbol_record;
3730 var value;
3731 var BgL_sc_symbolzd2record_16zd2;
3732 var sym;
3733 var sc_sym_17;
3734 var term;
3735 var lst;
3736 var sc_term_18;
3737 var sc_term_19;
3738 {
3739 (BgL_sc_za2symbolzd2recordszd2alistza2_2z00_nboyer = null);
3740 (if_constructor_nboyer = (BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer("\u1E9Cif")));
3741 (false_term_nboyer = ((sc_term_19 = (new sc_Pair("\u1E9Cf",null))), (!(sc_term_19 instanceof sc_Pair)?sc_term_19:(new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((sc_term_19.car))), (translate_args_nboyer((sc_term_19.cdr))))))));
3742 (true_term_nboyer = ((sc_term_18 = (new sc_Pair("\u1E9Ct",null))), (!(sc_term_18 instanceof sc_Pair)?sc_term_18:(new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((sc_term_18.car))), (translate_args_nboyer((sc_term_18.cdr))))))));
3743 (lst = sc_const_3_nboyer);
3744 while (!(lst === null)) {
3745 {
3746 (term = (lst.car));
3747 if (((term instanceof sc_Pair)&&(((term.car)==="\u1E9Cequal")&&((term.cdr.car) instanceof sc_Pair))))
3748 {
3749 (sc_sym_17 = ((term.cdr.car).car));
3750 (value = (new sc_Pair((!(term instanceof sc_Pair)?term:(new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((term.car))), (translate_args_nboyer((term.cdr)))))), ((sym = ((term.cdr.car).car)), (BgL_sc_symbolzd2record_16zd2 = (BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer(sym))), (BgL_sc_symbolzd2record_16zd2[(1)])))));
3751 (symbol_record = (BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer(sc_sym_17)));
3752 (symbol_record[(1)] = value);
3753 }
3754 else
3755 (sc_error("ADD-LEMMA did not like term: ", term));
3756 (lst = (lst.cdr));
3757 }
3758 }
3759 return true;
3760 }
3761 };
3762 BgL_testzd2boyerzd2 = function(n) {
3763 var optrOpnd;
3764 var term;
3765 var sc_n_20;
3766 var answer;
3767 var sc_term_21;
3768 var sc_term_22;
3769 {
3770 (rewrite_count_nboyer = (0));
3771 (term = sc_const_4_nboyer);
3772 (sc_n_20 = n);
3773 while (!(sc_n_20=== 0)) {
3774 {
3775 (term = (sc_list("\u1E9Cor", term, (new sc_Pair("\u1E9Cf",null)))));
3776 (--sc_n_20);
3777 }
3778 }
3779 (sc_term_22 = term);
3780 if (!(sc_term_22 instanceof sc_Pair))
3781 (optrOpnd = sc_term_22);
3782 else
3783 (optrOpnd = (new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((sc_term_22.car))), (translate_args_nboyer((sc_term_22.cdr))))));
3784 (sc_term_21 = (apply_subst_nboyer(((const_nboyer === null)?null:(new sc_Pair((new sc_Pair((const_nboyer.car.car), (translate_term_nboyer((const_nboyer.car.cdr))))), (translate_alist_nboyer((const_nboyer.cdr)))))), optrOpnd)));
3785 (answer = (tautologyp_nboyer((rewrite_nboyer(sc_term_21)), null, null)));
3786 (sc_write(rewrite_count_nboyer));
3787 (sc_display(" rewrites"));
3788 (sc_newline());
3789 if ((answer!== false))
3790 return rewrite_count_nboyer;
3791 else
3792 return false;
3793 }
3794 };
3795}
3796/* Exported Variables */
3797var BgL_parsezd2ze3nbzd2treesze3;
3798var BgL_earleyzd2benchmarkzd2;
3799var BgL_parsezd2ze3parsedzf3zc2;
3800var test;
3801var BgL_parsezd2ze3treesz31;
3802var BgL_makezd2parserzd2;
3803/* End Exports */
3804
3805var const_earley;
3806{
3807 (const_earley = (new sc_Pair((new sc_Pair("\u1E9Cs",(new sc_Pair((new sc_Pair("\u1E9Ca",null)),(new sc_Pair((new sc_Pair("\u1E9Cs",(new sc_Pair("\u1E9Cs",null)))),null)))))),null)));
3808 BgL_makezd2parserzd2 = function(grammar, lexer) {
3809 var i;
3810 var parser_descr;
3811 var def_loop;
3812 var nb_nts;
3813 var names;
3814 var steps;
3815 var predictors;
3816 var enders;
3817 var starters;
3818 var nts;
3819 var sc_names_1;
3820 var sc_steps_2;
3821 var sc_predictors_3;
3822 var sc_enders_4;
3823 var sc_starters_5;
3824 var nb_confs;
3825 var BgL_sc_defzd2loop_6zd2;
3826 var BgL_sc_nbzd2nts_7zd2;
3827 var sc_nts_8;
3828 var BgL_sc_defzd2loop_9zd2;
3829 var ind;
3830 {
3831 ind = function(nt, sc_nts_10) {
3832 var i;
3833 {
3834 (i = ((sc_nts_10.length)-(1)));
3835 while (true) {
3836 if ((i>=(0)))
3837 if ((sc_isEqual((sc_nts_10[i]), nt)))
3838 return i;
3839 else
3840 (--i);
3841 else
3842 return false;
3843 }
3844 }
3845 };
3846 (sc_nts_8 = ((BgL_sc_defzd2loop_9zd2 = function(defs, sc_nts_11) {
3847 var rule_loop;
3848 var head;
3849 var def;
3850 return ((defs instanceof sc_Pair)?((def = (defs.car)), (head = (def.car)), (rule_loop = function(rules, sc_nts_12) {
3851 var nt;
3852 var l;
3853 var sc_nts_13;
3854 var rule;
3855 if ((rules instanceof sc_Pair))
3856 {
3857 (rule = (rules.car));
3858 (l = rule);
3859 (sc_nts_13 = sc_nts_12);
3860 while ((l instanceof sc_Pair)) {
3861 {
3862 (nt = (l.car));
3863 (l = (l.cdr));
3864 (sc_nts_13 = (((sc_member(nt, sc_nts_13))!== false)?sc_nts_13:(new sc_Pair(nt, sc_nts_13))));
3865 }
3866 }
3867 return (rule_loop((rules.cdr), sc_nts_13));
3868 }
3869 else
3870 return (BgL_sc_defzd2loop_9zd2((defs.cdr), sc_nts_12));
3871 }), (rule_loop((def.cdr), (((sc_member(head, sc_nts_11))!== false)?sc_nts_11:(new sc_Pair(head, sc_nts_11)))))):(sc_list2vector((sc_reverse(sc_nts_11)))));
3872 }), (BgL_sc_defzd2loop_9zd2(grammar, null))));
3873 (BgL_sc_nbzd2nts_7zd2 = (sc_nts_8.length));
3874 (nb_confs = (((BgL_sc_defzd2loop_6zd2 = function(defs, BgL_sc_nbzd2confs_14zd2) {
3875 var rule_loop;
3876 var def;
3877 return ((defs instanceof sc_Pair)?((def = (defs.car)), (rule_loop = function(rules, BgL_sc_nbzd2confs_15zd2) {
3878 var l;
3879 var BgL_sc_nbzd2confs_16zd2;
3880 var rule;
3881 if ((rules instanceof sc_Pair))
3882 {
3883 (rule = (rules.car));
3884 (l = rule);
3885 (BgL_sc_nbzd2confs_16zd2 = BgL_sc_nbzd2confs_15zd2);
3886 while ((l instanceof sc_Pair)) {
3887 {
3888 (l = (l.cdr));
3889 (++BgL_sc_nbzd2confs_16zd2);
3890 }
3891 }
3892 return (rule_loop((rules.cdr), (BgL_sc_nbzd2confs_16zd2+(1))));
3893 }
3894 else
3895 return (BgL_sc_defzd2loop_6zd2((defs.cdr), BgL_sc_nbzd2confs_15zd2));
3896 }), (rule_loop((def.cdr), BgL_sc_nbzd2confs_14zd2))):BgL_sc_nbzd2confs_14zd2);
3897 }), (BgL_sc_defzd2loop_6zd2(grammar, (0))))+BgL_sc_nbzd2nts_7zd2));
3898 (sc_starters_5 = (sc_makeVector(BgL_sc_nbzd2nts_7zd2, null)));
3899 (sc_enders_4 = (sc_makeVector(BgL_sc_nbzd2nts_7zd2, null)));
3900 (sc_predictors_3 = (sc_makeVector(BgL_sc_nbzd2nts_7zd2, null)));
3901 (sc_steps_2 = (sc_makeVector(nb_confs, false)));
3902 (sc_names_1 = (sc_makeVector(nb_confs, false)));
3903 (nts = sc_nts_8);
3904 (starters = sc_starters_5);
3905 (enders = sc_enders_4);
3906 (predictors = sc_predictors_3);
3907 (steps = sc_steps_2);
3908 (names = sc_names_1);
3909 (nb_nts = (sc_nts_8.length));
3910 (i = (nb_nts-(1)));
3911 while ((i>=(0))) {
3912 {
3913 (sc_steps_2[i] = (i-nb_nts));
3914 (sc_names_1[i] = (sc_list((sc_nts_8[i]), (0))));
3915 (sc_enders_4[i] = (sc_list(i)));
3916 (--i);
3917 }
3918 }
3919 def_loop = function(defs, conf) {
3920 var rule_loop;
3921 var head;
3922 var def;
3923 return ((defs instanceof sc_Pair)?((def = (defs.car)), (head = (def.car)), (rule_loop = function(rules, conf, rule_num) {
3924 var i;
3925 var sc_i_17;
3926 var nt;
3927 var l;
3928 var sc_conf_18;
3929 var sc_i_19;
3930 var rule;
3931 if ((rules instanceof sc_Pair))
3932 {
3933 (rule = (rules.car));
3934 (names[conf] = (sc_list(head, rule_num)));
3935 (sc_i_19 = (ind(head, nts)));
3936 (starters[sc_i_19] = (new sc_Pair(conf, (starters[sc_i_19]))));
3937 (l = rule);
3938 (sc_conf_18 = conf);
3939 while ((l instanceof sc_Pair)) {
3940 {
3941 (nt = (l.car));
3942 (steps[sc_conf_18] = (ind(nt, nts)));
3943 (sc_i_17 = (ind(nt, nts)));
3944 (predictors[sc_i_17] = (new sc_Pair(sc_conf_18, (predictors[sc_i_17]))));
3945 (l = (l.cdr));
3946 (++sc_conf_18);
3947 }
3948 }
3949 (steps[sc_conf_18] = ((ind(head, nts))-nb_nts));
3950 (i = (ind(head, nts)));
3951 (enders[i] = (new sc_Pair(sc_conf_18, (enders[i]))));
3952 return (rule_loop((rules.cdr), (sc_conf_18+(1)), (rule_num+(1))));
3953 }
3954 else
3955 return (def_loop((defs.cdr), conf));
3956 }), (rule_loop((def.cdr), conf, (1)))):undefined);
3957 };
3958 (def_loop(grammar, (sc_nts_8.length)));
3959 (parser_descr = [lexer, sc_nts_8, sc_starters_5, sc_enders_4, sc_predictors_3, sc_steps_2, sc_names_1]);
3960 return function(input) {
3961 var optrOpnd;
3962 var sc_optrOpnd_20;
3963 var sc_optrOpnd_21;
3964 var sc_optrOpnd_22;
3965 var loop1;
3966 var BgL_sc_stateza2_23za2;
3967 var toks;
3968 var BgL_sc_nbzd2nts_24zd2;
3969 var sc_steps_25;
3970 var sc_enders_26;
3971 var state_num;
3972 var BgL_sc_statesza2_27za2;
3973 var states;
3974 var i;
3975 var conf;
3976 var l;
3977 var tok_nts;
3978 var sc_i_28;
3979 var sc_i_29;
3980 var l1;
3981 var l2;
3982 var tok;
3983 var tail1129;
3984 var L1125;
3985 var goal_enders;
3986 var BgL_sc_statesza2_30za2;
3987 var BgL_sc_nbzd2nts_31zd2;
3988 var BgL_sc_nbzd2confs_32zd2;
3989 var nb_toks;
3990 var goal_starters;
3991 var sc_states_33;
3992 var BgL_sc_nbzd2confs_34zd2;
3993 var BgL_sc_nbzd2toks_35zd2;
3994 var sc_toks_36;
3995 var falseHead1128;
3996 var sc_names_37;
3997 var sc_steps_38;
3998 var sc_predictors_39;
3999 var sc_enders_40;
4000 var sc_starters_41;
4001 var sc_nts_42;
4002 var lexer;
4003 var sc_ind_43;
4004 var make_states;
4005 var BgL_sc_confzd2setzd2getza2_44za2;
4006 var conf_set_merge_new_bang;
4007 var conf_set_adjoin;
4008 var BgL_sc_confzd2setzd2adjoinza2_45za2;
4009 var BgL_sc_confzd2setzd2adjoinza2za2_46z00;
4010 var conf_set_union;
4011 var forw;
4012 var is_parsed;
4013 var deriv_trees;
4014 var BgL_sc_derivzd2treesza2_47z70;
4015 var nb_deriv_trees;
4016 var BgL_sc_nbzd2derivzd2treesza2_48za2;
4017 {
4018 sc_ind_43 = function(nt, sc_nts_49) {
4019 var i;
4020 {
4021 (i = ((sc_nts_49.length)-(1)));
4022 while (true) {
4023 if ((i>=(0)))
4024 if ((sc_isEqual((sc_nts_49[i]), nt)))
4025 return i;
4026 else
4027 (--i);
4028 else
4029 return false;
4030 }
4031 }
4032 };
4033 make_states = function(BgL_sc_nbzd2toks_50zd2, BgL_sc_nbzd2confs_51zd2) {
4034 var v;
4035 var i;
4036 var sc_states_52;
4037 {
4038 (sc_states_52 = (sc_makeVector((BgL_sc_nbzd2toks_50zd2+(1)), false)));
4039 (i = BgL_sc_nbzd2toks_50zd2);
4040 while ((i>=(0))) {
4041 {
4042 (v = (sc_makeVector((BgL_sc_nbzd2confs_51zd2+(1)), false)));
4043 (v[(0)] = (-1));
4044 (sc_states_52[i] = v);
4045 (--i);
4046 }
4047 }
4048 return sc_states_52;
4049 }
4050 };
4051 BgL_sc_confzd2setzd2getza2_44za2 = function(state, BgL_sc_statezd2num_53zd2, sc_conf_54) {
4052 var conf_set;
4053 var BgL_sc_confzd2set_55zd2;
4054 return ((BgL_sc_confzd2set_55zd2 = (state[(sc_conf_54+(1))])), ((BgL_sc_confzd2set_55zd2!== false)?BgL_sc_confzd2set_55zd2:((conf_set = (sc_makeVector((BgL_sc_statezd2num_53zd2+(6)), false))), (conf_set[(1)] = (-3)), (conf_set[(2)] = (-1)), (conf_set[(3)] = (-1)), (conf_set[(4)] = (-1)), (state[(sc_conf_54+(1))] = conf_set), conf_set)));
4055 };
4056 conf_set_merge_new_bang = function(conf_set) {
4057 return ((conf_set[((conf_set[(1)])+(5))] = (conf_set[(4)])), (conf_set[(1)] = (conf_set[(3)])), (conf_set[(3)] = (-1)), (conf_set[(4)] = (-1)));
4058 };
4059 conf_set_adjoin = function(state, conf_set, sc_conf_56, i) {
4060 var tail;
4061 return ((tail = (conf_set[(3)])), (conf_set[(i+(5))] = (-1)), (conf_set[(tail+(5))] = i), (conf_set[(3)] = i), ((tail<(0))?((conf_set[(0)] = (state[(0)])), (state[(0)] = sc_conf_56)):undefined));
4062 };
4063 BgL_sc_confzd2setzd2adjoinza2_45za2 = function(sc_states_57, BgL_sc_statezd2num_58zd2, l, i) {
4064 var conf_set;
4065 var sc_conf_59;
4066 var l1;
4067 var state;
4068 {
4069 (state = (sc_states_57[BgL_sc_statezd2num_58zd2]));
4070 (l1 = l);
4071 while ((l1 instanceof sc_Pair)) {
4072 {
4073 (sc_conf_59 = (l1.car));
4074 (conf_set = (BgL_sc_confzd2setzd2getza2_44za2(state, BgL_sc_statezd2num_58zd2, sc_conf_59)));
4075 if (((conf_set[(i+(5))])=== false))
4076 {
4077 (conf_set_adjoin(state, conf_set, sc_conf_59, i));
4078 (l1 = (l1.cdr));
4079 }
4080 else
4081 (l1 = (l1.cdr));
4082 }
4083 }
4084 return undefined;
4085 }
4086 };
4087 BgL_sc_confzd2setzd2adjoinza2za2_46z00 = function(sc_states_60, BgL_sc_statesza2_61za2, BgL_sc_statezd2num_62zd2, sc_conf_63, i) {
4088 var BgL_sc_confzd2setza2_64z70;
4089 var BgL_sc_stateza2_65za2;
4090 var conf_set;
4091 var state;
4092 return ((state = (sc_states_60[BgL_sc_statezd2num_62zd2])), ((((conf_set = (state[(sc_conf_63+(1))])), ((conf_set!== false)?(conf_set[(i+(5))]):false))!== false)?((BgL_sc_stateza2_65za2 = (BgL_sc_statesza2_61za2[BgL_sc_statezd2num_62zd2])), (BgL_sc_confzd2setza2_64z70 = (BgL_sc_confzd2setzd2getza2_44za2(BgL_sc_stateza2_65za2, BgL_sc_statezd2num_62zd2, sc_conf_63))), (((BgL_sc_confzd2setza2_64z70[(i+(5))])=== false)?(conf_set_adjoin(BgL_sc_stateza2_65za2, BgL_sc_confzd2setza2_64z70, sc_conf_63, i)):undefined), true):false));
4093 };
4094 conf_set_union = function(state, conf_set, sc_conf_66, other_set) {
4095 var i;
4096 {
4097 (i = (other_set[(2)]));
4098 while ((i>=(0))) {
4099 if (((conf_set[(i+(5))])=== false))
4100 {
4101 (conf_set_adjoin(state, conf_set, sc_conf_66, i));
4102 (i = (other_set[(i+(5))]));
4103 }
4104 else
4105 (i = (other_set[(i+(5))]));
4106 }
4107 return undefined;
4108 }
4109 };
4110 forw = function(sc_states_67, BgL_sc_statezd2num_68zd2, sc_starters_69, sc_enders_70, sc_predictors_71, sc_steps_72, sc_nts_73) {
4111 var next_set;
4112 var next;
4113 var conf_set;
4114 var ender;
4115 var l;
4116 var starter_set;
4117 var starter;
4118 var sc_l_74;
4119 var sc_loop1_75;
4120 var head;
4121 var BgL_sc_confzd2set_76zd2;
4122 var BgL_sc_statezd2num_77zd2;
4123 var state;
4124 var sc_states_78;
4125 var preds;
4126 var BgL_sc_confzd2set_79zd2;
4127 var step;
4128 var sc_conf_80;
4129 var BgL_sc_nbzd2nts_81zd2;
4130 var sc_state_82;
4131 {
4132 (sc_state_82 = (sc_states_67[BgL_sc_statezd2num_68zd2]));
4133 (BgL_sc_nbzd2nts_81zd2 = (sc_nts_73.length));
4134 while (true) {
4135 {
4136 (sc_conf_80 = (sc_state_82[(0)]));
4137 if ((sc_conf_80>=(0)))
4138 {
4139 (step = (sc_steps_72[sc_conf_80]));
4140 (BgL_sc_confzd2set_79zd2 = (sc_state_82[(sc_conf_80+(1))]));
4141 (head = (BgL_sc_confzd2set_79zd2[(4)]));
4142 (sc_state_82[(0)] = (BgL_sc_confzd2set_79zd2[(0)]));
4143 (conf_set_merge_new_bang(BgL_sc_confzd2set_79zd2));
4144 if ((step>=(0)))
4145 {
4146 (sc_l_74 = (sc_starters_69[step]));
4147 while ((sc_l_74 instanceof sc_Pair)) {
4148 {
4149 (starter = (sc_l_74.car));
4150 (starter_set = (BgL_sc_confzd2setzd2getza2_44za2(sc_state_82, BgL_sc_statezd2num_68zd2, starter)));
4151 if (((starter_set[(BgL_sc_statezd2num_68zd2+(5))])=== false))
4152 {
4153 (conf_set_adjoin(sc_state_82, starter_set, starter, BgL_sc_statezd2num_68zd2));
4154 (sc_l_74 = (sc_l_74.cdr));
4155 }
4156 else
4157 (sc_l_74 = (sc_l_74.cdr));
4158 }
4159 }
4160 (l = (sc_enders_70[step]));
4161 while ((l instanceof sc_Pair)) {
4162 {
4163 (ender = (l.car));
4164 if ((((conf_set = (sc_state_82[(ender+(1))])), ((conf_set!== false)?(conf_set[(BgL_sc_statezd2num_68zd2+(5))]):false))!== false))
4165 {
4166 (next = (sc_conf_80+(1)));
4167 (next_set = (BgL_sc_confzd2setzd2getza2_44za2(sc_state_82, BgL_sc_statezd2num_68zd2, next)));
4168 (conf_set_union(sc_state_82, next_set, next, BgL_sc_confzd2set_79zd2));
4169 (l = (l.cdr));
4170 }
4171 else
4172 (l = (l.cdr));
4173 }
4174 }
4175 }
4176 else
4177 {
4178 (preds = (sc_predictors_71[(step+BgL_sc_nbzd2nts_81zd2)]));
4179 (sc_states_78 = sc_states_67);
4180 (state = sc_state_82);
4181 (BgL_sc_statezd2num_77zd2 = BgL_sc_statezd2num_68zd2);
4182 (BgL_sc_confzd2set_76zd2 = BgL_sc_confzd2set_79zd2);
4183 sc_loop1_75 = function(l) {
4184 var sc_state_83;
4185 var BgL_sc_nextzd2set_84zd2;
4186 var sc_next_85;
4187 var pred_set;
4188 var i;
4189 var pred;
4190 if ((l instanceof sc_Pair))
4191 {
4192 (pred = (l.car));
4193 (i = head);
4194 while ((i>=(0))) {
4195 {
4196 (pred_set = ((sc_state_83 = (sc_states_78[i])), (sc_state_83[(pred+(1))])));
4197 if ((pred_set!== false))
4198 {
4199 (sc_next_85 = (pred+(1)));
4200 (BgL_sc_nextzd2set_84zd2 = (BgL_sc_confzd2setzd2getza2_44za2(state, BgL_sc_statezd2num_77zd2, sc_next_85)));
4201 (conf_set_union(state, BgL_sc_nextzd2set_84zd2, sc_next_85, pred_set));
4202 }
4203 (i = (BgL_sc_confzd2set_76zd2[(i+(5))]));
4204 }
4205 }
4206 return (sc_loop1_75((l.cdr)));
4207 }
4208 else
4209 return undefined;
4210 };
4211 (sc_loop1_75(preds));
4212 }
4213 }
4214 else
4215 return undefined;
4216 }
4217 }
4218 }
4219 };
4220 is_parsed = function(nt, i, j, sc_nts_86, sc_enders_87, sc_states_88) {
4221 var conf_set;
4222 var state;
4223 var sc_conf_89;
4224 var l;
4225 var BgL_sc_ntza2_90za2;
4226 {
4227 (BgL_sc_ntza2_90za2 = (sc_ind_43(nt, sc_nts_86)));
4228 if ((BgL_sc_ntza2_90za2!== false))
4229 {
4230 (sc_nts_86.length);
4231 (l = (sc_enders_87[BgL_sc_ntza2_90za2]));
4232 while (true) {
4233 if ((l instanceof sc_Pair))
4234 {
4235 (sc_conf_89 = (l.car));
4236 if ((((state = (sc_states_88[j])), (conf_set = (state[(sc_conf_89+(1))])), ((conf_set!== false)?(conf_set[(i+(5))]):false))!== false))
4237 return true;
4238 else
4239 (l = (l.cdr));
4240 }
4241 else
4242 return false;
4243 }
4244 }
4245 else
4246 return false;
4247 }
4248 };
4249 deriv_trees = function(sc_conf_91, i, j, sc_enders_92, sc_steps_93, sc_names_94, sc_toks_95, sc_states_96, BgL_sc_nbzd2nts_97zd2) {
4250 var sc_loop1_98;
4251 var prev;
4252 var name;
4253 return ((name = (sc_names_94[sc_conf_91])), ((name!== false)?((sc_conf_91<BgL_sc_nbzd2nts_97zd2)?(sc_list((sc_list(name, ((sc_toks_95[i]).car))))):(sc_list((sc_list(name))))):((prev = (sc_conf_91-(1))), (sc_loop1_98 = function(l1, l2) {
4254 var loop2;
4255 var ender_set;
4256 var state;
4257 var ender;
4258 var l1;
4259 var l2;
4260 while (true) {
4261 if ((l1 instanceof sc_Pair))
4262 {
4263 (ender = (l1.car));
4264 (ender_set = ((state = (sc_states_96[j])), (state[(ender+(1))])));
4265 if ((ender_set!== false))
4266 {
4267 loop2 = function(k, l2) {
4268 var loop3;
4269 var ender_trees;
4270 var prev_trees;
4271 var conf_set;
4272 var sc_state_99;
4273 var k;
4274 var l2;
4275 while (true) {
4276 if ((k>=(0)))
4277 if (((k>=i)&&(((sc_state_99 = (sc_states_96[k])), (conf_set = (sc_state_99[(prev+(1))])), ((conf_set!== false)?(conf_set[(i+(5))]):false))!== false)))
4278 {
4279 (prev_trees = (deriv_trees(prev, i, k, sc_enders_92, sc_steps_93, sc_names_94, sc_toks_95, sc_states_96, BgL_sc_nbzd2nts_97zd2)));
4280 (ender_trees = (deriv_trees(ender, k, j, sc_enders_92, sc_steps_93, sc_names_94, sc_toks_95, sc_states_96, BgL_sc_nbzd2nts_97zd2)));
4281 loop3 = function(l3, l2) {
4282 var l4;
4283 var sc_l2_100;
4284 var ender_tree;
4285 if ((l3 instanceof sc_Pair))
4286 {
4287 (ender_tree = (sc_list((l3.car))));
4288 (l4 = prev_trees);
4289 (sc_l2_100 = l2);
4290 while ((l4 instanceof sc_Pair)) {
4291 {
4292 (sc_l2_100 = (new sc_Pair((sc_append((l4.car), ender_tree)), sc_l2_100)));
4293 (l4 = (l4.cdr));
4294 }
4295 }
4296 return (loop3((l3.cdr), sc_l2_100));
4297 }
4298 else
4299 return (loop2((ender_set[(k+(5))]), l2));
4300 };
4301 return (loop3(ender_trees, l2));
4302 }
4303 else
4304 (k = (ender_set[(k+(5))]));
4305 else
4306 return (sc_loop1_98((l1.cdr), l2));
4307 }
4308 };
4309 return (loop2((ender_set[(2)]), l2));
4310 }
4311 else
4312 (l1 = (l1.cdr));
4313 }
4314 else
4315 return l2;
4316 }
4317 }), (sc_loop1_98((sc_enders_92[(sc_steps_93[prev])]), null)))));
4318 };
4319 BgL_sc_derivzd2treesza2_47z70 = function(nt, i, j, sc_nts_101, sc_enders_102, sc_steps_103, sc_names_104, sc_toks_105, sc_states_106) {
4320 var conf_set;
4321 var state;
4322 var sc_conf_107;
4323 var l;
4324 var trees;
4325 var BgL_sc_nbzd2nts_108zd2;
4326 var BgL_sc_ntza2_109za2;
4327 {
4328 (BgL_sc_ntza2_109za2 = (sc_ind_43(nt, sc_nts_101)));
4329 if ((BgL_sc_ntza2_109za2!== false))
4330 {
4331 (BgL_sc_nbzd2nts_108zd2 = (sc_nts_101.length));
4332 (l = (sc_enders_102[BgL_sc_ntza2_109za2]));
4333 (trees = null);
4334 while ((l instanceof sc_Pair)) {
4335 {
4336 (sc_conf_107 = (l.car));
4337 if ((((state = (sc_states_106[j])), (conf_set = (state[(sc_conf_107+(1))])), ((conf_set!== false)?(conf_set[(i+(5))]):false))!== false))
4338 {
4339 (l = (l.cdr));
4340 (trees = (sc_append((deriv_trees(sc_conf_107, i, j, sc_enders_102, sc_steps_103, sc_names_104, sc_toks_105, sc_states_106, BgL_sc_nbzd2nts_108zd2)), trees)));
4341 }
4342 else
4343 (l = (l.cdr));
4344 }
4345 }
4346 return trees;
4347 }
4348 else
4349 return false;
4350 }
4351 };
4352 nb_deriv_trees = function(sc_conf_110, i, j, sc_enders_111, sc_steps_112, sc_toks_113, sc_states_114, BgL_sc_nbzd2nts_115zd2) {
4353 var sc_loop1_116;
4354 var tmp1124;
4355 var prev;
4356 return ((prev = (sc_conf_110-(1))), ((((tmp1124 = (sc_conf_110<BgL_sc_nbzd2nts_115zd2)), ((tmp1124!== false)?tmp1124:((sc_steps_112[prev])<(0))))!== false)?(1):((sc_loop1_116 = function(l, sc_n_118) {
4357 var nb_ender_trees;
4358 var nb_prev_trees;
4359 var conf_set;
4360 var state;
4361 var k;
4362 var n;
4363 var ender_set;
4364 var sc_state_117;
4365 var ender;
4366 var l;
4367 var sc_n_118;
4368 while (true) {
4369 if ((l instanceof sc_Pair))
4370 {
4371 (ender = (l.car));
4372 (ender_set = ((sc_state_117 = (sc_states_114[j])), (sc_state_117[(ender+(1))])));
4373 if ((ender_set!== false))
4374 {
4375 (k = (ender_set[(2)]));
4376 (n = sc_n_118);
4377 while ((k>=(0))) {
4378 if (((k>=i)&&(((state = (sc_states_114[k])), (conf_set = (state[(prev+(1))])), ((conf_set!== false)?(conf_set[(i+(5))]):false))!== false)))
4379 {
4380 (nb_prev_trees = (nb_deriv_trees(prev, i, k, sc_enders_111, sc_steps_112, sc_toks_113, sc_states_114, BgL_sc_nbzd2nts_115zd2)));
4381 (nb_ender_trees = (nb_deriv_trees(ender, k, j, sc_enders_111, sc_steps_112, sc_toks_113, sc_states_114, BgL_sc_nbzd2nts_115zd2)));
4382 (k = (ender_set[(k+(5))]));
4383 (n +=(nb_prev_trees*nb_ender_trees));
4384 }
4385 else
4386 (k = (ender_set[(k+(5))]));
4387 }
4388 return (sc_loop1_116((l.cdr), n));
4389 }
4390 else
4391 (l = (l.cdr));
4392 }
4393 else
4394 return sc_n_118;
4395 }
4396 }), (sc_loop1_116((sc_enders_111[(sc_steps_112[prev])]), (0))))));
4397 };
4398 BgL_sc_nbzd2derivzd2treesza2_48za2 = function(nt, i, j, sc_nts_119, sc_enders_120, sc_steps_121, sc_toks_122, sc_states_123) {
4399 var conf_set;
4400 var state;
4401 var sc_conf_124;
4402 var l;
4403 var nb_trees;
4404 var BgL_sc_nbzd2nts_125zd2;
4405 var BgL_sc_ntza2_126za2;
4406 {
4407 (BgL_sc_ntza2_126za2 = (sc_ind_43(nt, sc_nts_119)));
4408 if ((BgL_sc_ntza2_126za2!== false))
4409 {
4410 (BgL_sc_nbzd2nts_125zd2 = (sc_nts_119.length));
4411 (l = (sc_enders_120[BgL_sc_ntza2_126za2]));
4412 (nb_trees = (0));
4413 while ((l instanceof sc_Pair)) {
4414 {
4415 (sc_conf_124 = (l.car));
4416 if ((((state = (sc_states_123[j])), (conf_set = (state[(sc_conf_124+(1))])), ((conf_set!== false)?(conf_set[(i+(5))]):false))!== false))
4417 {
4418 (l = (l.cdr));
4419 (nb_trees = ((nb_deriv_trees(sc_conf_124, i, j, sc_enders_120, sc_steps_121, sc_toks_122, sc_states_123, BgL_sc_nbzd2nts_125zd2))+nb_trees));
4420 }
4421 else
4422 (l = (l.cdr));
4423 }
4424 }
4425 return nb_trees;
4426 }
4427 else
4428 return false;
4429 }
4430 };
4431 (lexer = (parser_descr[(0)]));
4432 (sc_nts_42 = (parser_descr[(1)]));
4433 (sc_starters_41 = (parser_descr[(2)]));
4434 (sc_enders_40 = (parser_descr[(3)]));
4435 (sc_predictors_39 = (parser_descr[(4)]));
4436 (sc_steps_38 = (parser_descr[(5)]));
4437 (sc_names_37 = (parser_descr[(6)]));
4438 (falseHead1128 = (new sc_Pair(null, null)));
4439 (L1125 = (lexer(input)));
4440 (tail1129 = falseHead1128);
4441 while (!(L1125 === null)) {
4442 {
4443 (tok = (L1125.car));
4444 (l1 = (tok.cdr));
4445 (l2 = null);
4446 while ((l1 instanceof sc_Pair)) {
4447 {
4448 (sc_i_29 = (sc_ind_43((l1.car), sc_nts_42)));
4449 if ((sc_i_29!== false))
4450 {
4451 (l1 = (l1.cdr));
4452 (l2 = (new sc_Pair(sc_i_29, l2)));
4453 }
4454 else
4455 (l1 = (l1.cdr));
4456 }
4457 }
4458 (sc_optrOpnd_22 = (new sc_Pair((tok.car), (sc_reverse(l2)))));
4459 (sc_optrOpnd_21 = (new sc_Pair(sc_optrOpnd_22, null)));
4460 (tail1129.cdr = sc_optrOpnd_21);
4461 (tail1129 = (tail1129.cdr));
4462 (L1125 = (L1125.cdr));
4463 }
4464 }
4465 (sc_optrOpnd_20 = (falseHead1128.cdr));
4466 (sc_toks_36 = (sc_list2vector(sc_optrOpnd_20)));
4467 (BgL_sc_nbzd2toks_35zd2 = (sc_toks_36.length));
4468 (BgL_sc_nbzd2confs_34zd2 = (sc_steps_38.length));
4469 (sc_states_33 = (make_states(BgL_sc_nbzd2toks_35zd2, BgL_sc_nbzd2confs_34zd2)));
4470 (goal_starters = (sc_starters_41[(0)]));
4471 (BgL_sc_confzd2setzd2adjoinza2_45za2(sc_states_33, (0), goal_starters, (0)));
4472 (forw(sc_states_33, (0), sc_starters_41, sc_enders_40, sc_predictors_39, sc_steps_38, sc_nts_42));
4473 (sc_i_28 = (0));
4474 while ((sc_i_28<BgL_sc_nbzd2toks_35zd2)) {
4475 {
4476 (tok_nts = ((sc_toks_36[sc_i_28]).cdr));
4477 (BgL_sc_confzd2setzd2adjoinza2_45za2(sc_states_33, (sc_i_28+(1)), tok_nts, sc_i_28));
4478 (forw(sc_states_33, (sc_i_28+(1)), sc_starters_41, sc_enders_40, sc_predictors_39, sc_steps_38, sc_nts_42));
4479 (++sc_i_28);
4480 }
4481 }
4482 (nb_toks = (sc_toks_36.length));
4483 (BgL_sc_nbzd2confs_32zd2 = (sc_steps_38.length));
4484 (BgL_sc_nbzd2nts_31zd2 = (sc_nts_42.length));
4485 (BgL_sc_statesza2_30za2 = (make_states(nb_toks, BgL_sc_nbzd2confs_32zd2)));
4486 (goal_enders = (sc_enders_40[(0)]));
4487 (l = goal_enders);
4488 while ((l instanceof sc_Pair)) {
4489 {
4490 (conf = (l.car));
4491 (BgL_sc_confzd2setzd2adjoinza2za2_46z00(sc_states_33, BgL_sc_statesza2_30za2, nb_toks, conf, (0)));
4492 (l = (l.cdr));
4493 }
4494 }
4495 (i = nb_toks);
4496 while ((i>=(0))) {
4497 {
4498 (states = sc_states_33);
4499 (BgL_sc_statesza2_27za2 = BgL_sc_statesza2_30za2);
4500 (state_num = i);
4501 (sc_enders_26 = sc_enders_40);
4502 (sc_steps_25 = sc_steps_38);
4503 (BgL_sc_nbzd2nts_24zd2 = BgL_sc_nbzd2nts_31zd2);
4504 (toks = sc_toks_36);
4505 (BgL_sc_stateza2_23za2 = (BgL_sc_statesza2_30za2[i]));
4506 loop1 = function() {
4507 var sc_loop1_127;
4508 var prev;
4509 var BgL_sc_statesza2_128za2;
4510 var sc_states_129;
4511 var j;
4512 var i;
4513 var sc_i_130;
4514 var head;
4515 var conf_set;
4516 var sc_conf_131;
4517 {
4518 (sc_conf_131 = (BgL_sc_stateza2_23za2[(0)]));
4519 if ((sc_conf_131>=(0)))
4520 {
4521 (conf_set = (BgL_sc_stateza2_23za2[(sc_conf_131+(1))]));
4522 (head = (conf_set[(4)]));
4523 (BgL_sc_stateza2_23za2[(0)] = (conf_set[(0)]));
4524 (conf_set_merge_new_bang(conf_set));
4525 (sc_i_130 = head);
4526 while ((sc_i_130>=(0))) {
4527 {
4528 (i = sc_i_130);
4529 (j = state_num);
4530 (sc_states_129 = states);
4531 (BgL_sc_statesza2_128za2 = BgL_sc_statesza2_27za2);
4532 (prev = (sc_conf_131-(1)));
4533 if (((sc_conf_131>=BgL_sc_nbzd2nts_24zd2)&&((sc_steps_25[prev])>=(0))))
4534 {
4535 sc_loop1_127 = function(l) {
4536 var k;
4537 var ender_set;
4538 var state;
4539 var ender;
4540 var l;
4541 while (true) {
4542 if ((l instanceof sc_Pair))
4543 {
4544 (ender = (l.car));
4545 (ender_set = ((state = (sc_states_129[j])), (state[(ender+(1))])));
4546 if ((ender_set!== false))
4547 {
4548 (k = (ender_set[(2)]));
4549 while ((k>=(0))) {
4550 {
4551 if ((k>=i))
4552 if (((BgL_sc_confzd2setzd2adjoinza2za2_46z00(sc_states_129, BgL_sc_statesza2_128za2, k, prev, i))!== false))
4553 (BgL_sc_confzd2setzd2adjoinza2za2_46z00(sc_states_129, BgL_sc_statesza2_128za2, j, ender, k));
4554 (k = (ender_set[(k+(5))]));
4555 }
4556 }
4557 return (sc_loop1_127((l.cdr)));
4558 }
4559 else
4560 (l = (l.cdr));
4561 }
4562 else
4563 return undefined;
4564 }
4565 };
4566 (sc_loop1_127((sc_enders_26[(sc_steps_25[prev])])));
4567 }
4568 (sc_i_130 = (conf_set[(sc_i_130+(5))]));
4569 }
4570 }
4571 return (loop1());
4572 }
4573 else
4574 return undefined;
4575 }
4576 };
4577 (loop1());
4578 (--i);
4579 }
4580 }
4581 (optrOpnd = BgL_sc_statesza2_30za2);
4582 return [sc_nts_42, sc_starters_41, sc_enders_40, sc_predictors_39, sc_steps_38, sc_names_37, sc_toks_36, optrOpnd, is_parsed, BgL_sc_derivzd2treesza2_47z70, BgL_sc_nbzd2derivzd2treesza2_48za2];
4583 }
4584 };
4585 }
4586 };
4587 BgL_parsezd2ze3parsedzf3zc2 = function(parse, nt, i, j) {
4588 var is_parsed;
4589 var states;
4590 var enders;
4591 var nts;
4592 return ((nts = (parse[(0)])), (enders = (parse[(2)])), (states = (parse[(7)])), (is_parsed = (parse[(8)])), (is_parsed(nt, i, j, nts, enders, states)));
4593 };
4594 BgL_parsezd2ze3treesz31 = function(parse, nt, i, j) {
4595 var BgL_sc_derivzd2treesza2_132z70;
4596 var states;
4597 var toks;
4598 var names;
4599 var steps;
4600 var enders;
4601 var nts;
4602 return ((nts = (parse[(0)])), (enders = (parse[(2)])), (steps = (parse[(4)])), (names = (parse[(5)])), (toks = (parse[(6)])), (states = (parse[(7)])), (BgL_sc_derivzd2treesza2_132z70 = (parse[(9)])), (BgL_sc_derivzd2treesza2_132z70(nt, i, j, nts, enders, steps, names, toks, states)));
4603 };
4604 BgL_parsezd2ze3nbzd2treesze3 = function(parse, nt, i, j) {
4605 var BgL_sc_nbzd2derivzd2treesza2_133za2;
4606 var states;
4607 var toks;
4608 var steps;
4609 var enders;
4610 var nts;
4611 return ((nts = (parse[(0)])), (enders = (parse[(2)])), (steps = (parse[(4)])), (toks = (parse[(6)])), (states = (parse[(7)])), (BgL_sc_nbzd2derivzd2treesza2_133za2 = (parse[(10)])), (BgL_sc_nbzd2derivzd2treesza2_133za2(nt, i, j, nts, enders, steps, toks, states)));
4612 };
4613 test = function(k) {
4614 var x;
4615 var p;
4616 return ((p = (BgL_makezd2parserzd2(const_earley, function(l) {
4617 var sc_x_134;
4618 var tail1134;
4619 var L1130;
4620 var falseHead1133;
4621 {
4622 (falseHead1133 = (new sc_Pair(null, null)));
4623 (tail1134 = falseHead1133);
4624 (L1130 = l);
4625 while (!(L1130 === null)) {
4626 {
4627 (tail1134.cdr = (new sc_Pair(((sc_x_134 = (L1130.car)), (sc_list(sc_x_134, sc_x_134))), null)));
4628 (tail1134 = (tail1134.cdr));
4629 (L1130 = (L1130.cdr));
4630 }
4631 }
4632 return (falseHead1133.cdr);
4633 }
4634 }))), (x = (p((sc_vector2list((sc_makeVector(k, "\u1E9Ca"))))))), (sc_length((BgL_parsezd2ze3treesz31(x, "\u1E9Cs", (0), k)))));
4635 };
4636 BgL_earleyzd2benchmarkzd2 = function() {
4637 var args = null;
4638 for (var sc_tmp = arguments.length - 1; sc_tmp >= 0; sc_tmp--) {
4639 args = sc_cons(arguments[sc_tmp], args);
4640 }
4641 var k;
4642 return ((k = ((args === null)?(7):(args.car))), (BgL_runzd2benchmarkzd2("earley", (1), function() {
4643 return (test(k));
4644 }, function(result) {
4645 return ((sc_display(result)), (sc_newline()), result == 132);
4646 })));
4647 };
4648}
4649
4650
4651/************* END OF GENERATED CODE *************/
4652// Invoke this function to run a benchmark.
4653// The first argument is a string identifying the benchmark.
4654// The second argument is the number of times to run the benchmark.
4655// The third argument is a function that runs the benchmark.
4656// The fourth argument is a unary function that warns if the result
4657// returned by the benchmark is incorrect.
4658//
4659// Example:
4660// RunBenchmark("new Array()",
4661// 1,
4662// function () { new Array(1000000); }
4663// function (v) {
4664// return (v instanceof Array) && (v.length == 1000000);
4665// });
4666
4667SC_DEFAULT_OUT = new sc_GenericOutputPort(function(s) {});
4668SC_ERROR_OUT = SC_DEFAULT_OUT;
4669
4670function RunBenchmark(name, count, run, warn) {
4671 for (var n = 0; n < count; ++n) {
4672 result = run();
4673 if (!warn(result)) {
4674 throw new Error("Earley or Boyer did incorrect number of rewrites");
4675 }
4676 }
4677}
4678
4679var BgL_runzd2benchmarkzd2 = RunBenchmark;
4680
4681for (var i = 0; i < 4; ++i) {
4682 BgL_earleyzd2benchmarkzd2();
4683 BgL_nboyerzd2benchmarkzd2();
4684}
4685
4686} catch (e) {
4687 print("JSC EXCEPTION FUZZ: Caught exception: " + e);
4688}
4689