v8-earley-boyer.js 191 KB

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