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