earley-boyer.js 204 KB

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