michael@0: // This file is automatically generated by scheme2js, except for the michael@0: // benchmark harness code at the beginning and end of the file. michael@0: michael@0: var EarleyBoyer = new BenchmarkSuite('EarleyBoyer', 666463, [ michael@0: new Benchmark("Earley", function () { BgL_earleyzd2benchmarkzd2(); }), michael@0: new Benchmark("Boyer", function () { BgL_nboyerzd2benchmarkzd2(); }) michael@0: ]); michael@0: michael@0: michael@0: /************* GENERATED FILE - DO NOT EDIT *************/ michael@0: /************* GENERATED FILE - DO NOT EDIT *************/ michael@0: /************* GENERATED FILE - DO NOT EDIT *************/ michael@0: /************* GENERATED FILE - DO NOT EDIT *************/ michael@0: /************* GENERATED FILE - DO NOT EDIT *************/ michael@0: /************* GENERATED FILE - DO NOT EDIT *************/ michael@0: /************* GENERATED FILE - DO NOT EDIT *************/ michael@0: /************* GENERATED FILE - DO NOT EDIT *************/ michael@0: /* michael@0: * To use write/prints/... the default-output port has to be set first. michael@0: * Simply setting SC_DEFAULT_OUT and SC_ERROR_OUT to the desired values michael@0: * should do the trick. michael@0: * In the following example the std-out and error-port are redirected to michael@0: * a DIV. michael@0: function initRuntime() { michael@0: function escapeHTML(s) { michael@0: var tmp = s; michael@0: tmp = tmp.replace(/&/g, "&"); michael@0: tmp = tmp.replace(//g, ">"); michael@0: tmp = tmp.replace(/ /g, " "); michael@0: tmp = tmp.replace(/\n/g, "
"); michael@0: tmp = tmp.replace(/\t/g, "    "); michael@0: return tmp; michael@0: michael@0: } michael@0: michael@0: document.write("
"); michael@0: SC_DEFAULT_OUT = new sc_GenericOutputPort( michael@0: function(s) { michael@0: var stdout = document.getElementById('stdout'); michael@0: stdout.innerHTML = stdout.innerHTML + escapeHTML(s); michael@0: }); michael@0: SC_ERROR_OUT = SC_DEFAULT_OUT; michael@0: } michael@0: */ michael@0: michael@0: michael@0: function sc_print_debug() { michael@0: sc_print.apply(null, arguments); michael@0: } michael@0: /*** META ((export *js*)) */ michael@0: var sc_JS_GLOBALS = this; michael@0: michael@0: var __sc_LINE=-1; michael@0: var __sc_FILE=""; michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_alert() { michael@0: var len = arguments.length; michael@0: var s = ""; michael@0: var i; michael@0: michael@0: for( i = 0; i < len; i++ ) { michael@0: s += sc_toDisplayString(arguments[ i ]); michael@0: } michael@0: michael@0: return alert( s ); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_typeof( x ) { michael@0: return typeof x; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_error() { michael@0: var a = [sc_jsstring2symbol("*error*")]; michael@0: for (var i = 0; i < arguments.length; i++) { michael@0: a[i+1] = arguments[i]; michael@0: } michael@0: throw a; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (prefix "throw "))) michael@0: */ michael@0: function sc_raise(obj) { michael@0: throw obj; michael@0: } michael@0: michael@0: /*** META ((export with-handler-lambda)) */ michael@0: function sc_withHandlerLambda(handler, body) { michael@0: try { michael@0: return body(); michael@0: } catch(e) { michael@0: if (!e._internalException) michael@0: return handler(e); michael@0: else michael@0: throw e; michael@0: } michael@0: } michael@0: michael@0: var sc_properties = new Object(); michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_putpropBang(sym, key, val) { michael@0: var ht = sc_properties[sym]; michael@0: if (!ht) { michael@0: ht = new Object(); michael@0: sc_properties[sym] = ht; michael@0: } michael@0: ht[key] = val; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_getprop(sym, key) { michael@0: var ht = sc_properties[sym]; michael@0: if (ht) { michael@0: if (key in ht) michael@0: return ht[key]; michael@0: else michael@0: return false; michael@0: } else michael@0: return false; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_rempropBang(sym, key) { michael@0: var ht = sc_properties[sym]; michael@0: if (ht) michael@0: delete ht[key]; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_any2String(o) { michael@0: return jsstring2string(sc_toDisplayString(o)); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (infix 2 2 "===")) michael@0: (type bool)) michael@0: */ michael@0: function sc_isEqv(o1, o2) { michael@0: return (o1 === o2); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (infix 2 2 "===")) michael@0: (type bool)) michael@0: */ michael@0: function sc_isEq(o1, o2) { michael@0: return (o1 === o2); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool)) michael@0: */ michael@0: function sc_isNumber(n) { michael@0: return (typeof n === "number"); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool)) michael@0: */ michael@0: function sc_isComplex(n) { michael@0: return sc_isNumber(n); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool)) michael@0: */ michael@0: function sc_isReal(n) { michael@0: return sc_isNumber(n); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool)) michael@0: */ michael@0: function sc_isRational(n) { michael@0: return sc_isReal(n); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool)) michael@0: */ michael@0: function sc_isInteger(n) { michael@0: return (parseInt(n) === n); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool) michael@0: (peephole (postfix ", false"))) michael@0: */ michael@0: // we don't have exact numbers... michael@0: function sc_isExact(n) { michael@0: return false; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (postfix ", true")) michael@0: (type bool)) michael@0: */ michael@0: function sc_isInexact(n) { michael@0: return true; michael@0: } michael@0: michael@0: /*** META ((export = =fx =fl) michael@0: (type bool) michael@0: (peephole (infix 2 2 "==="))) michael@0: */ michael@0: function sc_equal(x) { michael@0: for (var i = 1; i < arguments.length; i++) michael@0: if (x !== arguments[i]) michael@0: return false; michael@0: return true; michael@0: } michael@0: michael@0: /*** META ((export < = arguments[i]) michael@0: return false; michael@0: x = arguments[i]; michael@0: } michael@0: return true; michael@0: } michael@0: michael@0: /*** META ((export > >fx >fl) michael@0: (type bool) michael@0: (peephole (infix 2 2 ">"))) michael@0: */ michael@0: function sc_greater(x, y) { michael@0: for (var i = 1; i < arguments.length; i++) { michael@0: if (x <= arguments[i]) michael@0: return false; michael@0: x = arguments[i]; michael@0: } michael@0: return true; michael@0: } michael@0: michael@0: /*** META ((export <= <=fx <=fl) michael@0: (type bool) michael@0: (peephole (infix 2 2 "<="))) michael@0: */ michael@0: function sc_lessEqual(x, y) { michael@0: for (var i = 1; i < arguments.length; i++) { michael@0: if (x > arguments[i]) michael@0: return false; michael@0: x = arguments[i]; michael@0: } michael@0: return true; michael@0: } michael@0: michael@0: /*** META ((export >= >=fl >=fx) michael@0: (type bool) michael@0: (peephole (infix 2 2 ">="))) michael@0: */ michael@0: function sc_greaterEqual(x, y) { michael@0: for (var i = 1; i < arguments.length; i++) { michael@0: if (x < arguments[i]) michael@0: return false; michael@0: x = arguments[i]; michael@0: } michael@0: return true; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool) michael@0: (peephole (postfix "=== 0"))) michael@0: */ michael@0: function sc_isZero(x) { michael@0: return (x === 0); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool) michael@0: (peephole (postfix "> 0"))) michael@0: */ michael@0: function sc_isPositive(x) { michael@0: return (x > 0); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool) michael@0: (peephole (postfix "< 0"))) michael@0: */ michael@0: function sc_isNegative(x) { michael@0: return (x < 0); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool) michael@0: (peephole (postfix "%2===1"))) michael@0: */ michael@0: function sc_isOdd(x) { michael@0: return (x % 2 === 1); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool) michael@0: (peephole (postfix "%2===0"))) michael@0: */ michael@0: function sc_isEven(x) { michael@0: return (x % 2 === 0); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: var sc_max = Math.max; michael@0: /*** META ((export #t)) */ michael@0: var sc_min = Math.min; michael@0: michael@0: /*** META ((export + +fx +fl) michael@0: (peephole (infix 0 #f "+" "0"))) michael@0: */ michael@0: function sc_plus() { michael@0: var sum = 0; michael@0: for (var i = 0; i < arguments.length; i++) michael@0: sum += arguments[i]; michael@0: return sum; michael@0: } michael@0: michael@0: /*** META ((export * *fx *fl) michael@0: (peephole (infix 0 #f "*" "1"))) michael@0: */ michael@0: function sc_multi() { michael@0: var product = 1; michael@0: for (var i = 0; i < arguments.length; i++) michael@0: product *= arguments[i]; michael@0: return product; michael@0: } michael@0: michael@0: /*** META ((export - -fx -fl) michael@0: (peephole (minus))) michael@0: */ michael@0: function sc_minus(x) { michael@0: if (arguments.length === 1) michael@0: return -x; michael@0: else { michael@0: var res = x; michael@0: for (var i = 1; i < arguments.length; i++) michael@0: res -= arguments[i]; michael@0: return res; michael@0: } michael@0: } michael@0: michael@0: /*** META ((export / /fl) michael@0: (peephole (div))) michael@0: */ michael@0: function sc_div(x) { michael@0: if (arguments.length === 1) michael@0: return 1/x; michael@0: else { michael@0: var res = x; michael@0: for (var i = 1; i < arguments.length; i++) michael@0: res /= arguments[i]; michael@0: return res; michael@0: } michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: var sc_abs = Math.abs; michael@0: michael@0: /*** META ((export quotient /fx) michael@0: (peephole (hole 2 "parseInt(" x "/" y ")"))) michael@0: */ michael@0: function sc_quotient(x, y) { michael@0: return parseInt(x / y); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (infix 2 2 "%"))) michael@0: */ michael@0: function sc_remainder(x, y) { michael@0: return x % y; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (modulo))) michael@0: */ michael@0: function sc_modulo(x, y) { michael@0: var remainder = x % y; michael@0: // if they don't have the same sign michael@0: if ((remainder * y) < 0) michael@0: return remainder + y; michael@0: else michael@0: return remainder; michael@0: } michael@0: michael@0: function sc_euclid_gcd(a, b) { michael@0: var temp; michael@0: if (a === 0) return b; michael@0: if (b === 0) return a; michael@0: if (a < 0) {a = -a;}; michael@0: if (b < 0) {b = -b;}; michael@0: if (b > a) {temp = a; a = b; b = temp;}; michael@0: while (true) { michael@0: a %= b; michael@0: if(a === 0) {return b;}; michael@0: b %= a; michael@0: if(b === 0) {return a;}; michael@0: }; michael@0: return b; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_gcd() { michael@0: var gcd = 0; michael@0: for (var i = 0; i < arguments.length; i++) michael@0: gcd = sc_euclid_gcd(gcd, arguments[i]); michael@0: return gcd; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_lcm() { michael@0: var lcm = 1; michael@0: for (var i = 0; i < arguments.length; i++) { michael@0: var f = Math.round(arguments[i] / sc_euclid_gcd(arguments[i], lcm)); michael@0: lcm *= Math.abs(f); michael@0: } michael@0: return lcm; michael@0: } michael@0: michael@0: // LIMITATION: numerator and denominator don't make sense in floating point world. michael@0: //var SC_MAX_DECIMALS = 1000000 michael@0: // michael@0: // function sc_numerator(x) { michael@0: // var rounded = Math.round(x * SC_MAX_DECIMALS); michael@0: // return Math.round(rounded / sc_euclid_gcd(rounded, SC_MAX_DECIMALS)); michael@0: // } michael@0: michael@0: // function sc_denominator(x) { michael@0: // var rounded = Math.round(x * SC_MAX_DECIMALS); michael@0: // return Math.round(SC_MAX_DECIMALS / sc_euclid_gcd(rounded, SC_MAX_DECIMALS)); michael@0: // } michael@0: michael@0: /*** META ((export #t)) */ michael@0: var sc_floor = Math.floor; michael@0: /*** META ((export #t)) */ michael@0: var sc_ceiling = Math.ceil; michael@0: /*** META ((export #t)) */ michael@0: var sc_truncate = parseInt; michael@0: /*** META ((export #t)) */ michael@0: var sc_round = Math.round; michael@0: michael@0: // LIMITATION: sc_rationalize doesn't make sense in a floating point world. michael@0: michael@0: /*** META ((export #t)) */ michael@0: var sc_exp = Math.exp; michael@0: /*** META ((export #t)) */ michael@0: var sc_log = Math.log; michael@0: /*** META ((export #t)) */ michael@0: var sc_sin = Math.sin; michael@0: /*** META ((export #t)) */ michael@0: var sc_cos = Math.cos; michael@0: /*** META ((export #t)) */ michael@0: var sc_tan = Math.tan; michael@0: /*** META ((export #t)) */ michael@0: var sc_asin = Math.asin; michael@0: /*** META ((export #t)) */ michael@0: var sc_acos = Math.acos; michael@0: /*** META ((export #t)) */ michael@0: var sc_atan = Math.atan; michael@0: michael@0: /*** META ((export #t)) */ michael@0: var sc_sqrt = Math.sqrt; michael@0: /*** META ((export #t)) */ michael@0: var sc_expt = Math.pow; michael@0: michael@0: // LIMITATION: we don't have complex numbers. michael@0: // LIMITATION: the following functions are hence not implemented. michael@0: // LIMITATION: make-rectangular, make-polar, real-part, imag-part, magnitude, angle michael@0: // LIMITATION: 2 argument atan michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (id))) michael@0: */ michael@0: function sc_exact2inexact(x) { michael@0: return x; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (id))) michael@0: */ michael@0: function sc_inexact2exact(x) { michael@0: return x; michael@0: } michael@0: michael@0: function sc_number2jsstring(x, radix) { michael@0: if (radix) michael@0: return x.toString(radix); michael@0: else michael@0: return x.toString(); michael@0: } michael@0: michael@0: function sc_jsstring2number(s, radix) { michael@0: if (s === "") return false; michael@0: michael@0: if (radix) { michael@0: var t = parseInt(s, radix); michael@0: if (!t && t !== 0) return false; michael@0: // verify that each char is in range. (parseInt ignores leading michael@0: // white and trailing chars) michael@0: var allowedChars = "01234567890abcdefghijklmnopqrstuvwxyz".substring(0, radix+1); michael@0: if ((new RegExp("^["+allowedChars+"]*$", "i")).test(s)) michael@0: return t; michael@0: else return false; michael@0: } else { michael@0: var t = +s; // does not ignore trailing chars. michael@0: if (!t && t !== 0) return false; michael@0: // simply verify that first char is not whitespace. michael@0: var c = s.charAt(0); michael@0: // if +c is 0, but the char is not "0", then we have a whitespace. michael@0: if (+c === 0 && c !== "0") return false; michael@0: return t; michael@0: } michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool) michael@0: (peephole (not))) michael@0: */ michael@0: function sc_not(b) { michael@0: return b === false; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool)) michael@0: */ michael@0: function sc_isBoolean(b) { michael@0: return (b === true) || (b === false); michael@0: } michael@0: michael@0: function sc_Pair(car, cdr) { michael@0: this.car = car; michael@0: this.cdr = cdr; michael@0: } michael@0: michael@0: sc_Pair.prototype.toString = function() { michael@0: return sc_toDisplayString(this); michael@0: }; michael@0: sc_Pair.prototype.sc_toWriteOrDisplayString = function(writeOrDisplay) { michael@0: var current = this; michael@0: michael@0: var res = "("; michael@0: michael@0: while(true) { michael@0: res += writeOrDisplay(current.car); michael@0: if (sc_isPair(current.cdr)) { michael@0: res += " "; michael@0: current = current.cdr; michael@0: } else if (current.cdr !== null) { michael@0: res += " . " + writeOrDisplay(current.cdr); michael@0: break; michael@0: } else // current.cdr == null michael@0: break; michael@0: } michael@0: michael@0: res += ")"; michael@0: michael@0: return res; michael@0: }; michael@0: sc_Pair.prototype.sc_toDisplayString = function() { michael@0: return this.sc_toWriteOrDisplayString(sc_toDisplayString); michael@0: }; michael@0: sc_Pair.prototype.sc_toWriteString = function() { michael@0: return this.sc_toWriteOrDisplayString(sc_toWriteString); michael@0: }; michael@0: // sc_Pair.prototype.sc_toWriteCircleString in IO.js michael@0: michael@0: /*** META ((export #t) michael@0: (type bool) michael@0: (peephole (postfix " instanceof sc_Pair"))) michael@0: */ michael@0: function sc_isPair(p) { michael@0: return (p instanceof sc_Pair); michael@0: } michael@0: michael@0: function sc_isPairEqual(p1, p2, comp) { michael@0: return (comp(p1.car, p2.car) && comp(p1.cdr, p2.cdr)); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (hole 2 "new sc_Pair(" car ", " cdr ")"))) michael@0: */ michael@0: function sc_cons(car, cdr) { michael@0: return new sc_Pair(car, cdr); michael@0: } michael@0: michael@0: /*** META ((export cons*)) */ michael@0: function sc_consStar() { michael@0: var res = arguments[arguments.length - 1]; michael@0: for (var i = arguments.length-2; i >= 0; i--) michael@0: res = new sc_Pair(arguments[i], res); michael@0: return res; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".car"))) michael@0: */ michael@0: function sc_car(p) { michael@0: return p.car; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".cdr"))) michael@0: */ michael@0: function sc_cdr(p) { michael@0: return p.cdr; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (hole 2 p ".car = " val))) michael@0: */ michael@0: function sc_setCarBang(p, val) { michael@0: p.car = val; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (hole 2 p ".cdr = " val))) michael@0: */ michael@0: function sc_setCdrBang(p, val) { michael@0: p.cdr = val; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".car.car"))) michael@0: */ michael@0: function sc_caar(p) { return p.car.car; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".cdr.car"))) michael@0: */ michael@0: function sc_cadr(p) { return p.cdr.car; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".car.cdr"))) michael@0: */ michael@0: function sc_cdar(p) { return p.car.cdr; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".cdr.cdr"))) michael@0: */ michael@0: function sc_cddr(p) { return p.cdr.cdr; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".car.car.car"))) michael@0: */ michael@0: function sc_caaar(p) { return p.car.car.car; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".car.cdr.car"))) michael@0: */ michael@0: function sc_cadar(p) { return p.car.cdr.car; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".cdr.car.car"))) michael@0: */ michael@0: function sc_caadr(p) { return p.cdr.car.car; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".cdr.cdr.car"))) michael@0: */ michael@0: function sc_caddr(p) { return p.cdr.cdr.car; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".car.car.cdr"))) michael@0: */ michael@0: function sc_cdaar(p) { return p.car.car.cdr; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".cdr.car.cdr"))) michael@0: */ michael@0: function sc_cdadr(p) { return p.cdr.car.cdr; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".car.cdr.cdr"))) michael@0: */ michael@0: function sc_cddar(p) { return p.car.cdr.cdr; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".cdr.cdr.cdr"))) michael@0: */ michael@0: function sc_cdddr(p) { return p.cdr.cdr.cdr; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".car.car.car.car"))) michael@0: */ michael@0: function sc_caaaar(p) { return p.car.car.car.car; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".car.cdr.car.car"))) michael@0: */ michael@0: function sc_caadar(p) { return p.car.cdr.car.car; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".cdr.car.car.car"))) michael@0: */ michael@0: function sc_caaadr(p) { return p.cdr.car.car.car; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".cdr.cdr.car.car"))) michael@0: */ michael@0: function sc_caaddr(p) { return p.cdr.cdr.car.car; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".car.car.car.cdr"))) michael@0: */ michael@0: function sc_cdaaar(p) { return p.car.car.car.cdr; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".car.cdr.car.cdr"))) michael@0: */ michael@0: function sc_cdadar(p) { return p.car.cdr.car.cdr; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".cdr.car.car.cdr"))) michael@0: */ michael@0: function sc_cdaadr(p) { return p.cdr.car.car.cdr; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".cdr.cdr.car.cdr"))) michael@0: */ michael@0: function sc_cdaddr(p) { return p.cdr.cdr.car.cdr; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".car.car.cdr.car"))) michael@0: */ michael@0: function sc_cadaar(p) { return p.car.car.cdr.car; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".car.cdr.cdr.car"))) michael@0: */ michael@0: function sc_caddar(p) { return p.car.cdr.cdr.car; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".cdr.car.cdr.car"))) michael@0: */ michael@0: function sc_cadadr(p) { return p.cdr.car.cdr.car; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".cdr.cdr.cdr.car"))) michael@0: */ michael@0: function sc_cadddr(p) { return p.cdr.cdr.cdr.car; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".car.car.cdr.cdr"))) michael@0: */ michael@0: function sc_cddaar(p) { return p.car.car.cdr.cdr; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".car.cdr.cdr.cdr"))) michael@0: */ michael@0: function sc_cdddar(p) { return p.car.cdr.cdr.cdr; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".cdr.car.cdr.cdr"))) michael@0: */ michael@0: function sc_cddadr(p) { return p.cdr.car.cdr.cdr; } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".cdr.cdr.cdr.cdr"))) michael@0: */ michael@0: function sc_cddddr(p) { return p.cdr.cdr.cdr.cdr; } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_lastPair(l) { michael@0: if (!sc_isPair(l)) sc_error("sc_lastPair: pair expected"); michael@0: var res = l; michael@0: var cdr = l.cdr; michael@0: while (sc_isPair(cdr)) { michael@0: res = cdr; michael@0: cdr = res.cdr; michael@0: } michael@0: return res; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool) michael@0: (peephole (postfix " === null"))) michael@0: */ michael@0: function sc_isNull(o) { michael@0: return (o === null); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool)) michael@0: */ michael@0: function sc_isList(o) { michael@0: var rabbit; michael@0: var turtle; michael@0: michael@0: var rabbit = o; michael@0: var turtle = o; michael@0: while (true) { michael@0: if (rabbit === null || michael@0: (rabbit instanceof sc_Pair && rabbit.cdr === null)) michael@0: return true; // end of list michael@0: else if ((rabbit instanceof sc_Pair) && michael@0: (rabbit.cdr instanceof sc_Pair)) { michael@0: rabbit = rabbit.cdr.cdr; michael@0: turtle = turtle.cdr; michael@0: if (rabbit === turtle) return false; // cycle michael@0: } else michael@0: return false; // not pair michael@0: } michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_list() { michael@0: var res = null; michael@0: var a = arguments; michael@0: for (var i = a.length-1; i >= 0; i--) michael@0: res = new sc_Pair(a[i], res); michael@0: return res; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_iota(num, init) { michael@0: var res = null; michael@0: if (!init) init = 0; michael@0: for (var i = num - 1; i >= 0; i--) michael@0: res = new sc_Pair(i + init, res); michael@0: return res; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_makeList(nbEls, fill) { michael@0: var res = null; michael@0: for (var i = 0; i < nbEls; i++) michael@0: res = new sc_Pair(fill, res); michael@0: return res; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_length(l) { michael@0: var res = 0; michael@0: while (l !== null) { michael@0: res++; michael@0: l = l.cdr; michael@0: } michael@0: return res; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_remq(o, l) { michael@0: var dummy = { cdr : null }; michael@0: var tail = dummy; michael@0: while (l !== null) { michael@0: if (l.car !== o) { michael@0: tail.cdr = sc_cons(l.car, null); michael@0: tail = tail.cdr; michael@0: } michael@0: l = l.cdr; michael@0: } michael@0: return dummy.cdr; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_remqBang(o, l) { michael@0: var dummy = { cdr : null }; michael@0: var tail = dummy; michael@0: var needsAssig = true; michael@0: while (l !== null) { michael@0: if (l.car === o) { michael@0: needsAssig = true; michael@0: } else { michael@0: if (needsAssig) { michael@0: tail.cdr = l; michael@0: needsAssig = false; michael@0: } michael@0: tail = l; michael@0: } michael@0: l = l.cdr; michael@0: } michael@0: tail.cdr = null; michael@0: return dummy.cdr; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_delete(o, l) { michael@0: var dummy = { cdr : null }; michael@0: var tail = dummy; michael@0: while (l !== null) { michael@0: if (!sc_isEqual(l.car, o)) { michael@0: tail.cdr = sc_cons(l.car, null); michael@0: tail = tail.cdr; michael@0: } michael@0: l = l.cdr; michael@0: } michael@0: return dummy.cdr; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_deleteBang(o, l) { michael@0: var dummy = { cdr : null }; michael@0: var tail = dummy; michael@0: var needsAssig = true; michael@0: while (l !== null) { michael@0: if (sc_isEqual(l.car, o)) { michael@0: needsAssig = true; michael@0: } else { michael@0: if (needsAssig) { michael@0: tail.cdr = l; michael@0: needsAssig = false; michael@0: } michael@0: tail = l; michael@0: } michael@0: l = l.cdr; michael@0: } michael@0: tail.cdr = null; michael@0: return dummy.cdr; michael@0: } michael@0: michael@0: function sc_reverseAppendBang(l1, l2) { michael@0: var res = l2; michael@0: while (l1 !== null) { michael@0: var tmp = res; michael@0: res = l1; michael@0: l1 = l1.cdr; michael@0: res.cdr = tmp; michael@0: } michael@0: return res; michael@0: } michael@0: michael@0: function sc_dualAppend(l1, l2) { michael@0: if (l1 === null) return l2; michael@0: if (l2 === null) return l1; michael@0: var rev = sc_reverse(l1); michael@0: return sc_reverseAppendBang(rev, l2); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_append() { michael@0: if (arguments.length === 0) michael@0: return null; michael@0: var res = arguments[arguments.length - 1]; michael@0: for (var i = arguments.length - 2; i >= 0; i--) michael@0: res = sc_dualAppend(arguments[i], res); michael@0: return res; michael@0: } michael@0: michael@0: function sc_dualAppendBang(l1, l2) { michael@0: if (l1 === null) return l2; michael@0: if (l2 === null) return l1; michael@0: var tmp = l1; michael@0: while (tmp.cdr !== null) tmp=tmp.cdr; michael@0: tmp.cdr = l2; michael@0: return l1; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_appendBang() { michael@0: var res = null; michael@0: for (var i = 0; i < arguments.length; i++) michael@0: res = sc_dualAppendBang(res, arguments[i]); michael@0: return res; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_reverse(l1) { michael@0: var res = null; michael@0: while (l1 !== null) { michael@0: res = sc_cons(l1.car, res); michael@0: l1 = l1.cdr; michael@0: } michael@0: return res; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_reverseBang(l) { michael@0: return sc_reverseAppendBang(l, null); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_listTail(l, k) { michael@0: var res = l; michael@0: for (var i = 0; i < k; i++) { michael@0: res = res.cdr; michael@0: } michael@0: return res; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_listRef(l, k) { michael@0: return sc_listTail(l, k).car; michael@0: } michael@0: michael@0: /* // unoptimized generic versions michael@0: function sc_memX(o, l, comp) { michael@0: while (l != null) { michael@0: if (comp(l.car, o)) michael@0: return l; michael@0: l = l.cdr; michael@0: } michael@0: return false; michael@0: } michael@0: function sc_memq(o, l) { return sc_memX(o, l, sc_isEq); } michael@0: function sc_memv(o, l) { return sc_memX(o, l, sc_isEqv); } michael@0: function sc_member(o, l) { return sc_memX(o, l, sc_isEqual); } michael@0: */ michael@0: michael@0: /* optimized versions */ michael@0: /*** META ((export #t)) */ michael@0: function sc_memq(o, l) { michael@0: while (l !== null) { michael@0: if (l.car === o) michael@0: return l; michael@0: l = l.cdr; michael@0: } michael@0: return false; michael@0: } michael@0: /*** META ((export #t)) */ michael@0: function sc_memv(o, l) { michael@0: while (l !== null) { michael@0: if (l.car === o) michael@0: return l; michael@0: l = l.cdr; michael@0: } michael@0: return false; michael@0: } michael@0: /*** META ((export #t)) */ michael@0: function sc_member(o, l) { michael@0: while (l !== null) { michael@0: if (sc_isEqual(l.car,o)) michael@0: return l; michael@0: l = l.cdr; michael@0: } michael@0: return false; michael@0: } michael@0: michael@0: /* // generic unoptimized versions michael@0: function sc_assX(o, al, comp) { michael@0: while (al != null) { michael@0: if (comp(al.car.car, o)) michael@0: return al.car; michael@0: al = al.cdr; michael@0: } michael@0: return false; michael@0: } michael@0: function sc_assq(o, al) { return sc_assX(o, al, sc_isEq); } michael@0: function sc_assv(o, al) { return sc_assX(o, al, sc_isEqv); } michael@0: function sc_assoc(o, al) { return sc_assX(o, al, sc_isEqual); } michael@0: */ michael@0: // optimized versions michael@0: /*** META ((export #t)) */ michael@0: function sc_assq(o, al) { michael@0: while (al !== null) { michael@0: if (al.car.car === o) michael@0: return al.car; michael@0: al = al.cdr; michael@0: } michael@0: return false; michael@0: } michael@0: /*** META ((export #t)) */ michael@0: function sc_assv(o, al) { michael@0: while (al !== null) { michael@0: if (al.car.car === o) michael@0: return al.car; michael@0: al = al.cdr; michael@0: } michael@0: return false; michael@0: } michael@0: /*** META ((export #t)) */ michael@0: function sc_assoc(o, al) { michael@0: while (al !== null) { michael@0: if (sc_isEqual(al.car.car, o)) michael@0: return al.car; michael@0: al = al.cdr; michael@0: } michael@0: return false; michael@0: } michael@0: michael@0: /* can be used for mutable strings and characters */ michael@0: function sc_isCharStringEqual(cs1, cs2) { return cs1.val === cs2.val; } michael@0: function sc_isCharStringLess(cs1, cs2) { return cs1.val < cs2.val; } michael@0: function sc_isCharStringGreater(cs1, cs2) { return cs1.val > cs2.val; } michael@0: function sc_isCharStringLessEqual(cs1, cs2) { return cs1.val <= cs2.val; } michael@0: function sc_isCharStringGreaterEqual(cs1, cs2) { return cs1.val >= cs2.val; } michael@0: function sc_isCharStringCIEqual(cs1, cs2) michael@0: { return cs1.val.toLowerCase() === cs2.val.toLowerCase(); } michael@0: function sc_isCharStringCILess(cs1, cs2) michael@0: { return cs1.val.toLowerCase() < cs2.val.toLowerCase(); } michael@0: function sc_isCharStringCIGreater(cs1, cs2) michael@0: { return cs1.val.toLowerCase() > cs2.val.toLowerCase(); } michael@0: function sc_isCharStringCILessEqual(cs1, cs2) michael@0: { return cs1.val.toLowerCase() <= cs2.val.toLowerCase(); } michael@0: function sc_isCharStringCIGreaterEqual(cs1, cs2) michael@0: { return cs1.val.toLowerCase() >= cs2.val.toLowerCase(); } michael@0: michael@0: michael@0: michael@0: michael@0: function sc_Char(c) { michael@0: var cached = sc_Char.lazy[c]; michael@0: if (cached) michael@0: return cached; michael@0: this.val = c; michael@0: sc_Char.lazy[c] = this; michael@0: // add return, so FF does not complain. michael@0: return undefined; michael@0: } michael@0: sc_Char.lazy = new Object(); michael@0: // thanks to Eric michael@0: sc_Char.char2readable = { michael@0: "\000": "#\\null", michael@0: "\007": "#\\bell", michael@0: "\010": "#\\backspace", michael@0: "\011": "#\\tab", michael@0: "\012": "#\\newline", michael@0: "\014": "#\\page", michael@0: "\015": "#\\return", michael@0: "\033": "#\\escape", michael@0: "\040": "#\\space", michael@0: "\177": "#\\delete", michael@0: michael@0: /* poeticless names */ michael@0: "\001": "#\\soh", michael@0: "\002": "#\\stx", michael@0: "\003": "#\\etx", michael@0: "\004": "#\\eot", michael@0: "\005": "#\\enq", michael@0: "\006": "#\\ack", michael@0: michael@0: "\013": "#\\vt", michael@0: "\016": "#\\so", michael@0: "\017": "#\\si", michael@0: michael@0: "\020": "#\\dle", michael@0: "\021": "#\\dc1", michael@0: "\022": "#\\dc2", michael@0: "\023": "#\\dc3", michael@0: "\024": "#\\dc4", michael@0: "\025": "#\\nak", michael@0: "\026": "#\\syn", michael@0: "\027": "#\\etb", michael@0: michael@0: "\030": "#\\can", michael@0: "\031": "#\\em", michael@0: "\032": "#\\sub", michael@0: "\033": "#\\esc", michael@0: "\034": "#\\fs", michael@0: "\035": "#\\gs", michael@0: "\036": "#\\rs", michael@0: "\037": "#\\us"}; michael@0: michael@0: sc_Char.readable2char = { michael@0: "null": "\000", michael@0: "bell": "\007", michael@0: "backspace": "\010", michael@0: "tab": "\011", michael@0: "newline": "\012", michael@0: "page": "\014", michael@0: "return": "\015", michael@0: "escape": "\033", michael@0: "space": "\040", michael@0: "delete": "\000", michael@0: "soh": "\001", michael@0: "stx": "\002", michael@0: "etx": "\003", michael@0: "eot": "\004", michael@0: "enq": "\005", michael@0: "ack": "\006", michael@0: "bel": "\007", michael@0: "bs": "\010", michael@0: "ht": "\011", michael@0: "nl": "\012", michael@0: "vt": "\013", michael@0: "np": "\014", michael@0: "cr": "\015", michael@0: "so": "\016", michael@0: "si": "\017", michael@0: "dle": "\020", michael@0: "dc1": "\021", michael@0: "dc2": "\022", michael@0: "dc3": "\023", michael@0: "dc4": "\024", michael@0: "nak": "\025", michael@0: "syn": "\026", michael@0: "etb": "\027", michael@0: "can": "\030", michael@0: "em": "\031", michael@0: "sub": "\032", michael@0: "esc": "\033", michael@0: "fs": "\034", michael@0: "gs": "\035", michael@0: "rs": "\036", michael@0: "us": "\037", michael@0: "sp": "\040", michael@0: "del": "\177"}; michael@0: michael@0: sc_Char.prototype.toString = function() { michael@0: return this.val; michael@0: }; michael@0: // sc_toDisplayString == toString michael@0: sc_Char.prototype.sc_toWriteString = function() { michael@0: var entry = sc_Char.char2readable[this.val]; michael@0: if (entry) michael@0: return entry; michael@0: else michael@0: return "#\\" + this.val; michael@0: }; michael@0: michael@0: /*** META ((export #t) michael@0: (type bool) michael@0: (peephole (postfix "instanceof sc_Char"))) michael@0: */ michael@0: function sc_isChar(c) { michael@0: return (c instanceof sc_Char); michael@0: } michael@0: michael@0: /*** META ((export char=?) michael@0: (type bool) michael@0: (peephole (hole 2 c1 ".val === " c2 ".val"))) michael@0: */ michael@0: var sc_isCharEqual = sc_isCharStringEqual; michael@0: /*** META ((export char?) michael@0: (type bool) michael@0: (peephole (hole 2 c1 ".val > " c2 ".val"))) michael@0: */ michael@0: var sc_isCharGreater = sc_isCharStringGreater; michael@0: /*** META ((export char<=?) michael@0: (type bool) michael@0: (peephole (hole 2 c1 ".val <= " c2 ".val"))) michael@0: */ michael@0: var sc_isCharLessEqual = sc_isCharStringLessEqual; michael@0: /*** META ((export char>=?) michael@0: (type bool) michael@0: (peephole (hole 2 c1 ".val >= " c2 ".val"))) michael@0: */ michael@0: var sc_isCharGreaterEqual = sc_isCharStringGreaterEqual; michael@0: /*** META ((export char-ci=?) michael@0: (type bool) michael@0: (peephole (hole 2 c1 ".val.toLowerCase() === " c2 ".val.toLowerCase()"))) michael@0: */ michael@0: var sc_isCharCIEqual = sc_isCharStringCIEqual; michael@0: /*** META ((export char-ci?) michael@0: (type bool) michael@0: (peephole (hole 2 c1 ".val.toLowerCase() > " c2 ".val.toLowerCase()"))) michael@0: */ michael@0: var sc_isCharCIGreater = sc_isCharStringCIGreater; michael@0: /*** META ((export char-ci<=?) michael@0: (type bool) michael@0: (peephole (hole 2 c1 ".val.toLowerCase() <= " c2 ".val.toLowerCase()"))) michael@0: */ michael@0: var sc_isCharCILessEqual = sc_isCharStringCILessEqual; michael@0: /*** META ((export char-ci>=?) michael@0: (type bool) michael@0: (peephole (hole 2 c1 ".val.toLowerCase() >= " c2 ".val.toLowerCase()"))) michael@0: */ michael@0: var sc_isCharCIGreaterEqual = sc_isCharStringCIGreaterEqual; michael@0: michael@0: var SC_NUMBER_CLASS = "0123456789"; michael@0: var SC_WHITESPACE_CLASS = ' \r\n\t\f'; michael@0: var SC_LOWER_CLASS = 'abcdefghijklmnopqrstuvwxyz'; michael@0: var SC_UPPER_CLASS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; michael@0: michael@0: function sc_isCharOfClass(c, cl) { return (cl.indexOf(c) != -1); } michael@0: /*** META ((export #t) michael@0: (type bool)) michael@0: */ michael@0: function sc_isCharAlphabetic(c) michael@0: { return sc_isCharOfClass(c.val, SC_LOWER_CLASS) || michael@0: sc_isCharOfClass(c.val, SC_UPPER_CLASS); } michael@0: /*** META ((export #t) michael@0: (type bool) michael@0: (peephole (hole 1 "SC_NUMBER_CLASS.indexOf(" c ".val) != -1"))) michael@0: */ michael@0: function sc_isCharNumeric(c) michael@0: { return sc_isCharOfClass(c.val, SC_NUMBER_CLASS); } michael@0: /*** META ((export #t) michael@0: (type bool)) michael@0: */ michael@0: function sc_isCharWhitespace(c) { michael@0: var tmp = c.val; michael@0: return tmp === " " || tmp === "\r" || tmp === "\n" || tmp === "\t" || tmp === "\f"; michael@0: } michael@0: /*** META ((export #t) michael@0: (type bool) michael@0: (peephole (hole 1 "SC_UPPER_CLASS.indexOf(" c ".val) != -1"))) michael@0: */ michael@0: function sc_isCharUpperCase(c) michael@0: { return sc_isCharOfClass(c.val, SC_UPPER_CLASS); } michael@0: /*** META ((export #t) michael@0: (type bool) michael@0: (peephole (hole 1 "SC_LOWER_CLASS.indexOf(" c ".val) != -1"))) michael@0: */ michael@0: function sc_isCharLowerCase(c) michael@0: { return sc_isCharOfClass(c.val, SC_LOWER_CLASS); } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".val.charCodeAt(0)"))) michael@0: */ michael@0: function sc_char2integer(c) michael@0: { return c.val.charCodeAt(0); } michael@0: /*** META ((export #t) michael@0: (peephole (hole 1 "new sc_Char(String.fromCharCode(" n "))"))) michael@0: */ michael@0: function sc_integer2char(n) michael@0: { return new sc_Char(String.fromCharCode(n)); } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (hole 1 "new sc_Char(" c ".val.toUpperCase())"))) michael@0: */ michael@0: function sc_charUpcase(c) michael@0: { return new sc_Char(c.val.toUpperCase()); } michael@0: /*** META ((export #t) michael@0: (peephole (hole 1 "new sc_Char(" c ".val.toLowerCase())"))) michael@0: */ michael@0: function sc_charDowncase(c) michael@0: { return new sc_Char(c.val.toLowerCase()); } michael@0: michael@0: function sc_makeJSStringOfLength(k, c) { michael@0: var fill; michael@0: if (c === undefined) michael@0: fill = " "; michael@0: else michael@0: fill = c; michael@0: var res = ""; michael@0: var len = 1; michael@0: // every round doubles the size of fill. michael@0: while (k >= len) { michael@0: if (k & len) michael@0: res = res.concat(fill); michael@0: fill = fill.concat(fill); michael@0: len *= 2; michael@0: } michael@0: return res; michael@0: } michael@0: michael@0: function sc_makejsString(k, c) { michael@0: var fill; michael@0: if (c) michael@0: fill = c.val; michael@0: else michael@0: fill = " "; michael@0: return sc_makeJSStringOfLength(k, fill); michael@0: } michael@0: michael@0: function sc_jsstring2list(s) { michael@0: var res = null; michael@0: for (var i = s.length - 1; i >= 0; i--) michael@0: res = sc_cons(new sc_Char(s.charAt(i)), res); michael@0: return res; michael@0: } michael@0: michael@0: function sc_list2jsstring(l) { michael@0: var a = new Array(); michael@0: while(l !== null) { michael@0: a.push(l.car.val); michael@0: l = l.cdr; michael@0: } michael@0: return "".concat.apply("", a); michael@0: } michael@0: michael@0: var sc_Vector = Array; michael@0: michael@0: sc_Vector.prototype.sc_toWriteOrDisplayString = function(writeOrDisplay) { michael@0: if (this.length === 0) return "#()"; michael@0: michael@0: var res = "#(" + writeOrDisplay(this[0]); michael@0: for (var i = 1; i < this.length; i++) michael@0: res += " " + writeOrDisplay(this[i]); michael@0: res += ")"; michael@0: return res; michael@0: }; michael@0: sc_Vector.prototype.sc_toDisplayString = function() { michael@0: return this.sc_toWriteOrDisplayString(sc_toDisplayString); michael@0: }; michael@0: sc_Vector.prototype.sc_toWriteString = function() { michael@0: return this.sc_toWriteOrDisplayString(sc_toWriteString); michael@0: }; michael@0: michael@0: /*** META ((export vector? array?) michael@0: (type bool) michael@0: (peephole (postfix " instanceof sc_Vector"))) michael@0: */ michael@0: function sc_isVector(v) { michael@0: return (v instanceof sc_Vector); michael@0: } michael@0: michael@0: // only applies to vectors michael@0: function sc_isVectorEqual(v1, v2, comp) { michael@0: if (v1.length !== v2.length) return false; michael@0: for (var i = 0; i < v1.length; i++) michael@0: if (!comp(v1[i], v2[i])) return false; michael@0: return true; michael@0: } michael@0: michael@0: /*** META ((export make-vector make-array)) */ michael@0: function sc_makeVector(size, fill) { michael@0: var a = new sc_Vector(size); michael@0: if (fill !== undefined) michael@0: sc_vectorFillBang(a, fill); michael@0: return a; michael@0: } michael@0: michael@0: /*** META ((export vector array) michael@0: (peephole (vector))) michael@0: */ michael@0: function sc_vector() { michael@0: var a = new sc_Vector(); michael@0: for (var i = 0; i < arguments.length; i++) michael@0: a.push(arguments[i]); michael@0: return a; michael@0: } michael@0: michael@0: /*** META ((export vector-length array-length) michael@0: (peephole (postfix ".length"))) michael@0: */ michael@0: function sc_vectorLength(v) { michael@0: return v.length; michael@0: } michael@0: michael@0: /*** META ((export vector-ref array-ref) michael@0: (peephole (hole 2 v "[" pos "]"))) michael@0: */ michael@0: function sc_vectorRef(v, pos) { michael@0: return v[pos]; michael@0: } michael@0: michael@0: /*** META ((export vector-set! array-set!) michael@0: (peephole (hole 3 v "[" pos "] = " val))) michael@0: */ michael@0: function sc_vectorSetBang(v, pos, val) { michael@0: v[pos] = val; michael@0: } michael@0: michael@0: /*** META ((export vector->list array->list)) */ michael@0: function sc_vector2list(a) { michael@0: var res = null; michael@0: for (var i = a.length-1; i >= 0; i--) michael@0: res = sc_cons(a[i], res); michael@0: return res; michael@0: } michael@0: michael@0: /*** META ((export list->vector list->array)) */ michael@0: function sc_list2vector(l) { michael@0: var a = new sc_Vector(); michael@0: while(l !== null) { michael@0: a.push(l.car); michael@0: l = l.cdr; michael@0: } michael@0: return a; michael@0: } michael@0: michael@0: /*** META ((export vector-fill! array-fill!)) */ michael@0: function sc_vectorFillBang(a, fill) { michael@0: for (var i = 0; i < a.length; i++) michael@0: a[i] = fill; michael@0: } michael@0: michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_copyVector(a, len) { michael@0: if (len <= a.length) michael@0: return a.slice(0, len); michael@0: else { michael@0: var tmp = a.concat(); michael@0: tmp.length = len; michael@0: return tmp; michael@0: } michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (hole 3 a ".slice(" start "," end ")"))) michael@0: */ michael@0: function sc_vectorCopy(a, start, end) { michael@0: return a.slice(start, end); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_vectorCopyBang(target, tstart, source, sstart, send) { michael@0: if (!sstart) sstart = 0; michael@0: if (!send) send = source.length; michael@0: michael@0: // if target == source we don't want to overwrite not yet copied elements. michael@0: if (tstart <= sstart) { michael@0: for (var i = tstart, j = sstart; j < send; i++, j++) { michael@0: target[i] = source[j]; michael@0: } michael@0: } else { michael@0: var diff = send - sstart; michael@0: for (var i = tstart + diff - 1, j = send - 1; michael@0: j >= sstart; michael@0: i--, j--) { michael@0: target[i] = source[j]; michael@0: } michael@0: } michael@0: return target; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool) michael@0: (peephole (hole 1 "typeof " o " === 'function'"))) michael@0: */ michael@0: function sc_isProcedure(o) { michael@0: return (typeof o === "function"); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_apply(proc) { michael@0: var args = new Array(); michael@0: // first part of arguments are not in list-form. michael@0: for (var i = 1; i < arguments.length - 1; i++) michael@0: args.push(arguments[i]); michael@0: var l = arguments[arguments.length - 1]; michael@0: while (l !== null) { michael@0: args.push(l.car); michael@0: l = l.cdr; michael@0: } michael@0: return proc.apply(null, args); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_map(proc, l1) { michael@0: if (l1 === undefined) michael@0: return null; michael@0: // else michael@0: var nbApplyArgs = arguments.length - 1; michael@0: var applyArgs = new Array(nbApplyArgs); michael@0: var revres = null; michael@0: while (l1 !== null) { michael@0: for (var i = 0; i < nbApplyArgs; i++) { michael@0: applyArgs[i] = arguments[i + 1].car; michael@0: arguments[i + 1] = arguments[i + 1].cdr; michael@0: } michael@0: revres = sc_cons(proc.apply(null, applyArgs), revres); michael@0: } michael@0: return sc_reverseAppendBang(revres, null); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_mapBang(proc, l1) { michael@0: if (l1 === undefined) michael@0: return null; michael@0: // else michael@0: var l1_orig = l1; michael@0: var nbApplyArgs = arguments.length - 1; michael@0: var applyArgs = new Array(nbApplyArgs); michael@0: while (l1 !== null) { michael@0: var tmp = l1; michael@0: for (var i = 0; i < nbApplyArgs; i++) { michael@0: applyArgs[i] = arguments[i + 1].car; michael@0: arguments[i + 1] = arguments[i + 1].cdr; michael@0: } michael@0: tmp.car = proc.apply(null, applyArgs); michael@0: } michael@0: return l1_orig; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_forEach(proc, l1) { michael@0: if (l1 === undefined) michael@0: return undefined; michael@0: // else michael@0: var nbApplyArgs = arguments.length - 1; michael@0: var applyArgs = new Array(nbApplyArgs); michael@0: while (l1 !== null) { michael@0: for (var i = 0; i < nbApplyArgs; i++) { michael@0: applyArgs[i] = arguments[i + 1].car; michael@0: arguments[i + 1] = arguments[i + 1].cdr; michael@0: } michael@0: proc.apply(null, applyArgs); michael@0: } michael@0: // add return so FF does not complain. michael@0: return undefined; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_filter(proc, l1) { michael@0: var dummy = { cdr : null }; michael@0: var tail = dummy; michael@0: while (l1 !== null) { michael@0: if (proc(l1.car) !== false) { michael@0: tail.cdr = sc_cons(l1.car, null); michael@0: tail = tail.cdr; michael@0: } michael@0: l1 = l1.cdr; michael@0: } michael@0: return dummy.cdr; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_filterBang(proc, l1) { michael@0: var head = sc_cons("dummy", l1); michael@0: var it = head; michael@0: var next = l1; michael@0: while (next !== null) { michael@0: if (proc(next.car) !== false) { michael@0: it.cdr = next michael@0: it = next; michael@0: } michael@0: next = next.cdr; michael@0: } michael@0: it.cdr = null; michael@0: return head.cdr; michael@0: } michael@0: michael@0: function sc_filterMap1(proc, l1) { michael@0: var revres = null; michael@0: while (l1 !== null) { michael@0: var tmp = proc(l1.car) michael@0: if (tmp !== false) revres = sc_cons(tmp, revres); michael@0: l1 = l1.cdr; michael@0: } michael@0: return sc_reverseAppendBang(revres, null); michael@0: } michael@0: function sc_filterMap2(proc, l1, l2) { michael@0: var revres = null; michael@0: while (l1 !== null) { michael@0: var tmp = proc(l1.car, l2.car); michael@0: if(tmp !== false) revres = sc_cons(tmp, revres); michael@0: l1 = l1.cdr; michael@0: l2 = l2.cdr michael@0: } michael@0: return sc_reverseAppendBang(revres, null); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_filterMap(proc, l1, l2, l3) { michael@0: if (l2 === undefined) michael@0: return sc_filterMap1(proc, l1); michael@0: else if (l3 === undefined) michael@0: return sc_filterMap2(proc, l1, l2); michael@0: // else michael@0: var nbApplyArgs = arguments.length - 1; michael@0: var applyArgs = new Array(nbApplyArgs); michael@0: var revres = null; michael@0: while (l1 !== null) { michael@0: for (var i = 0; i < nbApplyArgs; i++) { michael@0: applyArgs[i] = arguments[i + 1].car; michael@0: arguments[i + 1] = arguments[i + 1].cdr; michael@0: } michael@0: var tmp = proc.apply(null, applyArgs); michael@0: if(tmp !== false) revres = sc_cons(tmp, revres); michael@0: } michael@0: return sc_reverseAppendBang(revres, null); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_any(proc, l) { michael@0: var revres = null; michael@0: while (l !== null) { michael@0: var tmp = proc(l.car); michael@0: if(tmp !== false) return tmp; michael@0: l = l.cdr; michael@0: } michael@0: return false; michael@0: } michael@0: michael@0: /*** META ((export any?) michael@0: (peephole (hole 2 "sc_any(" proc "," l ") !== false"))) michael@0: */ michael@0: function sc_anyPred(proc, l) { michael@0: return sc_any(proc, l)!== false; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_every(proc, l) { michael@0: var revres = null; michael@0: var tmp = true; michael@0: while (l !== null) { michael@0: tmp = proc(l.car); michael@0: if (tmp === false) return false; michael@0: l = l.cdr; michael@0: } michael@0: return tmp; michael@0: } michael@0: michael@0: /*** META ((export every?) michael@0: (peephole (hole 2 "sc_every(" proc "," l ") !== false"))) michael@0: */ michael@0: function sc_everyPred(proc, l) { michael@0: var tmp = sc_every(proc, l); michael@0: if (tmp !== false) return true; michael@0: return false; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (postfix "()"))) michael@0: */ michael@0: function sc_force(o) { michael@0: return o(); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_makePromise(proc) { michael@0: var isResultReady = false; michael@0: var result = undefined; michael@0: return function() { michael@0: if (!isResultReady) { michael@0: var tmp = proc(); michael@0: if (!isResultReady) { michael@0: isResultReady = true; michael@0: result = tmp; michael@0: } michael@0: } michael@0: return result; michael@0: }; michael@0: } michael@0: michael@0: function sc_Values(values) { michael@0: this.values = values; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (values))) michael@0: */ michael@0: function sc_values() { michael@0: if (arguments.length === 1) michael@0: return arguments[0]; michael@0: else michael@0: return new sc_Values(arguments); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_callWithValues(producer, consumer) { michael@0: var produced = producer(); michael@0: if (produced instanceof sc_Values) michael@0: return consumer.apply(null, produced.values); michael@0: else michael@0: return consumer(produced); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_dynamicWind(before, thunk, after) { michael@0: before(); michael@0: try { michael@0: var res = thunk(); michael@0: return res; michael@0: } finally { michael@0: after(); michael@0: } michael@0: } michael@0: michael@0: michael@0: // TODO: eval/scheme-report-environment/null-environment/interaction-environment michael@0: michael@0: // LIMITATION: 'load' doesn't exist without files. michael@0: // LIMITATION: transcript-on/transcript-off doesn't exist without files. michael@0: michael@0: michael@0: function sc_Struct(name) { michael@0: this.name = name; michael@0: } michael@0: sc_Struct.prototype.sc_toDisplayString = function() { michael@0: return "#"; michael@0: }; michael@0: sc_Struct.prototype.sc_toWriteString = sc_Struct.prototype.sc_toDisplayString; michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (hole 1 "new sc_Struct(" name ")"))) michael@0: */ michael@0: function sc_makeStruct(name) { michael@0: return new sc_Struct(name); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool) michael@0: (peephole (postfix " instanceof sc_Struct"))) michael@0: */ michael@0: function sc_isStruct(o) { michael@0: return (o instanceof sc_Struct); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool) michael@0: (peephole (hole 2 "(" 1 " instanceof sc_Struct) && ( " 1 ".name === " 0 ")"))) michael@0: */ michael@0: function sc_isStructNamed(name, s) { michael@0: return ((s instanceof sc_Struct) && (s.name === name)); michael@0: } michael@0: michael@0: /*** META ((export struct-field) michael@0: (peephole (hole 3 0 "[" 2 "]"))) michael@0: */ michael@0: function sc_getStructField(s, name, field) { michael@0: return s[field]; michael@0: } michael@0: michael@0: /*** META ((export struct-field-set!) michael@0: (peephole (hole 4 0 "[" 2 "] = " 3))) michael@0: */ michael@0: function sc_setStructFieldBang(s, name, field, val) { michael@0: s[field] = val; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (prefix "~"))) michael@0: */ michael@0: function sc_bitNot(x) { michael@0: return ~x; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (infix 2 2 "&"))) michael@0: */ michael@0: function sc_bitAnd(x, y) { michael@0: return x & y; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (infix 2 2 "|"))) michael@0: */ michael@0: function sc_bitOr(x, y) { michael@0: return x | y; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (infix 2 2 "^"))) michael@0: */ michael@0: function sc_bitXor(x, y) { michael@0: return x ^ y; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (infix 2 2 "<<"))) michael@0: */ michael@0: function sc_bitLsh(x, y) { michael@0: return x << y; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (infix 2 2 ">>"))) michael@0: */ michael@0: function sc_bitRsh(x, y) { michael@0: return x >> y; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (infix 2 2 ">>>"))) michael@0: */ michael@0: function sc_bitUrsh(x, y) { michael@0: return x >>> y; michael@0: } michael@0: michael@0: /*** META ((export js-field js-property) michael@0: (peephole (hole 2 o "[" field "]"))) michael@0: */ michael@0: function sc_jsField(o, field) { michael@0: return o[field]; michael@0: } michael@0: michael@0: /*** META ((export js-field-set! js-property-set!) michael@0: (peephole (hole 3 o "[" field "] = " val))) michael@0: */ michael@0: function sc_setJsFieldBang(o, field, val) { michael@0: return o[field] = val; michael@0: } michael@0: michael@0: /*** META ((export js-field-delete! js-property-delete!) michael@0: (peephole (hole 2 "delete" o "[" field "]"))) michael@0: */ michael@0: function sc_deleteJsFieldBang(o, field) { michael@0: delete o[field]; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (jsCall))) michael@0: */ michael@0: function sc_jsCall(o, fun) { michael@0: var args = new Array(); michael@0: for (var i = 2; i < arguments.length; i++) michael@0: args[i-2] = arguments[i]; michael@0: return fun.apply(o, args); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (jsMethodCall))) michael@0: */ michael@0: function sc_jsMethodCall(o, field) { michael@0: var args = new Array(); michael@0: for (var i = 2; i < arguments.length; i++) michael@0: args[i-2] = arguments[i]; michael@0: return o[field].apply(o, args); michael@0: } michael@0: michael@0: /*** META ((export new js-new) michael@0: (peephole (jsNew))) michael@0: */ michael@0: function sc_jsNew(c) { michael@0: var evalStr = "new c("; michael@0: evalStr +=arguments.length > 1? "arguments[1]": ""; michael@0: for (var i = 2; i < arguments.length; i++) michael@0: evalStr += ", arguments[" + i + "]"; michael@0: evalStr +=")"; michael@0: return eval(evalStr); michael@0: } michael@0: michael@0: // ======================== RegExp ==================== michael@0: /*** META ((export #t)) */ michael@0: function sc_pregexp(re) { michael@0: return new RegExp(sc_string2jsstring(re)); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_pregexpMatch(re, s) { michael@0: var reg = (re instanceof RegExp) ? re : sc_pregexp(re); michael@0: var tmp = reg.exec(sc_string2jsstring(s)); michael@0: michael@0: if (tmp == null) return false; michael@0: michael@0: var res = null; michael@0: for (var i = tmp.length-1; i >= 0; i--) { michael@0: if (tmp[i] !== null) { michael@0: res = sc_cons(sc_jsstring2string(tmp[i]), res); michael@0: } else { michael@0: res = sc_cons(false, res); michael@0: } michael@0: } michael@0: return res; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_pregexpReplace(re, s1, s2) { michael@0: var reg; michael@0: var jss1 = sc_string2jsstring(s1); michael@0: var jss2 = sc_string2jsstring(s2); michael@0: michael@0: if (re instanceof RegExp) { michael@0: if (re.global) michael@0: reg = re; michael@0: else michael@0: reg = new RegExp(re.source); michael@0: } else { michael@0: reg = new RegExp(sc_string2jsstring(re)); michael@0: } michael@0: michael@0: return jss1.replace(reg, jss2); michael@0: } michael@0: michael@0: /*** META ((export pregexp-replace*)) */ michael@0: function sc_pregexpReplaceAll(re, s1, s2) { michael@0: var reg; michael@0: var jss1 = sc_string2jsstring(s1); michael@0: var jss2 = sc_string2jsstring(s2); michael@0: michael@0: if (re instanceof RegExp) { michael@0: if (re.global) michael@0: reg = re; michael@0: else michael@0: reg = new RegExp(re.source, "g"); michael@0: } else { michael@0: reg = new RegExp(sc_string2jsstring(re), "g"); michael@0: } michael@0: michael@0: return jss1.replace(reg, jss2); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_pregexpSplit(re, s) { michael@0: var reg = ((re instanceof RegExp) ? michael@0: re : michael@0: new RegExp(sc_string2jsstring(re))); michael@0: var jss = sc_string2jsstring(s); michael@0: var tmp = jss.split(reg); michael@0: michael@0: if (tmp == null) return false; michael@0: michael@0: return sc_vector2list(tmp); michael@0: } michael@0: michael@0: michael@0: /* =========================================================================== */ michael@0: /* Other library stuff */ michael@0: /* =========================================================================== */ michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (hole 1 "Math.floor(Math.random()*" 'n ")"))) michael@0: */ michael@0: function sc_random(n) { michael@0: return Math.floor(Math.random()*n); michael@0: } michael@0: michael@0: /*** META ((export current-date) michael@0: (peephole (hole 0 "new Date()"))) michael@0: */ michael@0: function sc_currentDate() { michael@0: return new Date(); michael@0: } michael@0: michael@0: function sc_Hashtable() { michael@0: } michael@0: sc_Hashtable.prototype.toString = function() { michael@0: return "#{%hashtable}"; michael@0: }; michael@0: // sc_toWriteString == sc_toDisplayString == toString michael@0: michael@0: function sc_HashtableElement(key, val) { michael@0: this.key = key; michael@0: this.val = val; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (hole 0 "new sc_Hashtable()"))) michael@0: */ michael@0: function sc_makeHashtable() { michael@0: return new sc_Hashtable(); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_hashtablePutBang(ht, key, val) { michael@0: var hash = sc_hash(key); michael@0: ht[hash] = new sc_HashtableElement(key, val); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_hashtableGet(ht, key) { michael@0: var hash = sc_hash(key); michael@0: if (hash in ht) michael@0: return ht[hash].val; michael@0: else michael@0: return false; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_hashtableForEach(ht, f) { michael@0: for (var v in ht) { michael@0: if (ht[v] instanceof sc_HashtableElement) michael@0: f(ht[v].key, ht[v].val); michael@0: } michael@0: } michael@0: michael@0: /*** META ((export hashtable-contains?) michael@0: (peephole (hole 2 "sc_hash(" 1 ") in " 0))) michael@0: */ michael@0: function sc_hashtableContains(ht, key) { michael@0: var hash = sc_hash(key); michael@0: if (hash in ht) michael@0: return true; michael@0: else michael@0: return false; michael@0: } michael@0: michael@0: var SC_HASH_COUNTER = 0; michael@0: michael@0: function sc_hash(o) { michael@0: if (o === null) michael@0: return "null"; michael@0: else if (o === undefined) michael@0: return "undefined"; michael@0: else if (o === true) michael@0: return "true"; michael@0: else if (o === false) michael@0: return "false"; michael@0: else if (typeof o === "number") michael@0: return "num-" + o; michael@0: else if (typeof o === "string") michael@0: return "jsstr-" + o; michael@0: else if (o.sc_getHash) michael@0: return o.sc_getHash(); michael@0: else michael@0: return sc_counterHash.call(o); michael@0: } michael@0: function sc_counterHash() { michael@0: if (!this.sc_hash) { michael@0: this.sc_hash = "hash-" + SC_HASH_COUNTER; michael@0: SC_HASH_COUNTER++; michael@0: } michael@0: return this.sc_hash; michael@0: } michael@0: michael@0: function sc_Trampoline(args, maxTailCalls) { michael@0: this['__trampoline return__'] = true; michael@0: this.args = args; michael@0: this.MAX_TAIL_CALLs = maxTailCalls; michael@0: } michael@0: // TODO: call/cc stuff michael@0: sc_Trampoline.prototype.restart = function() { michael@0: var o = this; michael@0: while (true) { michael@0: // set both globals. michael@0: SC_TAIL_OBJECT.calls = o.MAX_TAIL_CALLs-1; michael@0: var fun = o.args.callee; michael@0: var res = fun.apply(SC_TAIL_OBJECT, o.args); michael@0: if (res instanceof sc_Trampoline) michael@0: o = res; michael@0: else michael@0: return res; michael@0: } michael@0: } michael@0: michael@0: /*** META ((export bind-exit-lambda)) */ michael@0: function sc_bindExitLambda(proc) { michael@0: var escape_obj = new sc_BindExitException(); michael@0: var escape = function(res) { michael@0: escape_obj.res = res; michael@0: throw escape_obj; michael@0: }; michael@0: try { michael@0: return proc(escape); michael@0: } catch(e) { michael@0: if (e === escape_obj) { michael@0: return e.res; michael@0: } michael@0: throw e; michael@0: } michael@0: } michael@0: function sc_BindExitException() { michael@0: this._internalException = true; michael@0: } michael@0: michael@0: var SC_SCM2JS_GLOBALS = new Object(); michael@0: michael@0: // default tail-call depth. michael@0: // normally the program should set it again. but just in case... michael@0: var SC_TAIL_OBJECT = new Object(); michael@0: SC_SCM2JS_GLOBALS.TAIL_OBJECT = SC_TAIL_OBJECT; michael@0: // ======================== I/O ======================= michael@0: michael@0: /*------------------------------------------------------------------*/ michael@0: michael@0: function sc_EOF() { michael@0: } michael@0: var SC_EOF_OBJECT = new sc_EOF(); michael@0: michael@0: function sc_Port() { michael@0: } michael@0: michael@0: /* --------------- Input ports -------------------------------------*/ michael@0: michael@0: function sc_InputPort() { michael@0: } michael@0: sc_InputPort.prototype = new sc_Port(); michael@0: michael@0: sc_InputPort.prototype.peekChar = function() { michael@0: if (!("peeked" in this)) michael@0: this.peeked = this.getNextChar(); michael@0: return this.peeked; michael@0: } michael@0: sc_InputPort.prototype.readChar = function() { michael@0: var tmp = this.peekChar(); michael@0: delete this.peeked; michael@0: return tmp; michael@0: } michael@0: sc_InputPort.prototype.isCharReady = function() { michael@0: return true; michael@0: } michael@0: sc_InputPort.prototype.close = function() { michael@0: // do nothing michael@0: } michael@0: michael@0: /* .............. String port ..........................*/ michael@0: function sc_ErrorInputPort() { michael@0: }; michael@0: sc_ErrorInputPort.prototype = new sc_InputPort(); michael@0: sc_ErrorInputPort.prototype.getNextChar = function() { michael@0: throw "can't read from error-port."; michael@0: }; michael@0: sc_ErrorInputPort.prototype.isCharReady = function() { michael@0: return false; michael@0: }; michael@0: michael@0: michael@0: /* .............. String port ..........................*/ michael@0: michael@0: function sc_StringInputPort(jsStr) { michael@0: // we are going to do some charAts on the str. michael@0: // instead of recreating all the time a String-object, we michael@0: // create one in the beginning. (not sure, if this is really an optim) michael@0: this.str = new String(jsStr); michael@0: this.pos = 0; michael@0: } michael@0: sc_StringInputPort.prototype = new sc_InputPort(); michael@0: sc_StringInputPort.prototype.getNextChar = function() { michael@0: if (this.pos >= this.str.length) michael@0: return SC_EOF_OBJECT; michael@0: return this.str.charAt(this.pos++); michael@0: }; michael@0: michael@0: /* ------------- Read and other lib-funs -------------------------------*/ michael@0: function sc_Token(type, val, pos) { michael@0: this.type = type; michael@0: this.val = val; michael@0: this.pos = pos; michael@0: } michael@0: sc_Token.EOF = 0/*EOF*/; michael@0: sc_Token.OPEN_PAR = 1/*OPEN_PAR*/; michael@0: sc_Token.CLOSE_PAR = 2/*CLOSE_PAR*/; michael@0: sc_Token.OPEN_BRACE = 3/*OPEN_BRACE*/; michael@0: sc_Token.CLOSE_BRACE = 4/*CLOSE_BRACE*/; michael@0: sc_Token.OPEN_BRACKET = 5/*OPEN_BRACKET*/; michael@0: sc_Token.CLOSE_BRACKET = 6/*CLOSE_BRACKET*/; michael@0: sc_Token.WHITESPACE = 7/*WHITESPACE*/; michael@0: sc_Token.QUOTE = 8/*QUOTE*/; michael@0: sc_Token.ID = 9/*ID*/; michael@0: sc_Token.DOT = 10/*DOT*/; michael@0: sc_Token.STRING = 11/*STRING*/; michael@0: sc_Token.NUMBER = 12/*NUMBER*/; michael@0: sc_Token.ERROR = 13/*ERROR*/; michael@0: sc_Token.VECTOR_BEGIN = 14/*VECTOR_BEGIN*/; michael@0: sc_Token.TRUE = 15/*TRUE*/; michael@0: sc_Token.FALSE = 16/*FALSE*/; michael@0: sc_Token.UNSPECIFIED = 17/*UNSPECIFIED*/; michael@0: sc_Token.REFERENCE = 18/*REFERENCE*/; michael@0: sc_Token.STORE = 19/*STORE*/; michael@0: sc_Token.CHAR = 20/*CHAR*/; michael@0: michael@0: var SC_ID_CLASS = SC_LOWER_CLASS + SC_UPPER_CLASS + "!$%*+-./:<=>?@^_~"; michael@0: function sc_Tokenizer(port) { michael@0: this.port = port; michael@0: } michael@0: sc_Tokenizer.prototype.peekToken = function() { michael@0: if (this.peeked) michael@0: return this.peeked; michael@0: var newToken = this.nextToken(); michael@0: this.peeked = newToken; michael@0: return newToken; michael@0: }; michael@0: sc_Tokenizer.prototype.readToken = function() { michael@0: var tmp = this.peekToken(); michael@0: delete this.peeked; michael@0: return tmp; michael@0: }; michael@0: sc_Tokenizer.prototype.nextToken = function() { michael@0: var port = this.port; michael@0: michael@0: function isNumberChar(c) { michael@0: return (c >= "0" && c <= "9"); michael@0: }; michael@0: function isIdOrNumberChar(c) { michael@0: return SC_ID_CLASS.indexOf(c) != -1 || // ID-char michael@0: (c >= "0" && c <= "9"); michael@0: } michael@0: function isWhitespace(c) { michael@0: return c === " " || c === "\r" || c === "\n" || c === "\t" || c === "\f"; michael@0: }; michael@0: function isWhitespaceOrEOF(c) { michael@0: return isWhitespace(c) || c === SC_EOF_OBJECT; michael@0: }; michael@0: michael@0: function readString() { michael@0: res = ""; michael@0: while (true) { michael@0: var c = port.readChar(); michael@0: switch (c) { michael@0: case '"': michael@0: return new sc_Token(11/*STRING*/, res); michael@0: case "\\": michael@0: var tmp = port.readChar(); michael@0: switch (tmp) { michael@0: case '0': res += "\0"; break; michael@0: case 'a': res += "\a"; break; michael@0: case 'b': res += "\b"; break; michael@0: case 'f': res += "\f"; break; michael@0: case 'n': res += "\n"; break; michael@0: case 'r': res += "\r"; break; michael@0: case 't': res += "\t"; break; michael@0: case 'v': res += "\v"; break; michael@0: case '"': res += '"'; break; michael@0: case '\\': res += '\\'; break; michael@0: case 'x': michael@0: /* hexa-number */ michael@0: var nb = 0; michael@0: while (true) { michael@0: var hexC = port.peekChar(); michael@0: if (hexC >= '0' && hexC <= '9') { michael@0: port.readChar(); michael@0: nb = nb * 16 + hexC.charCodeAt(0) - '0'.charCodeAt(0); michael@0: } else if (hexC >= 'a' && hexC <= 'f') { michael@0: port.readChar(); michael@0: nb = nb * 16 + hexC.charCodeAt(0) - 'a'.charCodeAt(0); michael@0: } else if (hexC >= 'A' && hexC <= 'F') { michael@0: port.readChar(); michael@0: nb = nb * 16 + hexC.charCodeAt(0) - 'A'.charCodeAt(0); michael@0: } else { michael@0: // next char isn't part of hex. michael@0: res += String.fromCharCode(nb); michael@0: break; michael@0: } michael@0: } michael@0: break; michael@0: default: michael@0: if (tmp === SC_EOF_OBJECT) { michael@0: return new sc_Token(13/*ERROR*/, "unclosed string-literal" + res); michael@0: } michael@0: res += tmp; michael@0: } michael@0: break; michael@0: default: michael@0: if (c === SC_EOF_OBJECT) { michael@0: return new sc_Token(13/*ERROR*/, "unclosed string-literal" + res); michael@0: } michael@0: res += c; michael@0: } michael@0: } michael@0: }; michael@0: function readIdOrNumber(firstChar) { michael@0: var res = firstChar; michael@0: while (isIdOrNumberChar(port.peekChar())) michael@0: res += port.readChar(); michael@0: if (isNaN(res)) michael@0: return new sc_Token(9/*ID*/, res); michael@0: else michael@0: return new sc_Token(12/*NUMBER*/, res - 0); michael@0: }; michael@0: michael@0: function skipWhitespaceAndComments() { michael@0: var done = false; michael@0: while (!done) { michael@0: done = true; michael@0: while (isWhitespace(port.peekChar())) michael@0: port.readChar(); michael@0: if (port.peekChar() === ';') { michael@0: port.readChar(); michael@0: done = false; michael@0: while (true) { michael@0: curChar = port.readChar(); michael@0: if (curChar === SC_EOF_OBJECT || michael@0: curChar === '\n') michael@0: break; michael@0: } michael@0: } michael@0: } michael@0: }; michael@0: michael@0: function readDot() { michael@0: if (isWhitespace(port.peekChar())) michael@0: return new sc_Token(10/*DOT*/); michael@0: else michael@0: return readIdOrNumber("."); michael@0: }; michael@0: michael@0: function readSharp() { michael@0: var c = port.readChar(); michael@0: if (isWhitespace(c)) michael@0: return new sc_Token(13/*ERROR*/, "bad #-pattern0."); michael@0: michael@0: // reference michael@0: if (isNumberChar(c)) { michael@0: var nb = c - 0; michael@0: while (isNumberChar(port.peekChar())) michael@0: nb = nb*10 + (port.readChar() - 0); michael@0: switch (port.readChar()) { michael@0: case '#': michael@0: return new sc_Token(18/*REFERENCE*/, nb); michael@0: case '=': michael@0: return new sc_Token(19/*STORE*/, nb); michael@0: default: michael@0: return new sc_Token(13/*ERROR*/, "bad #-pattern1." + nb); michael@0: } michael@0: } michael@0: michael@0: if (c === "(") michael@0: return new sc_Token(14/*VECTOR_BEGIN*/); michael@0: michael@0: if (c === "\\") { // character michael@0: var tmp = "" michael@0: while (!isWhitespaceOrEOF(port.peekChar())) michael@0: tmp += port.readChar(); michael@0: switch (tmp.length) { michael@0: case 0: // it's escaping a whitespace char: michael@0: if (sc_isEOFObject(port.peekChar)) michael@0: return new sc_Token(13/*ERROR*/, "bad #-pattern2."); michael@0: else michael@0: return new sc_Token(20/*CHAR*/, port.readChar()); michael@0: case 1: michael@0: return new sc_Token(20/*CHAR*/, tmp); michael@0: default: michael@0: var entry = sc_Char.readable2char[tmp.toLowerCase()]; michael@0: if (entry) michael@0: return new sc_Token(20/*CHAR*/, entry); michael@0: else michael@0: return new sc_Token(13/*ERROR*/, "unknown character description: #\\" + tmp); michael@0: } michael@0: } michael@0: michael@0: // some constants (#t, #f, #unspecified) michael@0: var res; michael@0: var needing; michael@0: switch (c) { michael@0: case 't': res = new sc_Token(15/*TRUE*/, true); needing = ""; break; michael@0: case 'f': res = new sc_Token(16/*FALSE*/, false); needing = ""; break; michael@0: case 'u': res = new sc_Token(17/*UNSPECIFIED*/, undefined); needing = "nspecified"; break; michael@0: default: michael@0: return new sc_Token(13/*ERROR*/, "bad #-pattern3: " + c); michael@0: } michael@0: while(true) { michael@0: c = port.peekChar(); michael@0: if ((isWhitespaceOrEOF(c) || c === ')') && michael@0: needing == "") michael@0: return res; michael@0: else if (isWhitespace(c) || needing == "") michael@0: return new sc_Token(13/*ERROR*/, "bad #-pattern4 " + c + " " + needing); michael@0: else if (needing.charAt(0) == c) { michael@0: port.readChar(); // consume michael@0: needing = needing.slice(1); michael@0: } else michael@0: return new sc_Token(13/*ERROR*/, "bad #-pattern5"); michael@0: } michael@0: michael@0: }; michael@0: michael@0: skipWhitespaceAndComments(); michael@0: var curChar = port.readChar(); michael@0: if (curChar === SC_EOF_OBJECT) michael@0: return new sc_Token(0/*EOF*/, curChar); michael@0: switch (curChar) michael@0: { michael@0: case " ": michael@0: case "\n": michael@0: case "\t": michael@0: return readWhitespace(); michael@0: case "(": michael@0: return new sc_Token(1/*OPEN_PAR*/); michael@0: case ")": michael@0: return new sc_Token(2/*CLOSE_PAR*/); michael@0: case "{": michael@0: return new sc_Token(3/*OPEN_BRACE*/); michael@0: case "}": michael@0: return new sc_Token(4/*CLOSE_BRACE*/); michael@0: case "[": michael@0: return new sc_Token(5/*OPEN_BRACKET*/); michael@0: case "]": michael@0: return new sc_Token(6/*CLOSE_BRACKET*/); michael@0: case "'": michael@0: return new sc_Token(8/*QUOTE*/); michael@0: case "#": michael@0: return readSharp(); michael@0: case ".": michael@0: return readDot(); michael@0: case '"': michael@0: return readString(); michael@0: default: michael@0: if (isIdOrNumberChar(curChar)) michael@0: return readIdOrNumber(curChar); michael@0: throw "unexpected character: " + curChar; michael@0: } michael@0: }; michael@0: michael@0: function sc_Reader(tokenizer) { michael@0: this.tokenizer = tokenizer; michael@0: this.backref = new Array(); michael@0: } michael@0: sc_Reader.prototype.read = function() { michael@0: function readList(listBeginType) { michael@0: function matchesPeer(open, close) { michael@0: return open === 1/*OPEN_PAR*/ && close === 2/*CLOSE_PAR*/ michael@0: || open === 3/*OPEN_BRACE*/ && close === 4/*CLOSE_BRACE*/ michael@0: || open === 5/*OPEN_BRACKET*/ && close === 6/*CLOSE_BRACKET*/; michael@0: }; michael@0: var res = null; michael@0: michael@0: while (true) { michael@0: var token = tokenizer.peekToken(); michael@0: michael@0: switch (token.type) { michael@0: case 2/*CLOSE_PAR*/: michael@0: case 4/*CLOSE_BRACE*/: michael@0: case 6/*CLOSE_BRACKET*/: michael@0: if (matchesPeer(listBeginType, token.type)) { michael@0: tokenizer.readToken(); // consume token michael@0: return sc_reverseBang(res); michael@0: } else michael@0: throw "closing par doesn't match: " + listBeginType michael@0: + " " + listEndType; michael@0: michael@0: case 0/*EOF*/: michael@0: throw "unexpected end of file"; michael@0: michael@0: case 10/*DOT*/: michael@0: tokenizer.readToken(); // consume token michael@0: var cdr = this.read(); michael@0: var par = tokenizer.readToken(); michael@0: if (!matchesPeer(listBeginType, par.type)) michael@0: throw "closing par doesn't match: " + listBeginType michael@0: + " " + par.type; michael@0: else michael@0: return sc_reverseAppendBang(res, cdr); michael@0: michael@0: michael@0: default: michael@0: res = sc_cons(this.read(), res); michael@0: } michael@0: } michael@0: }; michael@0: function readQuote() { michael@0: return sc_cons("quote", sc_cons(this.read(), null)); michael@0: }; michael@0: function readVector() { michael@0: // opening-parenthesis is already consumed michael@0: var a = new Array(); michael@0: while (true) { michael@0: var token = tokenizer.peekToken(); michael@0: switch (token.type) { michael@0: case 2/*CLOSE_PAR*/: michael@0: tokenizer.readToken(); michael@0: return a; michael@0: michael@0: default: michael@0: a.push(this.read()); michael@0: } michael@0: } michael@0: }; michael@0: michael@0: function storeRefence(nb) { michael@0: var tmp = this.read(); michael@0: this.backref[nb] = tmp; michael@0: return tmp; michael@0: }; michael@0: michael@0: function readReference(nb) { michael@0: if (nb in this.backref) michael@0: return this.backref[nb]; michael@0: else michael@0: throw "bad reference: " + nb; michael@0: }; michael@0: michael@0: var tokenizer = this.tokenizer; michael@0: michael@0: var token = tokenizer.readToken(); michael@0: michael@0: // handle error michael@0: if (token.type === 13/*ERROR*/) michael@0: throw token.val; michael@0: michael@0: switch (token.type) { michael@0: case 1/*OPEN_PAR*/: michael@0: case 3/*OPEN_BRACE*/: michael@0: case 5/*OPEN_BRACKET*/: michael@0: return readList.call(this, token.type); michael@0: case 8/*QUOTE*/: michael@0: return readQuote.call(this); michael@0: case 11/*STRING*/: michael@0: return sc_jsstring2string(token.val); michael@0: case 20/*CHAR*/: michael@0: return new sc_Char(token.val); michael@0: case 14/*VECTOR_BEGIN*/: michael@0: return readVector.call(this); michael@0: case 18/*REFERENCE*/: michael@0: return readReference.call(this, token.val); michael@0: case 19/*STORE*/: michael@0: return storeRefence.call(this, token.val); michael@0: case 9/*ID*/: michael@0: return sc_jsstring2symbol(token.val); michael@0: case 0/*EOF*/: michael@0: case 12/*NUMBER*/: michael@0: case 15/*TRUE*/: michael@0: case 16/*FALSE*/: michael@0: case 17/*UNSPECIFIED*/: michael@0: return token.val; michael@0: default: michael@0: throw "unexpected token " + token.type + " " + token.val; michael@0: } michael@0: }; michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_read(port) { michael@0: if (port === undefined) // we assume the port hasn't been given. michael@0: port = SC_DEFAULT_IN; // THREAD: shared var... michael@0: var reader = new sc_Reader(new sc_Tokenizer(port)); michael@0: return reader.read(); michael@0: } michael@0: /*** META ((export #t)) */ michael@0: function sc_readChar(port) { michael@0: if (port === undefined) // we assume the port hasn't been given. michael@0: port = SC_DEFAULT_IN; // THREAD: shared var... michael@0: var t = port.readChar(); michael@0: return t === SC_EOF_OBJECT? t: new sc_Char(t); michael@0: } michael@0: /*** META ((export #t)) */ michael@0: function sc_peekChar(port) { michael@0: if (port === undefined) // we assume the port hasn't been given. michael@0: port = SC_DEFAULT_IN; // THREAD: shared var... michael@0: var t = port.peekChar(); michael@0: return t === SC_EOF_OBJECT? t: new sc_Char(t); michael@0: } michael@0: /*** META ((export #t) michael@0: (type bool)) michael@0: */ michael@0: function sc_isCharReady(port) { michael@0: if (port === undefined) // we assume the port hasn't been given. michael@0: port = SC_DEFAULT_IN; // THREAD: shared var... michael@0: return port.isCharReady(); michael@0: } michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".close()"))) michael@0: */ michael@0: function sc_closeInputPort(p) { michael@0: return p.close(); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool) michael@0: (peephole (postfix " instanceof sc_InputPort"))) michael@0: */ michael@0: function sc_isInputPort(o) { michael@0: return (o instanceof sc_InputPort); michael@0: } michael@0: michael@0: /*** META ((export eof-object?) michael@0: (type bool) michael@0: (peephole (postfix " === SC_EOF_OBJECT"))) michael@0: */ michael@0: function sc_isEOFObject(o) { michael@0: return o === SC_EOF_OBJECT; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (hole 0 "SC_DEFAULT_IN"))) michael@0: */ michael@0: function sc_currentInputPort() { michael@0: return SC_DEFAULT_IN; michael@0: } michael@0: michael@0: /* ------------ file operations are not supported -----------*/ michael@0: /*** META ((export #t)) */ michael@0: function sc_callWithInputFile(s, proc) { michael@0: throw "can't open " + s; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_callWithOutputFile(s, proc) { michael@0: throw "can't open " + s; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_withInputFromFile(s, thunk) { michael@0: throw "can't open " + s; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_withOutputToFile(s, thunk) { michael@0: throw "can't open " + s; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_openInputFile(s) { michael@0: throw "can't open " + s; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_openOutputFile(s) { michael@0: throw "can't open " + s; michael@0: } michael@0: michael@0: /* ----------------------------------------------------------------------------*/ michael@0: /*** META ((export #t)) */ michael@0: function sc_basename(p) { michael@0: var i = p.lastIndexOf('/'); michael@0: michael@0: if(i >= 0) michael@0: return p.substring(i + 1, p.length); michael@0: else michael@0: return ''; michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_dirname(p) { michael@0: var i = p.lastIndexOf('/'); michael@0: michael@0: if(i >= 0) michael@0: return p.substring(0, i); michael@0: else michael@0: return ''; michael@0: } michael@0: michael@0: /* ----------------------------------------------------------------------------*/ michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_withInputFromPort(p, thunk) { michael@0: try { michael@0: var tmp = SC_DEFAULT_IN; // THREAD: shared var. michael@0: SC_DEFAULT_IN = p; michael@0: return thunk(); michael@0: } finally { michael@0: SC_DEFAULT_IN = tmp; michael@0: } michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_withInputFromString(s, thunk) { michael@0: return sc_withInputFromPort(new sc_StringInputPort(sc_string2jsstring(s)), thunk); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_withOutputToPort(p, thunk) { michael@0: try { michael@0: var tmp = SC_DEFAULT_OUT; // THREAD: shared var. michael@0: SC_DEFAULT_OUT = p; michael@0: return thunk(); michael@0: } finally { michael@0: SC_DEFAULT_OUT = tmp; michael@0: } michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_withOutputToString(thunk) { michael@0: var p = new sc_StringOutputPort(); michael@0: sc_withOutputToPort(p, thunk); michael@0: return p.close(); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_withOutputToProcedure(proc, thunk) { michael@0: var t = function(s) { proc(sc_jsstring2string(s)); }; michael@0: return sc_withOutputToPort(new sc_GenericOutputPort(t), thunk); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (hole 0 "new sc_StringOutputPort()"))) michael@0: */ michael@0: function sc_openOutputString() { michael@0: return new sc_StringOutputPort(); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_openInputString(str) { michael@0: return new sc_StringInputPort(sc_string2jsstring(str)); michael@0: } michael@0: michael@0: /* ----------------------------------------------------------------------------*/ michael@0: michael@0: function sc_OutputPort() { michael@0: } michael@0: sc_OutputPort.prototype = new sc_Port(); michael@0: sc_OutputPort.prototype.appendJSString = function(obj) { michael@0: /* do nothing */ michael@0: } michael@0: sc_OutputPort.prototype.close = function() { michael@0: /* do nothing */ michael@0: } michael@0: michael@0: function sc_StringOutputPort() { michael@0: this.res = ""; michael@0: } michael@0: sc_StringOutputPort.prototype = new sc_OutputPort(); michael@0: sc_StringOutputPort.prototype.appendJSString = function(s) { michael@0: this.res += s; michael@0: } michael@0: sc_StringOutputPort.prototype.close = function() { michael@0: return sc_jsstring2string(this.res); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_getOutputString(sp) { michael@0: return sc_jsstring2string(sp.res); michael@0: } michael@0: michael@0: michael@0: function sc_ErrorOutputPort() { michael@0: } michael@0: sc_ErrorOutputPort.prototype = new sc_OutputPort(); michael@0: sc_ErrorOutputPort.prototype.appendJSString = function(s) { michael@0: throw "don't write on ErrorPort!"; michael@0: } michael@0: sc_ErrorOutputPort.prototype.close = function() { michael@0: /* do nothing */ michael@0: } michael@0: michael@0: function sc_GenericOutputPort(appendJSString, close) { michael@0: this.appendJSString = appendJSString; michael@0: if (close) michael@0: this.close = close; michael@0: } michael@0: sc_GenericOutputPort.prototype = new sc_OutputPort(); michael@0: michael@0: /*** META ((export #t) michael@0: (type bool) michael@0: (peephole (postfix " instanceof sc_OutputPort"))) michael@0: */ michael@0: function sc_isOutputPort(o) { michael@0: return (o instanceof sc_OutputPort); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".close()"))) michael@0: */ michael@0: function sc_closeOutputPort(p) { michael@0: return p.close(); michael@0: } michael@0: michael@0: /* ------------------ write ---------------------------------------------------*/ michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_write(o, p) { michael@0: if (p === undefined) // we assume not given michael@0: p = SC_DEFAULT_OUT; michael@0: p.appendJSString(sc_toWriteString(o)); michael@0: } michael@0: michael@0: function sc_toWriteString(o) { michael@0: if (o === null) michael@0: return "()"; michael@0: else if (o === true) michael@0: return "#t"; michael@0: else if (o === false) michael@0: return "#f"; michael@0: else if (o === undefined) michael@0: return "#unspecified"; michael@0: else if (typeof o === 'function') michael@0: return "#"; michael@0: else if (o.sc_toWriteString) michael@0: return o.sc_toWriteString(); michael@0: else michael@0: return o.toString(); michael@0: } michael@0: michael@0: function sc_escapeWriteString(s) { michael@0: var res = ""; michael@0: var j = 0; michael@0: for (i = 0; i < s.length; i++) { michael@0: switch (s.charAt(i)) { michael@0: case "\0": res += s.substring(j, i) + "\\0"; j = i + 1; break; michael@0: case "\b": res += s.substring(j, i) + "\\b"; j = i + 1; break; michael@0: case "\f": res += s.substring(j, i) + "\\f"; j = i + 1; break; michael@0: case "\n": res += s.substring(j, i) + "\\n"; j = i + 1; break; michael@0: case "\r": res += s.substring(j, i) + "\\r"; j = i + 1; break; michael@0: case "\t": res += s.substring(j, i) + "\\t"; j = i + 1; break; michael@0: case "\v": res += s.substring(j, i) + "\\v"; j = i + 1; break; michael@0: case '"': res += s.substring(j, i) + '\\"'; j = i + 1; break; michael@0: case "\\": res += s.substring(j, i) + "\\\\"; j = i + 1; break; michael@0: default: michael@0: var c = s.charAt(i); michael@0: if ("\a" !== "a" && c == "\a") { michael@0: res += s.substring(j, i) + "\\a"; j = i + 1; continue; michael@0: } michael@0: if ("\v" !== "v" && c == "\v") { michael@0: res += s.substring(j, i) + "\\v"; j = i + 1; continue; michael@0: } michael@0: //if (s.charAt(i) < ' ' || s.charCodeAt(i) > 127) { michael@0: // CARE: Manuel is this OK with HOP? michael@0: if (s.charAt(i) < ' ') { michael@0: /* non printable character and special chars */ michael@0: res += s.substring(j, i) + "\\x" + s.charCodeAt(i).toString(16); michael@0: j = i + 1; michael@0: } michael@0: // else just let i increase... michael@0: } michael@0: } michael@0: res += s.substring(j, i); michael@0: return res; michael@0: } michael@0: michael@0: /* ------------------ display ---------------------------------------------------*/ michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_display(o, p) { michael@0: if (p === undefined) // we assume not given michael@0: p = SC_DEFAULT_OUT; michael@0: p.appendJSString(sc_toDisplayString(o)); michael@0: } michael@0: michael@0: function sc_toDisplayString(o) { michael@0: if (o === null) michael@0: return "()"; michael@0: else if (o === true) michael@0: return "#t"; michael@0: else if (o === false) michael@0: return "#f"; michael@0: else if (o === undefined) michael@0: return "#unspecified"; michael@0: else if (typeof o === 'function') michael@0: return "#"; michael@0: else if (o.sc_toDisplayString) michael@0: return o.sc_toDisplayString(); michael@0: else michael@0: return o.toString(); michael@0: } michael@0: michael@0: /* ------------------ newline ---------------------------------------------------*/ michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_newline(p) { michael@0: if (p === undefined) // we assume not given michael@0: p = SC_DEFAULT_OUT; michael@0: p.appendJSString("\n"); michael@0: } michael@0: michael@0: /* ------------------ write-char ---------------------------------------------------*/ michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_writeChar(c, p) { michael@0: if (p === undefined) // we assume not given michael@0: p = SC_DEFAULT_OUT; michael@0: p.appendJSString(c.val); michael@0: } michael@0: michael@0: /* ------------------ write-circle ---------------------------------------------------*/ michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_writeCircle(o, p) { michael@0: if (p === undefined) // we assume not given michael@0: p = SC_DEFAULT_OUT; michael@0: p.appendJSString(sc_toWriteCircleString(o)); michael@0: } michael@0: michael@0: function sc_toWriteCircleString(o) { michael@0: var symb = sc_gensym("writeCircle"); michael@0: var nbPointer = new Object(); michael@0: nbPointer.nb = 0; michael@0: sc_prepWriteCircle(o, symb, nbPointer); michael@0: return sc_genToWriteCircleString(o, symb); michael@0: } michael@0: michael@0: function sc_prepWriteCircle(o, symb, nbPointer) { michael@0: // TODO sc_Struct michael@0: if (o instanceof sc_Pair || michael@0: o instanceof sc_Vector) { michael@0: if (o[symb] !== undefined) { michael@0: // not the first visit. michael@0: o[symb]++; michael@0: // unless there is already a number, assign one. michael@0: if (!o[symb + "nb"]) o[symb + "nb"] = nbPointer.nb++; michael@0: return; michael@0: } michael@0: o[symb] = 0; michael@0: if (o instanceof sc_Pair) { michael@0: sc_prepWriteCircle(o.car, symb, nbPointer); michael@0: sc_prepWriteCircle(o.cdr, symb, nbPointer); michael@0: } else { michael@0: for (var i = 0; i < o.length; i++) michael@0: sc_prepWriteCircle(o[i], symb, nbPointer); michael@0: } michael@0: } michael@0: } michael@0: michael@0: function sc_genToWriteCircleString(o, symb) { michael@0: if (!(o instanceof sc_Pair || michael@0: o instanceof sc_Vector)) michael@0: return sc_toWriteString(o); michael@0: return o.sc_toWriteCircleString(symb); michael@0: } michael@0: sc_Pair.prototype.sc_toWriteCircleString = function(symb, inList) { michael@0: if (this[symb + "use"]) { // use-flag is set. Just use it. michael@0: var nb = this[symb + "nb"]; michael@0: if (this[symb]-- === 0) { // if we are the last use. remove all fields. michael@0: delete this[symb]; michael@0: delete this[symb + "nb"]; michael@0: delete this[symb + "use"]; michael@0: } michael@0: if (inList) michael@0: return '. #' + nb + '#'; michael@0: else michael@0: return '#' + nb + '#'; michael@0: } michael@0: if (this[symb]-- === 0) { // if we are the last use. remove all fields. michael@0: delete this[symb]; michael@0: delete this[symb + "nb"]; michael@0: delete this[symb + "use"]; michael@0: } michael@0: michael@0: var res = ""; michael@0: michael@0: if (this[symb] !== undefined) { // implies > 0 michael@0: this[symb + "use"] = true; michael@0: if (inList) michael@0: res += '. #' + this[symb + "nb"] + '='; michael@0: else michael@0: res += '#' + this[symb + "nb"] + '='; michael@0: inList = false; michael@0: } michael@0: michael@0: if (!inList) michael@0: res += "("; michael@0: michael@0: // print car michael@0: res += sc_genToWriteCircleString(this.car, symb); michael@0: michael@0: if (sc_isPair(this.cdr)) { michael@0: res += " " + this.cdr.sc_toWriteCircleString(symb, true); michael@0: } else if (this.cdr !== null) { michael@0: res += " . " + sc_genToWriteCircleString(this.cdr, symb); michael@0: } michael@0: if (!inList) michael@0: res += ")"; michael@0: return res; michael@0: }; michael@0: sc_Vector.prototype.sc_toWriteCircleString = function(symb) { michael@0: if (this[symb + "use"]) { // use-flag is set. Just use it. michael@0: var nb = this[symb + "nb"]; michael@0: if (this[symb]-- === 0) { // if we are the last use. remove all fields. michael@0: delete this[symb]; michael@0: delete this[symb + "nb"]; michael@0: delete this[symb + "use"]; michael@0: } michael@0: return '#' + nb + '#'; michael@0: } michael@0: if (this[symb]-- === 0) { // if we are the last use. remove all fields. michael@0: delete this[symb]; michael@0: delete this[symb + "nb"]; michael@0: delete this[symb + "use"]; michael@0: } michael@0: michael@0: var res = ""; michael@0: if (this[symb] !== undefined) { // implies > 0 michael@0: this[symb + "use"] = true; michael@0: res += '#' + this[symb + "nb"] + '='; michael@0: } michael@0: res += "#("; michael@0: for (var i = 0; i < this.length; i++) { michael@0: res += sc_genToWriteCircleString(this[i], symb); michael@0: if (i < this.length - 1) res += " "; michael@0: } michael@0: res += ")"; michael@0: return res; michael@0: }; michael@0: michael@0: michael@0: /* ------------------ print ---------------------------------------------------*/ michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_print(s) { michael@0: if (arguments.length === 1) { michael@0: sc_display(s); michael@0: sc_newline(); michael@0: } michael@0: else { michael@0: for (var i = 0; i < arguments.length; i++) michael@0: sc_display(arguments[i]); michael@0: sc_newline(); michael@0: } michael@0: } michael@0: michael@0: /* ------------------ format ---------------------------------------------------*/ michael@0: /*** META ((export #t)) */ michael@0: function sc_format(s, args) { michael@0: var len = s.length; michael@0: var p = new sc_StringOutputPort(); michael@0: var i = 0, j = 1; michael@0: michael@0: while( i < len ) { michael@0: var i2 = s.indexOf("~", i); michael@0: michael@0: if (i2 == -1) { michael@0: p.appendJSString( s.substring( i, len ) ); michael@0: return p.close(); michael@0: } else { michael@0: if (i2 > i) { michael@0: if (i2 == (len - 1)) { michael@0: p.appendJSString(s.substring(i, len)); michael@0: return p.close(); michael@0: } else { michael@0: p.appendJSString(s.substring(i, i2)); michael@0: i = i2; michael@0: } michael@0: } michael@0: michael@0: switch(s.charCodeAt(i2 + 1)) { michael@0: case 65: michael@0: case 97: michael@0: // a michael@0: sc_display(arguments[j], p); michael@0: i += 2; j++; michael@0: break; michael@0: michael@0: case 83: michael@0: case 115: michael@0: // s michael@0: sc_write(arguments[j], p); michael@0: i += 2; j++; michael@0: break; michael@0: michael@0: case 86: michael@0: case 118: michael@0: // v michael@0: sc_display(arguments[j], p); michael@0: p.appendJSString("\n"); michael@0: i += 2; j++; michael@0: break; michael@0: michael@0: case 67: michael@0: case 99: michael@0: // c michael@0: p.appendJSString(String.fromCharCode(arguments[j])); michael@0: i += 2; j++; michael@0: break; michael@0: michael@0: case 88: michael@0: case 120: michael@0: // x michael@0: p.appendJSString(arguments[j].toString(6)); michael@0: i += 2; j++; michael@0: break; michael@0: michael@0: case 79: michael@0: case 111: michael@0: // o michael@0: p.appendJSString(arguments[j].toString(8)); michael@0: i += 2; j++; michael@0: break; michael@0: michael@0: case 66: michael@0: case 98: michael@0: // b michael@0: p.appendJSString(arguments[j].toString(2)); michael@0: i += 2; j++; michael@0: break; michael@0: michael@0: case 37: michael@0: case 110: michael@0: // %, n michael@0: p.appendJSString("\n"); michael@0: i += 2; break; michael@0: michael@0: case 114: michael@0: // r michael@0: p.appendJSString("\r"); michael@0: i += 2; break; michael@0: michael@0: case 126: michael@0: // ~ michael@0: p.appendJSString("~"); michael@0: i += 2; break; michael@0: michael@0: default: michael@0: sc_error( "format: illegal ~" michael@0: + String.fromCharCode(s.charCodeAt(i2 + 1)) michael@0: + " sequence" ); michael@0: return ""; michael@0: } michael@0: } michael@0: } michael@0: michael@0: return p.close(); michael@0: } michael@0: michael@0: /* ------------------ global ports ---------------------------------------------------*/ michael@0: michael@0: var SC_DEFAULT_IN = new sc_ErrorInputPort(); michael@0: var SC_DEFAULT_OUT = new sc_ErrorOutputPort(); michael@0: var SC_ERROR_OUT = new sc_ErrorOutputPort(); michael@0: michael@0: var sc_SYMBOL_PREFIX = "\u1E9C"; michael@0: var sc_KEYWORD_PREFIX = "\u1E9D"; michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (id))) */ michael@0: function sc_jsstring2string(s) { michael@0: return s; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (prefix "'\\u1E9C' +"))) michael@0: */ michael@0: function sc_jsstring2symbol(s) { michael@0: return sc_SYMBOL_PREFIX + s; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (id))) michael@0: */ michael@0: function sc_string2jsstring(s) { michael@0: return s; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (symbol2jsstring_immutable))) michael@0: */ michael@0: function sc_symbol2jsstring(s) { michael@0: return s.slice(1); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".slice(1)"))) michael@0: */ michael@0: function sc_keyword2jsstring(k) { michael@0: return k.slice(1); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (prefix "'\\u1E9D' +"))) michael@0: */ michael@0: function sc_jsstring2keyword(s) { michael@0: return sc_KEYWORD_PREFIX + s; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool)) michael@0: */ michael@0: function sc_isKeyword(s) { michael@0: return (typeof s === "string") && michael@0: (s.charAt(0) === sc_KEYWORD_PREFIX); michael@0: } michael@0: michael@0: michael@0: /*** META ((export #t)) */ michael@0: var sc_gensym = function() { michael@0: var counter = 1000; michael@0: return function(sym) { michael@0: counter++; michael@0: if (!sym) sym = sc_SYMBOL_PREFIX; michael@0: return sym + "s" + counter + "~" + "^sC-GeNsYm "; michael@0: }; michael@0: }(); michael@0: michael@0: michael@0: /*** META ((export #t) michael@0: (type bool)) michael@0: */ michael@0: function sc_isEqual(o1, o2) { michael@0: return ((o1 === o2) || michael@0: (sc_isPair(o1) && sc_isPair(o2) michael@0: && sc_isPairEqual(o1, o2, sc_isEqual)) || michael@0: (sc_isVector(o1) && sc_isVector(o2) michael@0: && sc_isVectorEqual(o1, o2, sc_isEqual))); michael@0: } michael@0: michael@0: /*** META ((export number->symbol integer->symbol)) */ michael@0: function sc_number2symbol(x, radix) { michael@0: return sc_SYMBOL_PREFIX + sc_number2jsstring(x, radix); michael@0: } michael@0: michael@0: /*** META ((export number->string integer->string)) */ michael@0: var sc_number2string = sc_number2jsstring; michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_symbol2number(s, radix) { michael@0: return sc_jsstring2number(s.slice(1), radix); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: var sc_string2number = sc_jsstring2number; michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (prefix "+" s))) michael@0: ;; peephole will only apply if no radix is given. michael@0: */ michael@0: function sc_string2integer(s, radix) { michael@0: if (!radix) return +s; michael@0: return parseInt(s, radix); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (prefix "+"))) michael@0: */ michael@0: function sc_string2real(s) { michael@0: return +s; michael@0: } michael@0: michael@0: michael@0: /*** META ((export #t) michael@0: (type bool)) michael@0: */ michael@0: function sc_isSymbol(s) { michael@0: return (typeof s === "string") && michael@0: (s.charAt(0) === sc_SYMBOL_PREFIX); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (symbol2string_immutable))) michael@0: */ michael@0: function sc_symbol2string(s) { michael@0: return s.slice(1); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (prefix "'\\u1E9C' +"))) michael@0: */ michael@0: function sc_string2symbol(s) { michael@0: return sc_SYMBOL_PREFIX + s; michael@0: } michael@0: michael@0: /*** META ((export symbol-append) michael@0: (peephole (symbolAppend_immutable))) michael@0: */ michael@0: function sc_symbolAppend() { michael@0: var res = sc_SYMBOL_PREFIX; michael@0: for (var i = 0; i < arguments.length; i++) michael@0: res += arguments[i].slice(1); michael@0: return res; michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".val"))) michael@0: */ michael@0: function sc_char2string(c) { return c.val; } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (hole 1 "'\\u1E9C' + " c ".val"))) michael@0: */ michael@0: function sc_char2symbol(c) { return sc_SYMBOL_PREFIX + c.val; } michael@0: michael@0: /*** META ((export #t) michael@0: (type bool)) michael@0: */ michael@0: function sc_isString(s) { michael@0: return (typeof s === "string") && michael@0: (s.charAt(0) !== sc_SYMBOL_PREFIX); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: var sc_makeString = sc_makejsString; michael@0: michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_string() { michael@0: for (var i = 0; i < arguments.length; i++) michael@0: arguments[i] = arguments[i].val; michael@0: return "".concat.apply("", arguments); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".length"))) michael@0: */ michael@0: function sc_stringLength(s) { return s.length; } michael@0: michael@0: /*** META ((export #t)) */ michael@0: function sc_stringRef(s, k) { michael@0: return new sc_Char(s.charAt(k)); michael@0: } michael@0: michael@0: /* there's no stringSet in the immutable version michael@0: function sc_stringSet(s, k, c) michael@0: */ michael@0: michael@0: michael@0: /*** META ((export string=?) michael@0: (type bool) michael@0: (peephole (hole 2 str1 " === " str2))) michael@0: */ michael@0: function sc_isStringEqual(s1, s2) { michael@0: return s1 === s2; michael@0: } michael@0: /*** META ((export string?) michael@0: (type bool) michael@0: (peephole (hole 2 str1 " > " str2))) michael@0: */ michael@0: function sc_isStringGreater(s1, s2) { michael@0: return s1 > s2; michael@0: } michael@0: /*** META ((export string<=?) michael@0: (type bool) michael@0: (peephole (hole 2 str1 " <= " str2))) michael@0: */ michael@0: function sc_isStringLessEqual(s1, s2) { michael@0: return s1 <= s2; michael@0: } michael@0: /*** META ((export string>=?) michael@0: (type bool) michael@0: (peephole (hole 2 str1 " >= " str2))) michael@0: */ michael@0: function sc_isStringGreaterEqual(s1, s2) { michael@0: return s1 >= s2; michael@0: } michael@0: /*** META ((export string-ci=?) michael@0: (type bool) michael@0: (peephole (hole 2 str1 ".toLowerCase() === " str2 ".toLowerCase()"))) michael@0: */ michael@0: function sc_isStringCIEqual(s1, s2) { michael@0: return s1.toLowerCase() === s2.toLowerCase(); michael@0: } michael@0: /*** META ((export string-ci?) michael@0: (type bool) michael@0: (peephole (hole 2 str1 ".toLowerCase() > " str2 ".toLowerCase()"))) michael@0: */ michael@0: function sc_isStringCIGreater(s1, s2) { michael@0: return s1.toLowerCase() > s2.toLowerCase(); michael@0: } michael@0: /*** META ((export string-ci<=?) michael@0: (type bool) michael@0: (peephole (hole 2 str1 ".toLowerCase() <= " str2 ".toLowerCase()"))) michael@0: */ michael@0: function sc_isStringCILessEqual(s1, s2) { michael@0: return s1.toLowerCase() <= s2.toLowerCase(); michael@0: } michael@0: /*** META ((export string-ci>=?) michael@0: (type bool) michael@0: (peephole (hole 2 str1 ".toLowerCase() >= " str2 ".toLowerCase()"))) michael@0: */ michael@0: function sc_isStringCIGreaterEqual(s1, s2) { michael@0: return s1.toLowerCase() >= s2.toLowerCase(); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (hole 3 s ".substring(" start ", " end ")"))) michael@0: */ michael@0: function sc_substring(s, start, end) { michael@0: return s.substring(start, end); michael@0: } michael@0: michael@0: /*** META ((export #t)) michael@0: */ michael@0: function sc_isSubstring_at(s1, s2, i) { michael@0: return s2 == s1.substring(i, i+ s2.length); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (infix 0 #f "+" "''"))) michael@0: */ michael@0: function sc_stringAppend() { michael@0: return "".concat.apply("", arguments); michael@0: } michael@0: michael@0: /*** META ((export #t)) */ michael@0: var sc_string2list = sc_jsstring2list; michael@0: michael@0: /*** META ((export #t)) */ michael@0: var sc_list2string = sc_list2jsstring; michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (id))) michael@0: */ michael@0: function sc_stringCopy(s) { michael@0: return s; michael@0: } michael@0: michael@0: /* there's no string-fill in the immutable version michael@0: function sc_stringFill(s, c) michael@0: */ michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (postfix ".slice(1)"))) michael@0: */ michael@0: function sc_keyword2string(o) { michael@0: return o.slice(1); michael@0: } michael@0: michael@0: /*** META ((export #t) michael@0: (peephole (prefix "'\\u1E9D' +"))) michael@0: */ michael@0: function sc_string2keyword(o) { michael@0: return sc_KEYWORD_PREFIX + o; michael@0: } michael@0: michael@0: String.prototype.sc_toDisplayString = function() { michael@0: if (this.charAt(0) === sc_SYMBOL_PREFIX) michael@0: // TODO: care for symbols with spaces (escape-chars symbols). michael@0: return this.slice(1); michael@0: else if (this.charAt(0) === sc_KEYWORD_PREFIX) michael@0: return ":" + this.slice(1); michael@0: else michael@0: return this.toString(); michael@0: }; michael@0: michael@0: String.prototype.sc_toWriteString = function() { michael@0: if (this.charAt(0) === sc_SYMBOL_PREFIX) michael@0: // TODO: care for symbols with spaces (escape-chars symbols). michael@0: return this.slice(1); michael@0: else if (this.charAt(0) === sc_KEYWORD_PREFIX) michael@0: return ":" + this.slice(1); michael@0: else michael@0: return '"' + sc_escapeWriteString(this) + '"'; michael@0: }; michael@0: /* Exported Variables */ michael@0: var BgL_testzd2boyerzd2; michael@0: var BgL_nboyerzd2benchmarkzd2; michael@0: var BgL_setupzd2boyerzd2; michael@0: /* End Exports */ michael@0: michael@0: var translate_term_nboyer; michael@0: var translate_args_nboyer; michael@0: var untranslate_term_nboyer; michael@0: var BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer; michael@0: var BgL_sc_za2symbolzd2recordszd2alistza2_2z00_nboyer; michael@0: var translate_alist_nboyer; michael@0: var apply_subst_nboyer; michael@0: var apply_subst_lst_nboyer; michael@0: var tautologyp_nboyer; michael@0: var if_constructor_nboyer; michael@0: var rewrite_count_nboyer; michael@0: var rewrite_nboyer; michael@0: var rewrite_args_nboyer; michael@0: var unify_subst_nboyer; michael@0: var one_way_unify1_nboyer; michael@0: var false_term_nboyer; michael@0: var true_term_nboyer; michael@0: var trans_of_implies1_nboyer; michael@0: var is_term_equal_nboyer; michael@0: var is_term_member_nboyer; michael@0: var const_nboyer; michael@0: var sc_const_3_nboyer; michael@0: var sc_const_4_nboyer; michael@0: { michael@0: (sc_const_4_nboyer = (new sc_Pair("\u1E9Cimplies",(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cz",(new sc_Pair("\u1E9Cu",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cu",(new sc_Pair("\u1E9Cw",null)))))),null)))))),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cw",null)))))),null))))))); michael@0: (sc_const_3_nboyer = sc_list((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ccompile",(new sc_Pair("\u1E9Cform",null)))),(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair((new sc_Pair("\u1E9Ccodegen",(new sc_Pair((new sc_Pair("\u1E9Coptimize",(new sc_Pair("\u1E9Cform",null)))),(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ceqp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cy",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgreaterp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clesseqp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgreatereqp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cboolean",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cf",null)),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ciff",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ceven1",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Ct",null)),(new sc_Pair((new sc_Pair("\u1E9Codd",(new sc_Pair((new sc_Pair("\u1E9Csub1",(new sc_Pair("\u1E9Cx",null)))),null)))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ccountps-",(new sc_Pair("\u1E9Cl",(new sc_Pair("\u1E9Cpred",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ccountps-loop",(new sc_Pair("\u1E9Cl",(new sc_Pair("\u1E9Cpred",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cfact-",(new sc_Pair("\u1E9Ci",null)))),(new sc_Pair((new sc_Pair("\u1E9Cfact-loop",(new sc_Pair("\u1E9Ci",(new sc_Pair((1),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Creverse-",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Creverse-loop",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdivides",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cassume-true",(new sc_Pair("\u1E9Cvar",(new sc_Pair("\u1E9Calist",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cvar",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),null)))))),(new sc_Pair("\u1E9Calist",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cassume-false",(new sc_Pair("\u1E9Cvar",(new sc_Pair("\u1E9Calist",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cvar",(new sc_Pair((new sc_Pair("\u1E9Cf",null)),null)))))),(new sc_Pair("\u1E9Calist",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctautology-checker",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Ctautologyp",(new sc_Pair((new sc_Pair("\u1E9Cnormalize",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cfalsify",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cfalsify1",(new sc_Pair((new sc_Pair("\u1E9Cnormalize",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cprime",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))),null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cprime1",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Csub1",(new sc_Pair("\u1E9Cx",null)))),null)))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair("\u1E9Cp",(new sc_Pair("\u1E9Cq",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cp",(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cq",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),(new sc_Pair((new sc_Pair("\u1E9Cf",null)),null)))))))),(new sc_Pair((new sc_Pair("\u1E9Cf",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair("\u1E9Cp",(new sc_Pair("\u1E9Cq",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cp",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cq",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),(new sc_Pair((new sc_Pair("\u1E9Cf",null)),null)))))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair("\u1E9Cp",null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cp",(new sc_Pair((new sc_Pair("\u1E9Cf",null)),(new sc_Pair((new sc_Pair("\u1E9Ct",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cp",(new sc_Pair("\u1E9Cq",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cp",(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cq",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),(new sc_Pair((new sc_Pair("\u1E9Cf",null)),null)))))))),(new sc_Pair((new sc_Pair("\u1E9Ct",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",(new sc_Pair("\u1E9Cc",null)))))))),(new sc_Pair("\u1E9Cd",(new sc_Pair("\u1E9Ce",null)))))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Ca",(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cb",(new sc_Pair("\u1E9Cd",(new sc_Pair("\u1E9Ce",null)))))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cc",(new sc_Pair("\u1E9Cd",(new sc_Pair("\u1E9Ce",null)))))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cx",null)))),null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Ca",null)))),(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cb",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cc",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cb",null)))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cc",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair("\u1E9Ca",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair((new sc_Pair("\u1E9Cplus-fringe",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Ca",null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair("\u1E9Cb",null)))),(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair("\u1E9Ca",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cz",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cexec",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cpds",(new sc_Pair("\u1E9Cenvrn",null)))))))),(new sc_Pair((new sc_Pair("\u1E9Cexec",(new sc_Pair("\u1E9Cy",(new sc_Pair((new sc_Pair("\u1E9Cexec",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cpds",(new sc_Pair("\u1E9Cenvrn",null)))))))),(new sc_Pair("\u1E9Cenvrn",null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmc-flatten",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair("\u1E9Cy",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cb",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair("\u1E9Cy",null)))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair("\u1E9Cx",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Ca",(new sc_Pair((new sc_Pair("\u1E9Cintersect",(new sc_Pair("\u1E9Cb",(new sc_Pair("\u1E9Cc",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cc",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cnth",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cexp",(new sc_Pair("\u1E9Ci",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cj",(new sc_Pair("\u1E9Ck",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair((new sc_Pair("\u1E9Cexp",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cj",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cexp",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Ck",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cexp",(new sc_Pair("\u1E9Ci",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cj",(new sc_Pair("\u1E9Ck",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cexp",(new sc_Pair((new sc_Pair("\u1E9Cexp",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cj",null)))))),(new sc_Pair("\u1E9Ck",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Creverse-loop",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair("\u1E9Cy",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Creverse-loop",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair("\u1E9Cx",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ccount-list",(new sc_Pair("\u1E9Cz",(new sc_Pair((new sc_Pair("\u1E9Csort-lp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Ccount-list",(new sc_Pair("\u1E9Cz",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ccount-list",(new sc_Pair("\u1E9Cz",(new sc_Pair("\u1E9Cy",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cc",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cb",(new sc_Pair("\u1E9Cc",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cy",(new sc_Pair((new sc_Pair("\u1E9Cquotient",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair((new sc_Pair("\u1E9Cbig-plus1",(new sc_Pair("\u1E9Cl",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cbase",null)))))))),(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair("\u1E9Cl",(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair("\u1E9Ci",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair((new sc_Pair("\u1E9Cbig-plus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cbase",null)))))))))),(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ci",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cbase",null)))))),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Cy",(new sc_Pair((1),null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Cquotient",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cj",null)))))),(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Ci",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cj",null)))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cj",(new sc_Pair((1),null)))))),null)))),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair((new sc_Pair("\u1E9Cpower-rep",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Ci",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair((new sc_Pair("\u1E9Cbig-plus",(new sc_Pair((new sc_Pair("\u1E9Cpower-rep",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cpower-rep",(new sc_Pair("\u1E9Cj",(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),(new sc_Pair("\u1E9Cbase",null)))))))))),(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cj",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgcd",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cgcd",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cnth",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair((new sc_Pair("\u1E9Cnth",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnth",(new sc_Pair("\u1E9Cb",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Ci",(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair("\u1E9Ca",null)))),null)))))),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cy",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cy",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cz",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cc",(new sc_Pair("\u1E9Cw",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cc",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cw",(new sc_Pair("\u1E9Cx",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cb",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cc",null)))))),null)))))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cb",(new sc_Pair("\u1E9Cc",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair("\u1E9Cy",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cz",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cz",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cx",null)))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgcd",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cz",(new sc_Pair((new sc_Pair("\u1E9Cgcd",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cvalue",(new sc_Pair((new sc_Pair("\u1E9Cnormalize",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cvalue",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Ca",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cy",(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnlistp",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clistp",(new sc_Pair((new sc_Pair("\u1E9Cgopher",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Clistp",(new sc_Pair("\u1E9Cx",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Csamefringe",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair("\u1E9Cy",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgreatest-factor",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cy",(new sc_Pair((1),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgreatest-factor",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((1),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((1),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair((new sc_Pair("\u1E9Cgreatest-factor",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cy",(new sc_Pair((1),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cx",null)))),null)))),null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes-list",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair((new sc_Pair("\u1E9Ctimes-list",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Ctimes-list",(new sc_Pair("\u1E9Cy",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cprime-list",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cprime-list",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cprime-list",(new sc_Pair("\u1E9Cy",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cz",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cw",(new sc_Pair("\u1E9Cz",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cz",null)))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cz",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cw",(new sc_Pair((1),null)))))),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgreatereqp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cy",(new sc_Pair((1),null)))))),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((1),null)))))),(new sc_Pair(sc_list("\u1E9Cand", (new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Ca",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),null)))), (new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cb",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),null)))), (new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Ca",null)))), (new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cb",null)))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Csub1",(new sc_Pair("\u1E9Ca",null)))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Csub1",(new sc_Pair("\u1E9Cb",null)))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair((new sc_Pair("\u1E9Cdelete",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cl",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair("\u1E9Cl",null)))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cl",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Csort2",(new sc_Pair((new sc_Pair("\u1E9Cdelete",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cl",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cdelete",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Csort2",(new sc_Pair("\u1E9Cl",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdsort",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Csort2",(new sc_Pair("\u1E9Cx",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cx1",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cx2",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cx3",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cx4",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cx5",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cx6",(new sc_Pair("\u1E9Cx7",null)))))),null)))))),null)))))),null)))))),null)))))),null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((6),(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair("\u1E9Cx7",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((2),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cquotient",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((2),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cquotient",(new sc_Pair("\u1E9Cy",(new sc_Pair((2),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Csigma",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cquotient",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Ci",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair("\u1E9Ci",null)))),null)))))),(new sc_Pair((2),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair("\u1E9Cy",null)))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair("\u1E9Cx",null)))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cz",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cz",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cz",null)))),null)))))),null)))))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair((new sc_Pair("\u1E9Cdelete",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Ca",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair("\u1E9Ca",null)))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair("\u1E9Cy",null)))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cnth",(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Ci",null)))),(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clast",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clistp",(new sc_Pair("\u1E9Cb",null)))),(new sc_Pair((new sc_Pair("\u1E9Clast",(new sc_Pair("\u1E9Cb",null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clistp",(new sc_Pair("\u1E9Ca",null)))),(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair((new sc_Pair("\u1E9Ccar",(new sc_Pair((new sc_Pair("\u1E9Clast",(new sc_Pair("\u1E9Ca",null)))),null)))),(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair("\u1E9Cb",null)))))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cf",null)),(new sc_Pair("\u1E9Cz",null)))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cassignment",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Cassignedp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cassignment",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cassignment",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cb",null)))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ccar",(new sc_Pair((new sc_Pair("\u1E9Cgopher",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clistp",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Ccar",(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair((new sc_Pair("\u1E9Ccdr",(new sc_Pair((new sc_Pair("\u1E9Cgopher",(new sc_Pair("\u1E9Cx",null)))),null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clistp",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Ccdr",(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cquotient",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cget",(new sc_Pair("\u1E9Cj",(new sc_Pair((new sc_Pair("\u1E9Cset",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cval",(new sc_Pair("\u1E9Cmem",null)))))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Ceqp",(new sc_Pair("\u1E9Cj",(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair("\u1E9Cval",(new sc_Pair((new sc_Pair("\u1E9Cget",(new sc_Pair("\u1E9Cj",(new sc_Pair("\u1E9Cmem",null)))))),null)))))))),null)))))))); michael@0: (const_nboyer = (new sc_Pair((new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cf",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cc",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cf",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cc",(new sc_Pair("\u1E9Cd",null)))))),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cz",(new sc_Pair("\u1E9Cf",(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cu",(new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))))),(new sc_Pair((new sc_Pair("\u1E9Cw",(new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Ca",(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair("\u1E9Cb",null)))),null)))))),null)))))))),null))))))))))); michael@0: BgL_nboyerzd2benchmarkzd2 = function() { michael@0: var args = null; michael@0: for (var sc_tmp = arguments.length - 1; sc_tmp >= 0; sc_tmp--) { michael@0: args = sc_cons(arguments[sc_tmp], args); michael@0: } michael@0: var n; michael@0: return ((n = ((args === null)?(0):(args.car))), (BgL_setupzd2boyerzd2()), (BgL_runzd2benchmarkzd2(("nboyer"+(sc_number2string(n))), (1), function() { michael@0: return (BgL_testzd2boyerzd2(n)); michael@0: }, function(rewrites) { michael@0: if ((sc_isNumber(rewrites))) michael@0: switch (n) { michael@0: case (0): michael@0: return (rewrites===(95024)); michael@0: break; michael@0: case (1): michael@0: return (rewrites===(591777)); michael@0: break; michael@0: case (2): michael@0: return (rewrites===(1813975)); michael@0: break; michael@0: case (3): michael@0: return (rewrites===(5375678)); michael@0: break; michael@0: case (4): michael@0: return (rewrites===(16445406)); michael@0: break; michael@0: case (5): michael@0: return (rewrites===(51507739)); michael@0: break; michael@0: default: michael@0: return true; michael@0: break; michael@0: } michael@0: else michael@0: return false; michael@0: }))); michael@0: }; michael@0: BgL_setupzd2boyerzd2 = function() { michael@0: return true; michael@0: }; michael@0: BgL_testzd2boyerzd2 = function() { michael@0: return true; michael@0: }; michael@0: translate_term_nboyer = function(term) { michael@0: var lst; michael@0: return (!(term instanceof sc_Pair)?term:(new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((term.car))), ((lst = (term.cdr)), ((lst === null)?null:(new sc_Pair((translate_term_nboyer((lst.car))), (translate_args_nboyer((lst.cdr)))))))))); michael@0: }; michael@0: translate_args_nboyer = function(lst) { michael@0: var sc_lst_5; michael@0: var term; michael@0: return ((lst === null)?null:(new sc_Pair(((term = (lst.car)), (!(term instanceof sc_Pair)?term:(new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((term.car))), (translate_args_nboyer((term.cdr))))))), ((sc_lst_5 = (lst.cdr)), ((sc_lst_5 === null)?null:(new sc_Pair((translate_term_nboyer((sc_lst_5.car))), (translate_args_nboyer((sc_lst_5.cdr)))))))))); michael@0: }; michael@0: untranslate_term_nboyer = function(term) { michael@0: var optrOpnd; michael@0: var tail1131; michael@0: var L1127; michael@0: var falseHead1130; michael@0: var symbol_record; michael@0: if (!(term instanceof sc_Pair)) michael@0: return term; michael@0: else michael@0: { michael@0: (falseHead1130 = (new sc_Pair(null, null))); michael@0: (L1127 = (term.cdr)); michael@0: (tail1131 = falseHead1130); michael@0: while (!(L1127 === null)) { michael@0: { michael@0: (tail1131.cdr = (new sc_Pair((untranslate_term_nboyer((L1127.car))), null))); michael@0: (tail1131 = (tail1131.cdr)); michael@0: (L1127 = (L1127.cdr)); michael@0: } michael@0: } michael@0: (optrOpnd = (falseHead1130.cdr)); michael@0: return (new sc_Pair(((symbol_record = (term.car)), (symbol_record[(0)])), optrOpnd)); michael@0: } michael@0: }; michael@0: BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer = function(sym) { michael@0: var r; michael@0: var x; michael@0: return ((x = (sc_assq(sym, BgL_sc_za2symbolzd2recordszd2alistza2_2z00_nboyer))), ((x!== false)?(x.cdr):((r = [sym, null]), (BgL_sc_za2symbolzd2recordszd2alistza2_2z00_nboyer = (new sc_Pair((new sc_Pair(sym, r)), BgL_sc_za2symbolzd2recordszd2alistza2_2z00_nboyer))), r))); michael@0: }; michael@0: (BgL_sc_za2symbolzd2recordszd2alistza2_2z00_nboyer = null); michael@0: translate_alist_nboyer = function(alist) { michael@0: var sc_alist_6; michael@0: var term; michael@0: return ((alist === null)?null:(new sc_Pair((new sc_Pair((alist.car.car), ((term = (alist.car.cdr)), (!(term instanceof sc_Pair)?term:(new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((term.car))), (translate_args_nboyer((term.cdr))))))))), ((sc_alist_6 = (alist.cdr)), ((sc_alist_6 === null)?null:(new sc_Pair((new sc_Pair((sc_alist_6.car.car), (translate_term_nboyer((sc_alist_6.car.cdr))))), (translate_alist_nboyer((sc_alist_6.cdr)))))))))); michael@0: }; michael@0: apply_subst_nboyer = function(alist, term) { michael@0: var lst; michael@0: var temp_temp; michael@0: return (!(term instanceof sc_Pair)?((temp_temp = (sc_assq(term, alist))), ((temp_temp!== false)?(temp_temp.cdr):term)):(new sc_Pair((term.car), ((lst = (term.cdr)), ((lst === null)?null:(new sc_Pair((apply_subst_nboyer(alist, (lst.car))), (apply_subst_lst_nboyer(alist, (lst.cdr)))))))))); michael@0: }; michael@0: apply_subst_lst_nboyer = function(alist, lst) { michael@0: var sc_lst_7; michael@0: return ((lst === null)?null:(new sc_Pair((apply_subst_nboyer(alist, (lst.car))), ((sc_lst_7 = (lst.cdr)), ((sc_lst_7 === null)?null:(new sc_Pair((apply_subst_nboyer(alist, (sc_lst_7.car))), (apply_subst_lst_nboyer(alist, (sc_lst_7.cdr)))))))))); michael@0: }; michael@0: tautologyp_nboyer = function(sc_x_11, true_lst, false_lst) { michael@0: var tmp1125; michael@0: var x; michael@0: var tmp1126; michael@0: var sc_x_8; michael@0: var sc_tmp1125_9; michael@0: var sc_tmp1126_10; michael@0: var sc_x_11; michael@0: var true_lst; michael@0: var false_lst; michael@0: while (true) { michael@0: if ((((sc_tmp1126_10 = (is_term_equal_nboyer(sc_x_11, true_term_nboyer))), ((sc_tmp1126_10!== false)?sc_tmp1126_10:(is_term_member_nboyer(sc_x_11, true_lst))))!== false)) michael@0: return true; michael@0: else michael@0: 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)) michael@0: return false; michael@0: else michael@0: if (!(sc_x_11 instanceof sc_Pair)) michael@0: return false; michael@0: else michael@0: if (((sc_x_11.car)===if_constructor_nboyer)) michael@0: if ((((sc_x_8 = (sc_x_11.cdr.car)), (tmp1126 = (is_term_equal_nboyer(sc_x_8, true_term_nboyer))), ((tmp1126!== false)?tmp1126:(is_term_member_nboyer(sc_x_8, true_lst))))!== false)) michael@0: (sc_x_11 = (sc_x_11.cdr.cdr.car)); michael@0: else michael@0: if ((((x = (sc_x_11.cdr.car)), (tmp1125 = (is_term_equal_nboyer(x, false_term_nboyer))), ((tmp1125!== false)?tmp1125:(is_term_member_nboyer(x, false_lst))))!== false)) michael@0: (sc_x_11 = (sc_x_11.cdr.cdr.cdr.car)); michael@0: else michael@0: if (((tautologyp_nboyer((sc_x_11.cdr.cdr.car), (new sc_Pair((sc_x_11.cdr.car), true_lst)), false_lst))!== false)) michael@0: { michael@0: (false_lst = (new sc_Pair((sc_x_11.cdr.car), false_lst))); michael@0: (sc_x_11 = (sc_x_11.cdr.cdr.cdr.car)); michael@0: } michael@0: else michael@0: return false; michael@0: else michael@0: return false; michael@0: } michael@0: }; michael@0: (if_constructor_nboyer = "\u1E9C*"); michael@0: (rewrite_count_nboyer = (0)); michael@0: rewrite_nboyer = function(term) { michael@0: var term2; michael@0: var sc_term_12; michael@0: var lst; michael@0: var symbol_record; michael@0: var sc_lst_13; michael@0: { michael@0: (++rewrite_count_nboyer); michael@0: if (!(term instanceof sc_Pair)) michael@0: return term; michael@0: else michael@0: { michael@0: (sc_term_12 = (new sc_Pair((term.car), ((sc_lst_13 = (term.cdr)), ((sc_lst_13 === null)?null:(new sc_Pair((rewrite_nboyer((sc_lst_13.car))), (rewrite_args_nboyer((sc_lst_13.cdr)))))))))); michael@0: (lst = ((symbol_record = (term.car)), (symbol_record[(1)]))); michael@0: while (true) { michael@0: if ((lst === null)) michael@0: return sc_term_12; michael@0: else michael@0: if ((((term2 = ((lst.car).cdr.car)), (unify_subst_nboyer = null), (one_way_unify1_nboyer(sc_term_12, term2)))!== false)) michael@0: return (rewrite_nboyer((apply_subst_nboyer(unify_subst_nboyer, ((lst.car).cdr.cdr.car))))); michael@0: else michael@0: (lst = (lst.cdr)); michael@0: } michael@0: } michael@0: } michael@0: }; michael@0: rewrite_args_nboyer = function(lst) { michael@0: var sc_lst_14; michael@0: 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)))))))))); michael@0: }; michael@0: (unify_subst_nboyer = "\u1E9C*"); michael@0: one_way_unify1_nboyer = function(term1, term2) { michael@0: var lst1; michael@0: var lst2; michael@0: var temp_temp; michael@0: if (!(term2 instanceof sc_Pair)) michael@0: { michael@0: (temp_temp = (sc_assq(term2, unify_subst_nboyer))); michael@0: if ((temp_temp!== false)) michael@0: return (is_term_equal_nboyer(term1, (temp_temp.cdr))); michael@0: else michael@0: if ((sc_isNumber(term2))) michael@0: return (sc_isEqual(term1, term2)); michael@0: else michael@0: { michael@0: (unify_subst_nboyer = (new sc_Pair((new sc_Pair(term2, term1)), unify_subst_nboyer))); michael@0: return true; michael@0: } michael@0: } michael@0: else michael@0: if (!(term1 instanceof sc_Pair)) michael@0: return false; michael@0: else michael@0: if (((term1.car)===(term2.car))) michael@0: { michael@0: (lst1 = (term1.cdr)); michael@0: (lst2 = (term2.cdr)); michael@0: while (true) { michael@0: if ((lst1 === null)) michael@0: return (lst2 === null); michael@0: else michael@0: if ((lst2 === null)) michael@0: return false; michael@0: else michael@0: if (((one_way_unify1_nboyer((lst1.car), (lst2.car)))!== false)) michael@0: { michael@0: (lst1 = (lst1.cdr)); michael@0: (lst2 = (lst2.cdr)); michael@0: } michael@0: else michael@0: return false; michael@0: } michael@0: } michael@0: else michael@0: return false; michael@0: }; michael@0: (false_term_nboyer = "\u1E9C*"); michael@0: (true_term_nboyer = "\u1E9C*"); michael@0: trans_of_implies1_nboyer = function(n) { michael@0: var sc_n_15; michael@0: return ((sc_isEqual(n, (1)))?(sc_list("\u1E9Cimplies", (0), (1))):(sc_list("\u1E9Cand", (sc_list("\u1E9Cimplies", (n-(1)), n)), ((sc_n_15 = (n-(1))), ((sc_isEqual(sc_n_15, (1)))?(sc_list("\u1E9Cimplies", (0), (1))):(sc_list("\u1E9Cand", (sc_list("\u1E9Cimplies", (sc_n_15-(1)), sc_n_15)), (trans_of_implies1_nboyer((sc_n_15-(1))))))))))); michael@0: }; michael@0: is_term_equal_nboyer = function(x, y) { michael@0: var lst1; michael@0: var lst2; michael@0: var r2; michael@0: var r1; michael@0: if ((x instanceof sc_Pair)) michael@0: if ((y instanceof sc_Pair)) michael@0: if ((((r1 = (x.car)), (r2 = (y.car)), (r1===r2))!== false)) michael@0: { michael@0: (lst1 = (x.cdr)); michael@0: (lst2 = (y.cdr)); michael@0: while (true) { michael@0: if ((lst1 === null)) michael@0: return (lst2 === null); michael@0: else michael@0: if ((lst2 === null)) michael@0: return false; michael@0: else michael@0: if (((is_term_equal_nboyer((lst1.car), (lst2.car)))!== false)) michael@0: { michael@0: (lst1 = (lst1.cdr)); michael@0: (lst2 = (lst2.cdr)); michael@0: } michael@0: else michael@0: return false; michael@0: } michael@0: } michael@0: else michael@0: return false; michael@0: else michael@0: return false; michael@0: else michael@0: return (sc_isEqual(x, y)); michael@0: }; michael@0: is_term_member_nboyer = function(x, lst) { michael@0: var x; michael@0: var lst; michael@0: while (true) { michael@0: if ((lst === null)) michael@0: return false; michael@0: else michael@0: if (((is_term_equal_nboyer(x, (lst.car)))!== false)) michael@0: return true; michael@0: else michael@0: (lst = (lst.cdr)); michael@0: } michael@0: }; michael@0: BgL_setupzd2boyerzd2 = function() { michael@0: var symbol_record; michael@0: var value; michael@0: var BgL_sc_symbolzd2record_16zd2; michael@0: var sym; michael@0: var sc_sym_17; michael@0: var term; michael@0: var lst; michael@0: var sc_term_18; michael@0: var sc_term_19; michael@0: { michael@0: (BgL_sc_za2symbolzd2recordszd2alistza2_2z00_nboyer = null); michael@0: (if_constructor_nboyer = (BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer("\u1E9Cif"))); michael@0: (false_term_nboyer = ((sc_term_19 = (new sc_Pair("\u1E9Cf",null))), (!(sc_term_19 instanceof sc_Pair)?sc_term_19:(new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((sc_term_19.car))), (translate_args_nboyer((sc_term_19.cdr)))))))); michael@0: (true_term_nboyer = ((sc_term_18 = (new sc_Pair("\u1E9Ct",null))), (!(sc_term_18 instanceof sc_Pair)?sc_term_18:(new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((sc_term_18.car))), (translate_args_nboyer((sc_term_18.cdr)))))))); michael@0: (lst = sc_const_3_nboyer); michael@0: while (!(lst === null)) { michael@0: { michael@0: (term = (lst.car)); michael@0: if (((term instanceof sc_Pair)&&(((term.car)==="\u1E9Cequal")&&((term.cdr.car) instanceof sc_Pair)))) michael@0: { michael@0: (sc_sym_17 = ((term.cdr.car).car)); michael@0: (value = (new sc_Pair((!(term instanceof sc_Pair)?term:(new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((term.car))), (translate_args_nboyer((term.cdr)))))), ((sym = ((term.cdr.car).car)), (BgL_sc_symbolzd2record_16zd2 = (BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer(sym))), (BgL_sc_symbolzd2record_16zd2[(1)]))))); michael@0: (symbol_record = (BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer(sc_sym_17))); michael@0: (symbol_record[(1)] = value); michael@0: } michael@0: else michael@0: (sc_error("ADD-LEMMA did not like term: ", term)); michael@0: (lst = (lst.cdr)); michael@0: } michael@0: } michael@0: return true; michael@0: } michael@0: }; michael@0: BgL_testzd2boyerzd2 = function(n) { michael@0: var optrOpnd; michael@0: var term; michael@0: var sc_n_20; michael@0: var answer; michael@0: var sc_term_21; michael@0: var sc_term_22; michael@0: { michael@0: (rewrite_count_nboyer = (0)); michael@0: (term = sc_const_4_nboyer); michael@0: (sc_n_20 = n); michael@0: while (!(sc_n_20=== 0)) { michael@0: { michael@0: (term = (sc_list("\u1E9Cor", term, (new sc_Pair("\u1E9Cf",null))))); michael@0: (--sc_n_20); michael@0: } michael@0: } michael@0: (sc_term_22 = term); michael@0: if (!(sc_term_22 instanceof sc_Pair)) michael@0: (optrOpnd = sc_term_22); michael@0: else michael@0: (optrOpnd = (new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((sc_term_22.car))), (translate_args_nboyer((sc_term_22.cdr)))))); michael@0: (sc_term_21 = (apply_subst_nboyer(((const_nboyer === null)?null:(new sc_Pair((new sc_Pair((const_nboyer.car.car), (translate_term_nboyer((const_nboyer.car.cdr))))), (translate_alist_nboyer((const_nboyer.cdr)))))), optrOpnd))); michael@0: (answer = (tautologyp_nboyer((rewrite_nboyer(sc_term_21)), null, null))); michael@0: (sc_write(rewrite_count_nboyer)); michael@0: (sc_display(" rewrites")); michael@0: (sc_newline()); michael@0: if ((answer!== false)) michael@0: return rewrite_count_nboyer; michael@0: else michael@0: return false; michael@0: } michael@0: }; michael@0: } michael@0: /* Exported Variables */ michael@0: var BgL_parsezd2ze3nbzd2treesze3; michael@0: var BgL_earleyzd2benchmarkzd2; michael@0: var BgL_parsezd2ze3parsedzf3zc2; michael@0: var test; michael@0: var BgL_parsezd2ze3treesz31; michael@0: var BgL_makezd2parserzd2; michael@0: /* End Exports */ michael@0: michael@0: var const_earley; michael@0: { michael@0: (const_earley = (new sc_Pair((new sc_Pair("\u1E9Cs",(new sc_Pair((new sc_Pair("\u1E9Ca",null)),(new sc_Pair((new sc_Pair("\u1E9Cs",(new sc_Pair("\u1E9Cs",null)))),null)))))),null))); michael@0: BgL_makezd2parserzd2 = function(grammar, lexer) { michael@0: var i; michael@0: var parser_descr; michael@0: var def_loop; michael@0: var nb_nts; michael@0: var names; michael@0: var steps; michael@0: var predictors; michael@0: var enders; michael@0: var starters; michael@0: var nts; michael@0: var sc_names_1; michael@0: var sc_steps_2; michael@0: var sc_predictors_3; michael@0: var sc_enders_4; michael@0: var sc_starters_5; michael@0: var nb_confs; michael@0: var BgL_sc_defzd2loop_6zd2; michael@0: var BgL_sc_nbzd2nts_7zd2; michael@0: var sc_nts_8; michael@0: var BgL_sc_defzd2loop_9zd2; michael@0: var ind; michael@0: { michael@0: ind = function(nt, sc_nts_10) { michael@0: var i; michael@0: { michael@0: (i = ((sc_nts_10.length)-(1))); michael@0: while (true) { michael@0: if ((i>=(0))) michael@0: if ((sc_isEqual((sc_nts_10[i]), nt))) michael@0: return i; michael@0: else michael@0: (--i); michael@0: else michael@0: return false; michael@0: } michael@0: } michael@0: }; michael@0: (sc_nts_8 = ((BgL_sc_defzd2loop_9zd2 = function(defs, sc_nts_11) { michael@0: var rule_loop; michael@0: var head; michael@0: var def; michael@0: return ((defs instanceof sc_Pair)?((def = (defs.car)), (head = (def.car)), (rule_loop = function(rules, sc_nts_12) { michael@0: var nt; michael@0: var l; michael@0: var sc_nts_13; michael@0: var rule; michael@0: if ((rules instanceof sc_Pair)) michael@0: { michael@0: (rule = (rules.car)); michael@0: (l = rule); michael@0: (sc_nts_13 = sc_nts_12); michael@0: while ((l instanceof sc_Pair)) { michael@0: { michael@0: (nt = (l.car)); michael@0: (l = (l.cdr)); michael@0: (sc_nts_13 = (((sc_member(nt, sc_nts_13))!== false)?sc_nts_13:(new sc_Pair(nt, sc_nts_13)))); michael@0: } michael@0: } michael@0: return (rule_loop((rules.cdr), sc_nts_13)); michael@0: } michael@0: else michael@0: return (BgL_sc_defzd2loop_9zd2((defs.cdr), sc_nts_12)); michael@0: }), (rule_loop((def.cdr), (((sc_member(head, sc_nts_11))!== false)?sc_nts_11:(new sc_Pair(head, sc_nts_11)))))):(sc_list2vector((sc_reverse(sc_nts_11))))); michael@0: }), (BgL_sc_defzd2loop_9zd2(grammar, null)))); michael@0: (BgL_sc_nbzd2nts_7zd2 = (sc_nts_8.length)); michael@0: (nb_confs = (((BgL_sc_defzd2loop_6zd2 = function(defs, BgL_sc_nbzd2confs_14zd2) { michael@0: var rule_loop; michael@0: var def; michael@0: return ((defs instanceof sc_Pair)?((def = (defs.car)), (rule_loop = function(rules, BgL_sc_nbzd2confs_15zd2) { michael@0: var l; michael@0: var BgL_sc_nbzd2confs_16zd2; michael@0: var rule; michael@0: if ((rules instanceof sc_Pair)) michael@0: { michael@0: (rule = (rules.car)); michael@0: (l = rule); michael@0: (BgL_sc_nbzd2confs_16zd2 = BgL_sc_nbzd2confs_15zd2); michael@0: while ((l instanceof sc_Pair)) { michael@0: { michael@0: (l = (l.cdr)); michael@0: (++BgL_sc_nbzd2confs_16zd2); michael@0: } michael@0: } michael@0: return (rule_loop((rules.cdr), (BgL_sc_nbzd2confs_16zd2+(1)))); michael@0: } michael@0: else michael@0: return (BgL_sc_defzd2loop_6zd2((defs.cdr), BgL_sc_nbzd2confs_15zd2)); michael@0: }), (rule_loop((def.cdr), BgL_sc_nbzd2confs_14zd2))):BgL_sc_nbzd2confs_14zd2); michael@0: }), (BgL_sc_defzd2loop_6zd2(grammar, (0))))+BgL_sc_nbzd2nts_7zd2)); michael@0: (sc_starters_5 = (sc_makeVector(BgL_sc_nbzd2nts_7zd2, null))); michael@0: (sc_enders_4 = (sc_makeVector(BgL_sc_nbzd2nts_7zd2, null))); michael@0: (sc_predictors_3 = (sc_makeVector(BgL_sc_nbzd2nts_7zd2, null))); michael@0: (sc_steps_2 = (sc_makeVector(nb_confs, false))); michael@0: (sc_names_1 = (sc_makeVector(nb_confs, false))); michael@0: (nts = sc_nts_8); michael@0: (starters = sc_starters_5); michael@0: (enders = sc_enders_4); michael@0: (predictors = sc_predictors_3); michael@0: (steps = sc_steps_2); michael@0: (names = sc_names_1); michael@0: (nb_nts = (sc_nts_8.length)); michael@0: (i = (nb_nts-(1))); michael@0: while ((i>=(0))) { michael@0: { michael@0: (sc_steps_2[i] = (i-nb_nts)); michael@0: (sc_names_1[i] = (sc_list((sc_nts_8[i]), (0)))); michael@0: (sc_enders_4[i] = (sc_list(i))); michael@0: (--i); michael@0: } michael@0: } michael@0: def_loop = function(defs, conf) { michael@0: var rule_loop; michael@0: var head; michael@0: var def; michael@0: return ((defs instanceof sc_Pair)?((def = (defs.car)), (head = (def.car)), (rule_loop = function(rules, conf, rule_num) { michael@0: var i; michael@0: var sc_i_17; michael@0: var nt; michael@0: var l; michael@0: var sc_conf_18; michael@0: var sc_i_19; michael@0: var rule; michael@0: if ((rules instanceof sc_Pair)) michael@0: { michael@0: (rule = (rules.car)); michael@0: (names[conf] = (sc_list(head, rule_num))); michael@0: (sc_i_19 = (ind(head, nts))); michael@0: (starters[sc_i_19] = (new sc_Pair(conf, (starters[sc_i_19])))); michael@0: (l = rule); michael@0: (sc_conf_18 = conf); michael@0: while ((l instanceof sc_Pair)) { michael@0: { michael@0: (nt = (l.car)); michael@0: (steps[sc_conf_18] = (ind(nt, nts))); michael@0: (sc_i_17 = (ind(nt, nts))); michael@0: (predictors[sc_i_17] = (new sc_Pair(sc_conf_18, (predictors[sc_i_17])))); michael@0: (l = (l.cdr)); michael@0: (++sc_conf_18); michael@0: } michael@0: } michael@0: (steps[sc_conf_18] = ((ind(head, nts))-nb_nts)); michael@0: (i = (ind(head, nts))); michael@0: (enders[i] = (new sc_Pair(sc_conf_18, (enders[i])))); michael@0: return (rule_loop((rules.cdr), (sc_conf_18+(1)), (rule_num+(1)))); michael@0: } michael@0: else michael@0: return (def_loop((defs.cdr), conf)); michael@0: }), (rule_loop((def.cdr), conf, (1)))):undefined); michael@0: }; michael@0: (def_loop(grammar, (sc_nts_8.length))); michael@0: (parser_descr = [lexer, sc_nts_8, sc_starters_5, sc_enders_4, sc_predictors_3, sc_steps_2, sc_names_1]); michael@0: return function(input) { michael@0: var optrOpnd; michael@0: var sc_optrOpnd_20; michael@0: var sc_optrOpnd_21; michael@0: var sc_optrOpnd_22; michael@0: var loop1; michael@0: var BgL_sc_stateza2_23za2; michael@0: var toks; michael@0: var BgL_sc_nbzd2nts_24zd2; michael@0: var sc_steps_25; michael@0: var sc_enders_26; michael@0: var state_num; michael@0: var BgL_sc_statesza2_27za2; michael@0: var states; michael@0: var i; michael@0: var conf; michael@0: var l; michael@0: var tok_nts; michael@0: var sc_i_28; michael@0: var sc_i_29; michael@0: var l1; michael@0: var l2; michael@0: var tok; michael@0: var tail1129; michael@0: var L1125; michael@0: var goal_enders; michael@0: var BgL_sc_statesza2_30za2; michael@0: var BgL_sc_nbzd2nts_31zd2; michael@0: var BgL_sc_nbzd2confs_32zd2; michael@0: var nb_toks; michael@0: var goal_starters; michael@0: var sc_states_33; michael@0: var BgL_sc_nbzd2confs_34zd2; michael@0: var BgL_sc_nbzd2toks_35zd2; michael@0: var sc_toks_36; michael@0: var falseHead1128; michael@0: var sc_names_37; michael@0: var sc_steps_38; michael@0: var sc_predictors_39; michael@0: var sc_enders_40; michael@0: var sc_starters_41; michael@0: var sc_nts_42; michael@0: var lexer; michael@0: var sc_ind_43; michael@0: var make_states; michael@0: var BgL_sc_confzd2setzd2getza2_44za2; michael@0: var conf_set_merge_new_bang; michael@0: var conf_set_adjoin; michael@0: var BgL_sc_confzd2setzd2adjoinza2_45za2; michael@0: var BgL_sc_confzd2setzd2adjoinza2za2_46z00; michael@0: var conf_set_union; michael@0: var forw; michael@0: var is_parsed; michael@0: var deriv_trees; michael@0: var BgL_sc_derivzd2treesza2_47z70; michael@0: var nb_deriv_trees; michael@0: var BgL_sc_nbzd2derivzd2treesza2_48za2; michael@0: { michael@0: sc_ind_43 = function(nt, sc_nts_49) { michael@0: var i; michael@0: { michael@0: (i = ((sc_nts_49.length)-(1))); michael@0: while (true) { michael@0: if ((i>=(0))) michael@0: if ((sc_isEqual((sc_nts_49[i]), nt))) michael@0: return i; michael@0: else michael@0: (--i); michael@0: else michael@0: return false; michael@0: } michael@0: } michael@0: }; michael@0: make_states = function(BgL_sc_nbzd2toks_50zd2, BgL_sc_nbzd2confs_51zd2) { michael@0: var v; michael@0: var i; michael@0: var sc_states_52; michael@0: { michael@0: (sc_states_52 = (sc_makeVector((BgL_sc_nbzd2toks_50zd2+(1)), false))); michael@0: (i = BgL_sc_nbzd2toks_50zd2); michael@0: while ((i>=(0))) { michael@0: { michael@0: (v = (sc_makeVector((BgL_sc_nbzd2confs_51zd2+(1)), false))); michael@0: (v[(0)] = (-1)); michael@0: (sc_states_52[i] = v); michael@0: (--i); michael@0: } michael@0: } michael@0: return sc_states_52; michael@0: } michael@0: }; michael@0: BgL_sc_confzd2setzd2getza2_44za2 = function(state, BgL_sc_statezd2num_53zd2, sc_conf_54) { michael@0: var conf_set; michael@0: var BgL_sc_confzd2set_55zd2; michael@0: 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))); michael@0: }; michael@0: conf_set_merge_new_bang = function(conf_set) { michael@0: return ((conf_set[((conf_set[(1)])+(5))] = (conf_set[(4)])), (conf_set[(1)] = (conf_set[(3)])), (conf_set[(3)] = (-1)), (conf_set[(4)] = (-1))); michael@0: }; michael@0: conf_set_adjoin = function(state, conf_set, sc_conf_56, i) { michael@0: var tail; michael@0: 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)); michael@0: }; michael@0: BgL_sc_confzd2setzd2adjoinza2_45za2 = function(sc_states_57, BgL_sc_statezd2num_58zd2, l, i) { michael@0: var conf_set; michael@0: var sc_conf_59; michael@0: var l1; michael@0: var state; michael@0: { michael@0: (state = (sc_states_57[BgL_sc_statezd2num_58zd2])); michael@0: (l1 = l); michael@0: while ((l1 instanceof sc_Pair)) { michael@0: { michael@0: (sc_conf_59 = (l1.car)); michael@0: (conf_set = (BgL_sc_confzd2setzd2getza2_44za2(state, BgL_sc_statezd2num_58zd2, sc_conf_59))); michael@0: if (((conf_set[(i+(5))])=== false)) michael@0: { michael@0: (conf_set_adjoin(state, conf_set, sc_conf_59, i)); michael@0: (l1 = (l1.cdr)); michael@0: } michael@0: else michael@0: (l1 = (l1.cdr)); michael@0: } michael@0: } michael@0: return undefined; michael@0: } michael@0: }; michael@0: BgL_sc_confzd2setzd2adjoinza2za2_46z00 = function(sc_states_60, BgL_sc_statesza2_61za2, BgL_sc_statezd2num_62zd2, sc_conf_63, i) { michael@0: var BgL_sc_confzd2setza2_64z70; michael@0: var BgL_sc_stateza2_65za2; michael@0: var conf_set; michael@0: var state; michael@0: return ((state = (sc_states_60[BgL_sc_statezd2num_62zd2])), ((((conf_set = (state[(sc_conf_63+(1))])), ((conf_set!== false)?(conf_set[(i+(5))]):false))!== false)?((BgL_sc_stateza2_65za2 = (BgL_sc_statesza2_61za2[BgL_sc_statezd2num_62zd2])), (BgL_sc_confzd2setza2_64z70 = (BgL_sc_confzd2setzd2getza2_44za2(BgL_sc_stateza2_65za2, BgL_sc_statezd2num_62zd2, sc_conf_63))), (((BgL_sc_confzd2setza2_64z70[(i+(5))])=== false)?(conf_set_adjoin(BgL_sc_stateza2_65za2, BgL_sc_confzd2setza2_64z70, sc_conf_63, i)):undefined), true):false)); michael@0: }; michael@0: conf_set_union = function(state, conf_set, sc_conf_66, other_set) { michael@0: var i; michael@0: { michael@0: (i = (other_set[(2)])); michael@0: while ((i>=(0))) { michael@0: if (((conf_set[(i+(5))])=== false)) michael@0: { michael@0: (conf_set_adjoin(state, conf_set, sc_conf_66, i)); michael@0: (i = (other_set[(i+(5))])); michael@0: } michael@0: else michael@0: (i = (other_set[(i+(5))])); michael@0: } michael@0: return undefined; michael@0: } michael@0: }; michael@0: forw = function(sc_states_67, BgL_sc_statezd2num_68zd2, sc_starters_69, sc_enders_70, sc_predictors_71, sc_steps_72, sc_nts_73) { michael@0: var next_set; michael@0: var next; michael@0: var conf_set; michael@0: var ender; michael@0: var l; michael@0: var starter_set; michael@0: var starter; michael@0: var sc_l_74; michael@0: var sc_loop1_75; michael@0: var head; michael@0: var BgL_sc_confzd2set_76zd2; michael@0: var BgL_sc_statezd2num_77zd2; michael@0: var state; michael@0: var sc_states_78; michael@0: var preds; michael@0: var BgL_sc_confzd2set_79zd2; michael@0: var step; michael@0: var sc_conf_80; michael@0: var BgL_sc_nbzd2nts_81zd2; michael@0: var sc_state_82; michael@0: { michael@0: (sc_state_82 = (sc_states_67[BgL_sc_statezd2num_68zd2])); michael@0: (BgL_sc_nbzd2nts_81zd2 = (sc_nts_73.length)); michael@0: while (true) { michael@0: { michael@0: (sc_conf_80 = (sc_state_82[(0)])); michael@0: if ((sc_conf_80>=(0))) michael@0: { michael@0: (step = (sc_steps_72[sc_conf_80])); michael@0: (BgL_sc_confzd2set_79zd2 = (sc_state_82[(sc_conf_80+(1))])); michael@0: (head = (BgL_sc_confzd2set_79zd2[(4)])); michael@0: (sc_state_82[(0)] = (BgL_sc_confzd2set_79zd2[(0)])); michael@0: (conf_set_merge_new_bang(BgL_sc_confzd2set_79zd2)); michael@0: if ((step>=(0))) michael@0: { michael@0: (sc_l_74 = (sc_starters_69[step])); michael@0: while ((sc_l_74 instanceof sc_Pair)) { michael@0: { michael@0: (starter = (sc_l_74.car)); michael@0: (starter_set = (BgL_sc_confzd2setzd2getza2_44za2(sc_state_82, BgL_sc_statezd2num_68zd2, starter))); michael@0: if (((starter_set[(BgL_sc_statezd2num_68zd2+(5))])=== false)) michael@0: { michael@0: (conf_set_adjoin(sc_state_82, starter_set, starter, BgL_sc_statezd2num_68zd2)); michael@0: (sc_l_74 = (sc_l_74.cdr)); michael@0: } michael@0: else michael@0: (sc_l_74 = (sc_l_74.cdr)); michael@0: } michael@0: } michael@0: (l = (sc_enders_70[step])); michael@0: while ((l instanceof sc_Pair)) { michael@0: { michael@0: (ender = (l.car)); michael@0: if ((((conf_set = (sc_state_82[(ender+(1))])), ((conf_set!== false)?(conf_set[(BgL_sc_statezd2num_68zd2+(5))]):false))!== false)) michael@0: { michael@0: (next = (sc_conf_80+(1))); michael@0: (next_set = (BgL_sc_confzd2setzd2getza2_44za2(sc_state_82, BgL_sc_statezd2num_68zd2, next))); michael@0: (conf_set_union(sc_state_82, next_set, next, BgL_sc_confzd2set_79zd2)); michael@0: (l = (l.cdr)); michael@0: } michael@0: else michael@0: (l = (l.cdr)); michael@0: } michael@0: } michael@0: } michael@0: else michael@0: { michael@0: (preds = (sc_predictors_71[(step+BgL_sc_nbzd2nts_81zd2)])); michael@0: (sc_states_78 = sc_states_67); michael@0: (state = sc_state_82); michael@0: (BgL_sc_statezd2num_77zd2 = BgL_sc_statezd2num_68zd2); michael@0: (BgL_sc_confzd2set_76zd2 = BgL_sc_confzd2set_79zd2); michael@0: sc_loop1_75 = function(l) { michael@0: var sc_state_83; michael@0: var BgL_sc_nextzd2set_84zd2; michael@0: var sc_next_85; michael@0: var pred_set; michael@0: var i; michael@0: var pred; michael@0: if ((l instanceof sc_Pair)) michael@0: { michael@0: (pred = (l.car)); michael@0: (i = head); michael@0: while ((i>=(0))) { michael@0: { michael@0: (pred_set = ((sc_state_83 = (sc_states_78[i])), (sc_state_83[(pred+(1))]))); michael@0: if ((pred_set!== false)) michael@0: { michael@0: (sc_next_85 = (pred+(1))); michael@0: (BgL_sc_nextzd2set_84zd2 = (BgL_sc_confzd2setzd2getza2_44za2(state, BgL_sc_statezd2num_77zd2, sc_next_85))); michael@0: (conf_set_union(state, BgL_sc_nextzd2set_84zd2, sc_next_85, pred_set)); michael@0: } michael@0: (i = (BgL_sc_confzd2set_76zd2[(i+(5))])); michael@0: } michael@0: } michael@0: return (sc_loop1_75((l.cdr))); michael@0: } michael@0: else michael@0: return undefined; michael@0: }; michael@0: (sc_loop1_75(preds)); michael@0: } michael@0: } michael@0: else michael@0: return undefined; michael@0: } michael@0: } michael@0: } michael@0: }; michael@0: is_parsed = function(nt, i, j, sc_nts_86, sc_enders_87, sc_states_88) { michael@0: var conf_set; michael@0: var state; michael@0: var sc_conf_89; michael@0: var l; michael@0: var BgL_sc_ntza2_90za2; michael@0: { michael@0: (BgL_sc_ntza2_90za2 = (sc_ind_43(nt, sc_nts_86))); michael@0: if ((BgL_sc_ntza2_90za2!== false)) michael@0: { michael@0: (sc_nts_86.length); michael@0: (l = (sc_enders_87[BgL_sc_ntza2_90za2])); michael@0: while (true) { michael@0: if ((l instanceof sc_Pair)) michael@0: { michael@0: (sc_conf_89 = (l.car)); michael@0: if ((((state = (sc_states_88[j])), (conf_set = (state[(sc_conf_89+(1))])), ((conf_set!== false)?(conf_set[(i+(5))]):false))!== false)) michael@0: return true; michael@0: else michael@0: (l = (l.cdr)); michael@0: } michael@0: else michael@0: return false; michael@0: } michael@0: } michael@0: else michael@0: return false; michael@0: } michael@0: }; michael@0: deriv_trees = function(sc_conf_91, i, j, sc_enders_92, sc_steps_93, sc_names_94, sc_toks_95, sc_states_96, BgL_sc_nbzd2nts_97zd2) { michael@0: var sc_loop1_98; michael@0: var prev; michael@0: var name; michael@0: return ((name = (sc_names_94[sc_conf_91])), ((name!== false)?((sc_conf_91=(0))) michael@0: if (((k>=i)&&(((sc_state_99 = (sc_states_96[k])), (conf_set = (sc_state_99[(prev+(1))])), ((conf_set!== false)?(conf_set[(i+(5))]):false))!== false))) michael@0: { michael@0: (prev_trees = (deriv_trees(prev, i, k, sc_enders_92, sc_steps_93, sc_names_94, sc_toks_95, sc_states_96, BgL_sc_nbzd2nts_97zd2))); michael@0: (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))); michael@0: loop3 = function(l3, l2) { michael@0: var l4; michael@0: var sc_l2_100; michael@0: var ender_tree; michael@0: if ((l3 instanceof sc_Pair)) michael@0: { michael@0: (ender_tree = (sc_list((l3.car)))); michael@0: (l4 = prev_trees); michael@0: (sc_l2_100 = l2); michael@0: while ((l4 instanceof sc_Pair)) { michael@0: { michael@0: (sc_l2_100 = (new sc_Pair((sc_append((l4.car), ender_tree)), sc_l2_100))); michael@0: (l4 = (l4.cdr)); michael@0: } michael@0: } michael@0: return (loop3((l3.cdr), sc_l2_100)); michael@0: } michael@0: else michael@0: return (loop2((ender_set[(k+(5))]), l2)); michael@0: }; michael@0: return (loop3(ender_trees, l2)); michael@0: } michael@0: else michael@0: (k = (ender_set[(k+(5))])); michael@0: else michael@0: return (sc_loop1_98((l1.cdr), l2)); michael@0: } michael@0: }; michael@0: return (loop2((ender_set[(2)]), l2)); michael@0: } michael@0: else michael@0: (l1 = (l1.cdr)); michael@0: } michael@0: else michael@0: return l2; michael@0: } michael@0: }), (sc_loop1_98((sc_enders_92[(sc_steps_93[prev])]), null))))); michael@0: }; michael@0: BgL_sc_derivzd2treesza2_47z70 = function(nt, i, j, sc_nts_101, sc_enders_102, sc_steps_103, sc_names_104, sc_toks_105, sc_states_106) { michael@0: var conf_set; michael@0: var state; michael@0: var sc_conf_107; michael@0: var l; michael@0: var trees; michael@0: var BgL_sc_nbzd2nts_108zd2; michael@0: var BgL_sc_ntza2_109za2; michael@0: { michael@0: (BgL_sc_ntza2_109za2 = (sc_ind_43(nt, sc_nts_101))); michael@0: if ((BgL_sc_ntza2_109za2!== false)) michael@0: { michael@0: (BgL_sc_nbzd2nts_108zd2 = (sc_nts_101.length)); michael@0: (l = (sc_enders_102[BgL_sc_ntza2_109za2])); michael@0: (trees = null); michael@0: while ((l instanceof sc_Pair)) { michael@0: { michael@0: (sc_conf_107 = (l.car)); michael@0: if ((((state = (sc_states_106[j])), (conf_set = (state[(sc_conf_107+(1))])), ((conf_set!== false)?(conf_set[(i+(5))]):false))!== false)) michael@0: { michael@0: (l = (l.cdr)); michael@0: (trees = (sc_append((deriv_trees(sc_conf_107, i, j, sc_enders_102, sc_steps_103, sc_names_104, sc_toks_105, sc_states_106, BgL_sc_nbzd2nts_108zd2)), trees))); michael@0: } michael@0: else michael@0: (l = (l.cdr)); michael@0: } michael@0: } michael@0: return trees; michael@0: } michael@0: else michael@0: return false; michael@0: } michael@0: }; michael@0: 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) { michael@0: var sc_loop1_116; michael@0: var tmp1124; michael@0: var prev; michael@0: return ((prev = (sc_conf_110-(1))), ((((tmp1124 = (sc_conf_110=(0))) { michael@0: if (((k>=i)&&(((state = (sc_states_114[k])), (conf_set = (state[(prev+(1))])), ((conf_set!== false)?(conf_set[(i+(5))]):false))!== false))) michael@0: { michael@0: (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))); michael@0: (nb_ender_trees = (nb_deriv_trees(ender, k, j, sc_enders_111, sc_steps_112, sc_toks_113, sc_states_114, BgL_sc_nbzd2nts_115zd2))); michael@0: (k = (ender_set[(k+(5))])); michael@0: (n +=(nb_prev_trees*nb_ender_trees)); michael@0: } michael@0: else michael@0: (k = (ender_set[(k+(5))])); michael@0: } michael@0: return (sc_loop1_116((l.cdr), n)); michael@0: } michael@0: else michael@0: (l = (l.cdr)); michael@0: } michael@0: else michael@0: return sc_n_118; michael@0: } michael@0: }), (sc_loop1_116((sc_enders_111[(sc_steps_112[prev])]), (0)))))); michael@0: }; michael@0: BgL_sc_nbzd2derivzd2treesza2_48za2 = function(nt, i, j, sc_nts_119, sc_enders_120, sc_steps_121, sc_toks_122, sc_states_123) { michael@0: var conf_set; michael@0: var state; michael@0: var sc_conf_124; michael@0: var l; michael@0: var nb_trees; michael@0: var BgL_sc_nbzd2nts_125zd2; michael@0: var BgL_sc_ntza2_126za2; michael@0: { michael@0: (BgL_sc_ntza2_126za2 = (sc_ind_43(nt, sc_nts_119))); michael@0: if ((BgL_sc_ntza2_126za2!== false)) michael@0: { michael@0: (BgL_sc_nbzd2nts_125zd2 = (sc_nts_119.length)); michael@0: (l = (sc_enders_120[BgL_sc_ntza2_126za2])); michael@0: (nb_trees = (0)); michael@0: while ((l instanceof sc_Pair)) { michael@0: { michael@0: (sc_conf_124 = (l.car)); michael@0: if ((((state = (sc_states_123[j])), (conf_set = (state[(sc_conf_124+(1))])), ((conf_set!== false)?(conf_set[(i+(5))]):false))!== false)) michael@0: { michael@0: (l = (l.cdr)); michael@0: (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)); michael@0: } michael@0: else michael@0: (l = (l.cdr)); michael@0: } michael@0: } michael@0: return nb_trees; michael@0: } michael@0: else michael@0: return false; michael@0: } michael@0: }; michael@0: (lexer = (parser_descr[(0)])); michael@0: (sc_nts_42 = (parser_descr[(1)])); michael@0: (sc_starters_41 = (parser_descr[(2)])); michael@0: (sc_enders_40 = (parser_descr[(3)])); michael@0: (sc_predictors_39 = (parser_descr[(4)])); michael@0: (sc_steps_38 = (parser_descr[(5)])); michael@0: (sc_names_37 = (parser_descr[(6)])); michael@0: (falseHead1128 = (new sc_Pair(null, null))); michael@0: (L1125 = (lexer(input))); michael@0: (tail1129 = falseHead1128); michael@0: while (!(L1125 === null)) { michael@0: { michael@0: (tok = (L1125.car)); michael@0: (l1 = (tok.cdr)); michael@0: (l2 = null); michael@0: while ((l1 instanceof sc_Pair)) { michael@0: { michael@0: (sc_i_29 = (sc_ind_43((l1.car), sc_nts_42))); michael@0: if ((sc_i_29!== false)) michael@0: { michael@0: (l1 = (l1.cdr)); michael@0: (l2 = (new sc_Pair(sc_i_29, l2))); michael@0: } michael@0: else michael@0: (l1 = (l1.cdr)); michael@0: } michael@0: } michael@0: (sc_optrOpnd_22 = (new sc_Pair((tok.car), (sc_reverse(l2))))); michael@0: (sc_optrOpnd_21 = (new sc_Pair(sc_optrOpnd_22, null))); michael@0: (tail1129.cdr = sc_optrOpnd_21); michael@0: (tail1129 = (tail1129.cdr)); michael@0: (L1125 = (L1125.cdr)); michael@0: } michael@0: } michael@0: (sc_optrOpnd_20 = (falseHead1128.cdr)); michael@0: (sc_toks_36 = (sc_list2vector(sc_optrOpnd_20))); michael@0: (BgL_sc_nbzd2toks_35zd2 = (sc_toks_36.length)); michael@0: (BgL_sc_nbzd2confs_34zd2 = (sc_steps_38.length)); michael@0: (sc_states_33 = (make_states(BgL_sc_nbzd2toks_35zd2, BgL_sc_nbzd2confs_34zd2))); michael@0: (goal_starters = (sc_starters_41[(0)])); michael@0: (BgL_sc_confzd2setzd2adjoinza2_45za2(sc_states_33, (0), goal_starters, (0))); michael@0: (forw(sc_states_33, (0), sc_starters_41, sc_enders_40, sc_predictors_39, sc_steps_38, sc_nts_42)); michael@0: (sc_i_28 = (0)); michael@0: while ((sc_i_28=(0))) { michael@0: { michael@0: (states = sc_states_33); michael@0: (BgL_sc_statesza2_27za2 = BgL_sc_statesza2_30za2); michael@0: (state_num = i); michael@0: (sc_enders_26 = sc_enders_40); michael@0: (sc_steps_25 = sc_steps_38); michael@0: (BgL_sc_nbzd2nts_24zd2 = BgL_sc_nbzd2nts_31zd2); michael@0: (toks = sc_toks_36); michael@0: (BgL_sc_stateza2_23za2 = (BgL_sc_statesza2_30za2[i])); michael@0: loop1 = function() { michael@0: var sc_loop1_127; michael@0: var prev; michael@0: var BgL_sc_statesza2_128za2; michael@0: var sc_states_129; michael@0: var j; michael@0: var i; michael@0: var sc_i_130; michael@0: var head; michael@0: var conf_set; michael@0: var sc_conf_131; michael@0: { michael@0: (sc_conf_131 = (BgL_sc_stateza2_23za2[(0)])); michael@0: if ((sc_conf_131>=(0))) michael@0: { michael@0: (conf_set = (BgL_sc_stateza2_23za2[(sc_conf_131+(1))])); michael@0: (head = (conf_set[(4)])); michael@0: (BgL_sc_stateza2_23za2[(0)] = (conf_set[(0)])); michael@0: (conf_set_merge_new_bang(conf_set)); michael@0: (sc_i_130 = head); michael@0: while ((sc_i_130>=(0))) { michael@0: { michael@0: (i = sc_i_130); michael@0: (j = state_num); michael@0: (sc_states_129 = states); michael@0: (BgL_sc_statesza2_128za2 = BgL_sc_statesza2_27za2); michael@0: (prev = (sc_conf_131-(1))); michael@0: if (((sc_conf_131>=BgL_sc_nbzd2nts_24zd2)&&((sc_steps_25[prev])>=(0)))) michael@0: { michael@0: sc_loop1_127 = function(l) { michael@0: var k; michael@0: var ender_set; michael@0: var state; michael@0: var ender; michael@0: var l; michael@0: while (true) { michael@0: if ((l instanceof sc_Pair)) michael@0: { michael@0: (ender = (l.car)); michael@0: (ender_set = ((state = (sc_states_129[j])), (state[(ender+(1))]))); michael@0: if ((ender_set!== false)) michael@0: { michael@0: (k = (ender_set[(2)])); michael@0: while ((k>=(0))) { michael@0: { michael@0: if ((k>=i)) michael@0: if (((BgL_sc_confzd2setzd2adjoinza2za2_46z00(sc_states_129, BgL_sc_statesza2_128za2, k, prev, i))!== false)) michael@0: (BgL_sc_confzd2setzd2adjoinza2za2_46z00(sc_states_129, BgL_sc_statesza2_128za2, j, ender, k)); michael@0: (k = (ender_set[(k+(5))])); michael@0: } michael@0: } michael@0: return (sc_loop1_127((l.cdr))); michael@0: } michael@0: else michael@0: (l = (l.cdr)); michael@0: } michael@0: else michael@0: return undefined; michael@0: } michael@0: }; michael@0: (sc_loop1_127((sc_enders_26[(sc_steps_25[prev])]))); michael@0: } michael@0: (sc_i_130 = (conf_set[(sc_i_130+(5))])); michael@0: } michael@0: } michael@0: return (loop1()); michael@0: } michael@0: else michael@0: return undefined; michael@0: } michael@0: }; michael@0: (loop1()); michael@0: (--i); michael@0: } michael@0: } michael@0: (optrOpnd = BgL_sc_statesza2_30za2); michael@0: return [sc_nts_42, sc_starters_41, sc_enders_40, sc_predictors_39, sc_steps_38, sc_names_37, sc_toks_36, optrOpnd, is_parsed, BgL_sc_derivzd2treesza2_47z70, BgL_sc_nbzd2derivzd2treesza2_48za2]; michael@0: } michael@0: }; michael@0: } michael@0: }; michael@0: BgL_parsezd2ze3parsedzf3zc2 = function(parse, nt, i, j) { michael@0: var is_parsed; michael@0: var states; michael@0: var enders; michael@0: var nts; michael@0: return ((nts = (parse[(0)])), (enders = (parse[(2)])), (states = (parse[(7)])), (is_parsed = (parse[(8)])), (is_parsed(nt, i, j, nts, enders, states))); michael@0: }; michael@0: BgL_parsezd2ze3treesz31 = function(parse, nt, i, j) { michael@0: var BgL_sc_derivzd2treesza2_132z70; michael@0: var states; michael@0: var toks; michael@0: var names; michael@0: var steps; michael@0: var enders; michael@0: var nts; michael@0: 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))); michael@0: }; michael@0: BgL_parsezd2ze3nbzd2treesze3 = function(parse, nt, i, j) { michael@0: var BgL_sc_nbzd2derivzd2treesza2_133za2; michael@0: var states; michael@0: var toks; michael@0: var steps; michael@0: var enders; michael@0: var nts; michael@0: return ((nts = (parse[(0)])), (enders = (parse[(2)])), (steps = (parse[(4)])), (toks = (parse[(6)])), (states = (parse[(7)])), (BgL_sc_nbzd2derivzd2treesza2_133za2 = (parse[(10)])), (BgL_sc_nbzd2derivzd2treesza2_133za2(nt, i, j, nts, enders, steps, toks, states))); michael@0: }; michael@0: test = function(k) { michael@0: var x; michael@0: var p; michael@0: return ((p = (BgL_makezd2parserzd2(const_earley, function(l) { michael@0: var sc_x_134; michael@0: var tail1134; michael@0: var L1130; michael@0: var falseHead1133; michael@0: { michael@0: (falseHead1133 = (new sc_Pair(null, null))); michael@0: (tail1134 = falseHead1133); michael@0: (L1130 = l); michael@0: while (!(L1130 === null)) { michael@0: { michael@0: (tail1134.cdr = (new sc_Pair(((sc_x_134 = (L1130.car)), (sc_list(sc_x_134, sc_x_134))), null))); michael@0: (tail1134 = (tail1134.cdr)); michael@0: (L1130 = (L1130.cdr)); michael@0: } michael@0: } michael@0: return (falseHead1133.cdr); michael@0: } michael@0: }))), (x = (p((sc_vector2list((sc_makeVector(k, "\u1E9Ca"))))))), (sc_length((BgL_parsezd2ze3treesz31(x, "\u1E9Cs", (0), k))))); michael@0: }; michael@0: BgL_earleyzd2benchmarkzd2 = function() { michael@0: var args = null; michael@0: for (var sc_tmp = arguments.length - 1; sc_tmp >= 0; sc_tmp--) { michael@0: args = sc_cons(arguments[sc_tmp], args); michael@0: } michael@0: var k; michael@0: return ((k = ((args === null)?(7):(args.car))), (BgL_runzd2benchmarkzd2("earley", (1), function() { michael@0: return (test(k)); michael@0: }, function(result) { michael@0: return ((sc_display(result)), (sc_newline()), result == 132); michael@0: }))); michael@0: }; michael@0: } michael@0: michael@0: michael@0: /************* END OF GENERATED CODE *************/ michael@0: // Invoke this function to run a benchmark. michael@0: // The first argument is a string identifying the benchmark. michael@0: // The second argument is the number of times to run the benchmark. michael@0: // The third argument is a function that runs the benchmark. michael@0: // The fourth argument is a unary function that warns if the result michael@0: // returned by the benchmark is incorrect. michael@0: // michael@0: // Example: michael@0: // RunBenchmark("new Array()", michael@0: // 1, michael@0: // function () { new Array(1000000); } michael@0: // function (v) { michael@0: // return (v instanceof Array) && (v.length == 1000000); michael@0: // }); michael@0: michael@0: SC_DEFAULT_OUT = new sc_GenericOutputPort(function(s) {}); michael@0: SC_ERROR_OUT = SC_DEFAULT_OUT; michael@0: michael@0: function RunBenchmark(name, count, run, warn) { michael@0: for (var n = 0; n < count; ++n) { michael@0: result = run(); michael@0: if (!warn(result)) { michael@0: throw new Error("Earley or Boyer did incorrect number of rewrites"); michael@0: } michael@0: } michael@0: } michael@0: michael@0: var BgL_runzd2benchmarkzd2 = RunBenchmark;