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