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