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