1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853 |
- (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ohm = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
- var ohm = require('..');
- module.exports = ohm.makeRecipe(["grammar",{"source":"BuiltInRules {\n\n alnum (an alpha-numeric character)\n = letter\n | digit\n\n letter (a letter)\n = lower\n | upper\n | unicodeLtmo\n\n digit (a digit)\n = \"0\"..\"9\"\n\n hexDigit (a hexadecimal digit)\n = digit\n | \"a\"..\"f\"\n | \"A\"..\"F\"\n\n ListOf<elem, sep>\n = NonemptyListOf<elem, sep>\n | EmptyListOf<elem, sep>\n\n NonemptyListOf<elem, sep>\n = elem (sep elem)*\n\n EmptyListOf<elem, sep>\n = /* nothing */\n\n listOf<elem, sep>\n = nonemptyListOf<elem, sep>\n | emptyListOf<elem, sep>\n\n nonemptyListOf<elem, sep>\n = elem (sep elem)*\n\n emptyListOf<elem, sep>\n = /* nothing */\n\n}"},"BuiltInRules",null,null,{"alnum":["define",{"sourceInterval":[18,78]},"an alpha-numeric character",[],["alt",{"sourceInterval":[60,78]},["app",{"sourceInterval":[60,66]},"letter",[]],["app",{"sourceInterval":[73,78]},"digit",[]]]],"letter":["define",{"sourceInterval":[82,142]},"a letter",[],["alt",{"sourceInterval":[107,142]},["app",{"sourceInterval":[107,112]},"lower",[]],["app",{"sourceInterval":[119,124]},"upper",[]],["app",{"sourceInterval":[131,142]},"unicodeLtmo",[]]]],"digit":["define",{"sourceInterval":[146,177]},"a digit",[],["range",{"sourceInterval":[169,177]},"0","9"]],"hexDigit":["define",{"sourceInterval":[181,254]},"a hexadecimal digit",[],["alt",{"sourceInterval":[219,254]},["app",{"sourceInterval":[219,224]},"digit",[]],["range",{"sourceInterval":[231,239]},"a","f"],["range",{"sourceInterval":[246,254]},"A","F"]]],"ListOf":["define",{"sourceInterval":[258,336]},null,["elem","sep"],["alt",{"sourceInterval":[282,336]},["app",{"sourceInterval":[282,307]},"NonemptyListOf",[["param",{},0],["param",{},1]]],["app",{"sourceInterval":[314,336]},"EmptyListOf",[["param",{},0],["param",{},1]]]]],"NonemptyListOf":["define",{"sourceInterval":[340,388]},null,["elem","sep"],["seq",{"sourceInterval":[372,388]},["param",{},0],["star",{"sourceInterval":[377,388]},["seq",{"sourceInterval":[378,386]},["param",{},1],["param",{},0]]]]],"EmptyListOf":["define",{"sourceInterval":[392,434]},null,["elem","sep"],["seq",{"sourceInterval":[438,438]}]],"listOf":["define",{"sourceInterval":[438,516]},null,["elem","sep"],["alt",{"sourceInterval":[462,516]},["app",{"sourceInterval":[462,487]},"nonemptyListOf",[["param",{},0],["param",{},1]]],["app",{"sourceInterval":[494,516]},"emptyListOf",[["param",{},0],["param",{},1]]]]],"nonemptyListOf":["define",{"sourceInterval":[520,568]},null,["elem","sep"],["seq",{"sourceInterval":[552,568]},["param",{},0],["star",{"sourceInterval":[557,568]},["seq",{"sourceInterval":[558,566]},["param",{},1],["param",{},0]]]]],"emptyListOf":["define",{"sourceInterval":[572,614]},null,["elem","sep"],["seq",{"sourceInterval":[616,616]}]]}]);
- },{"..":46}],2:[function(require,module,exports){
- var ohm = require('..');
- module.exports = ohm.makeRecipe(["grammar",{"source":"Ohm {\n\n Grammars\n = Grammar*\n\n Grammar\n = ident SuperGrammar? \"{\" Rule* \"}\"\n\n SuperGrammar\n = \"<:\" ident\n\n Rule\n = ident Formals? ruleDescr? \"=\" RuleBody -- define\n | ident Formals? \":=\" RuleBody -- override\n | ident Formals? \"+=\" RuleBody -- extend\n\n RuleBody\n = \"|\"? NonemptyListOf<TopLevelTerm, \"|\">\n\n TopLevelTerm\n = Seq caseName -- inline\n | Seq\n\n Formals\n = \"<\" ListOf<ident, \",\"> \">\"\n\n Params\n = \"<\" ListOf<Seq, \",\"> \">\"\n\n Alt\n = NonemptyListOf<Seq, \"|\">\n\n Seq\n = Iter*\n\n Iter\n = Pred \"*\" -- star\n | Pred \"+\" -- plus\n | Pred \"?\" -- opt\n | Pred\n\n Pred\n = \"~\" Lex -- not\n | \"&\" Lex -- lookahead\n | Lex\n\n Lex\n = \"#\" Base -- lex\n | Base\n\n Base\n = ident Params? ~(ruleDescr? \"=\" | \":=\" | \"+=\") -- application\n | oneCharTerminal \"..\" oneCharTerminal -- range\n | terminal -- terminal\n | \"(\" Alt \")\" -- paren\n\n ruleDescr (a rule description)\n = \"(\" ruleDescrText \")\"\n\n ruleDescrText\n = (~\")\" any)*\n\n caseName\n = \"--\" (~\"\\n\" space)* name (~\"\\n\" space)* (\"\\n\" | &\"}\")\n\n name (a name)\n = nameFirst nameRest*\n\n nameFirst\n = \"_\"\n | letter\n\n nameRest\n = \"_\"\n | alnum\n\n ident (an identifier)\n = name\n\n terminal\n = \"\\\"\" terminalChar* \"\\\"\"\n\n oneCharTerminal\n = \"\\\"\" terminalChar \"\\\"\"\n\n terminalChar\n = escapeChar\n | ~\"\\\\\" ~\"\\\"\" ~\"\\n\" any\n\n escapeChar (an escape sequence)\n = \"\\\\\\\\\" -- backslash\n | \"\\\\\\\"\" -- doubleQuote\n | \"\\\\\\'\" -- singleQuote\n | \"\\\\b\" -- backspace\n | \"\\\\n\" -- lineFeed\n | \"\\\\r\" -- carriageReturn\n | \"\\\\t\" -- tab\n | \"\\\\u\" hexDigit hexDigit hexDigit hexDigit -- unicodeEscape\n | \"\\\\x\" hexDigit hexDigit -- hexEscape\n\n space\n += comment\n\n comment\n = \"//\" (~\"\\n\" any)* \"\\n\" -- singleLine\n | \"/*\" (~\"*/\" any)* \"*/\" -- multiLine\n\n tokens = token*\n\n token = caseName | comment | ident | operator | punctuation | terminal | any\n\n operator = \"<:\" | \"=\" | \":=\" | \"+=\" | \"*\" | \"+\" | \"?\" | \"~\" | \"&\"\n\n punctuation = \"<\" | \">\" | \",\" | \"--\"\n}"},"Ohm",null,"Grammars",{"Grammars":["define",{"sourceInterval":[9,32]},null,[],["star",{"sourceInterval":[24,32]},["app",{"sourceInterval":[24,31]},"Grammar",[]]]],"Grammar":["define",{"sourceInterval":[36,83]},null,[],["seq",{"sourceInterval":[50,83]},["app",{"sourceInterval":[50,55]},"ident",[]],["opt",{"sourceInterval":[56,69]},["app",{"sourceInterval":[56,68]},"SuperGrammar",[]]],["terminal",{"sourceInterval":[70,73]},"{"],["star",{"sourceInterval":[74,79]},["app",{"sourceInterval":[74,78]},"Rule",[]]],["terminal",{"sourceInterval":[80,83]},"}"]]],"SuperGrammar":["define",{"sourceInterval":[87,116]},null,[],["seq",{"sourceInterval":[106,116]},["terminal",{"sourceInterval":[106,110]},"<:"],["app",{"sourceInterval":[111,116]},"ident",[]]]],"Rule_define":["define",{"sourceInterval":[131,181]},null,[],["seq",{"sourceInterval":[131,170]},["app",{"sourceInterval":[131,136]},"ident",[]],["opt",{"sourceInterval":[137,145]},["app",{"sourceInterval":[137,144]},"Formals",[]]],["opt",{"sourceInterval":[146,156]},["app",{"sourceInterval":[146,155]},"ruleDescr",[]]],["terminal",{"sourceInterval":[157,160]},"="],["app",{"sourceInterval":[162,170]},"RuleBody",[]]]],"Rule_override":["define",{"sourceInterval":[188,240]},null,[],["seq",{"sourceInterval":[188,227]},["app",{"sourceInterval":[188,193]},"ident",[]],["opt",{"sourceInterval":[194,202]},["app",{"sourceInterval":[194,201]},"Formals",[]]],["terminal",{"sourceInterval":[214,218]},":="],["app",{"sourceInterval":[219,227]},"RuleBody",[]]]],"Rule_extend":["define",{"sourceInterval":[247,297]},null,[],["seq",{"sourceInterval":[247,286]},["app",{"sourceInterval":[247,252]},"ident",[]],["opt",{"sourceInterval":[253,261]},["app",{"sourceInterval":[253,260]},"Formals",[]]],["terminal",{"sourceInterval":[273,277]},"+="],["app",{"sourceInterval":[278,286]},"RuleBody",[]]]],"Rule":["define",{"sourceInterval":[120,297]},null,[],["alt",{"sourceInterval":[131,297]},["app",{"sourceInterval":[131,170]},"Rule_define",[]],["app",{"sourceInterval":[188,227]},"Rule_override",[]],["app",{"sourceInterval":[247,286]},"Rule_extend",[]]]],"RuleBody":["define",{"sourceInterval":[301,354]},null,[],["seq",{"sourceInterval":[316,354]},["opt",{"sourceInterval":[316,320]},["terminal",{"sourceInterval":[316,319]},"|"]],["app",{"sourceInterval":[321,354]},"NonemptyListOf",[["app",{"sourceInterval":[336,348]},"TopLevelTerm",[]],["terminal",{"sourceInterval":[350,353]},"|"]]]]],"TopLevelTerm_inline":["define",{"sourceInterval":[377,400]},null,[],["seq",{"sourceInterval":[377,389]},["app",{"sourceInterval":[377,380]},"Seq",[]],["app",{"sourceInterval":[381,389]},"caseName",[]]]],"TopLevelTerm":["define",{"sourceInterval":[358,410]},null,[],["alt",{"sourceInterval":[377,410]},["app",{"sourceInterval":[377,389]},"TopLevelTerm_inline",[]],["app",{"sourceInterval":[407,410]},"Seq",[]]]],"Formals":["define",{"sourceInterval":[414,454]},null,[],["seq",{"sourceInterval":[428,454]},["terminal",{"sourceInterval":[428,431]},"<"],["app",{"sourceInterval":[432,450]},"ListOf",[["app",{"sourceInterval":[439,444]},"ident",[]],["terminal",{"sourceInterval":[446,449]},","]]],["terminal",{"sourceInterval":[451,454]},">"]]],"Params":["define",{"sourceInterval":[458,495]},null,[],["seq",{"sourceInterval":[471,495]},["terminal",{"sourceInterval":[471,474]},"<"],["app",{"sourceInterval":[475,491]},"ListOf",[["app",{"sourceInterval":[482,485]},"Seq",[]],["terminal",{"sourceInterval":[487,490]},","]]],["terminal",{"sourceInterval":[492,495]},">"]]],"Alt":["define",{"sourceInterval":[499,533]},null,[],["app",{"sourceInterval":[509,533]},"NonemptyListOf",[["app",{"sourceInterval":[524,527]},"Seq",[]],["terminal",{"sourceInterval":[529,532]},"|"]]]],"Seq":["define",{"sourceInterval":[537,552]},null,[],["star",{"sourceInterval":[547,552]},["app",{"sourceInterval":[547,551]},"Iter",[]]]],"Iter_star":["define",{"sourceInterval":[567,584]},null,[],["seq",{"sourceInterval":[567,575]},["app",{"sourceInterval":[567,571]},"Pred",[]],["terminal",{"sourceInterval":[572,575]},"*"]]],"Iter_plus":["define",{"sourceInterval":[591,608]},null,[],["seq",{"sourceInterval":[591,599]},["app",{"sourceInterval":[591,595]},"Pred",[]],["terminal",{"sourceInterval":[596,599]},"+"]]],"Iter_opt":["define",{"sourceInterval":[615,631]},null,[],["seq",{"sourceInterval":[615,623]},["app",{"sourceInterval":[615,619]},"Pred",[]],["terminal",{"sourceInterval":[620,623]},"?"]]],"Iter":["define",{"sourceInterval":[556,642]},null,[],["alt",{"sourceInterval":[567,642]},["app",{"sourceInterval":[567,575]},"Iter_star",[]],["app",{"sourceInterval":[591,599]},"Iter_plus",[]],["app",{"sourceInterval":[615,623]},"Iter_opt",[]],["app",{"sourceInterval":[638,642]},"Pred",[]]]],"Pred_not":["define",{"sourceInterval":[657,672]},null,[],["seq",{"sourceInterval":[657,664]},["terminal",{"sourceInterval":[657,660]},"~"],["app",{"sourceInterval":[661,664]},"Lex",[]]]],"Pred_lookahead":["define",{"sourceInterval":[679,700]},null,[],["seq",{"sourceInterval":[679,686]},["terminal",{"sourceInterval":[679,682]},"&"],["app",{"sourceInterval":[683,686]},"Lex",[]]]],"Pred":["define",{"sourceInterval":[646,710]},null,[],["alt",{"sourceInterval":[657,710]},["app",{"sourceInterval":[657,664]},"Pred_not",[]],["app",{"sourceInterval":[679,686]},"Pred_lookahead",[]],["app",{"sourceInterval":[707,710]},"Lex",[]]]],"Lex_lex":["define",{"sourceInterval":[724,740]},null,[],["seq",{"sourceInterval":[724,732]},["terminal",{"sourceInterval":[724,727]},"#"],["app",{"sourceInterval":[728,732]},"Base",[]]]],"Lex":["define",{"sourceInterval":[714,751]},null,[],["alt",{"sourceInterval":[724,751]},["app",{"sourceInterval":[724,732]},"Lex_lex",[]],["app",{"sourceInterval":[747,751]},"Base",[]]]],"Base_application":["define",{"sourceInterval":[766,827]},null,[],["seq",{"sourceInterval":[766,811]},["app",{"sourceInterval":[766,771]},"ident",[]],["opt",{"sourceInterval":[772,779]},["app",{"sourceInterval":[772,778]},"Params",[]]],["not",{"sourceInterval":[780,811]},["alt",{"sourceInterval":[782,810]},["seq",{"sourceInterval":[782,796]},["opt",{"sourceInterval":[782,792]},["app",{"sourceInterval":[782,791]},"ruleDescr",[]]],["terminal",{"sourceInterval":[793,796]},"="]],["terminal",{"sourceInterval":[799,803]},":="],["terminal",{"sourceInterval":[806,810]},"+="]]]]],"Base_range":["define",{"sourceInterval":[834,889]},null,[],["seq",{"sourceInterval":[834,870]},["app",{"sourceInterval":[834,849]},"oneCharTerminal",[]],["terminal",{"sourceInterval":[850,854]},".."],["app",{"sourceInterval":[855,870]},"oneCharTerminal",[]]]],"Base_terminal":["define",{"sourceInterval":[896,954]},null,[],["app",{"sourceInterval":[896,904]},"terminal",[]]],"Base_paren":["define",{"sourceInterval":[961,1016]},null,[],["seq",{"sourceInterval":[961,972]},["terminal",{"sourceInterval":[961,964]},"("],["app",{"sourceInterval":[965,968]},"Alt",[]],["terminal",{"sourceInterval":[969,972]},")"]]],"Base":["define",{"sourceInterval":[755,1016]},null,[],["alt",{"sourceInterval":[766,1016]},["app",{"sourceInterval":[766,811]},"Base_application",[]],["app",{"sourceInterval":[834,870]},"Base_range",[]],["app",{"sourceInterval":[896,904]},"Base_terminal",[]],["app",{"sourceInterval":[961,972]},"Base_paren",[]]]],"ruleDescr":["define",{"sourceInterval":[1020,1079]},"a rule description",[],["seq",{"sourceInterval":[1058,1079]},["terminal",{"sourceInterval":[1058,1061]},"("],["app",{"sourceInterval":[1062,1075]},"ruleDescrText",[]],["terminal",{"sourceInterval":[1076,1079]},")"]]],"ruleDescrText":["define",{"sourceInterval":[1083,1114]},null,[],["star",{"sourceInterval":[1103,1114]},["seq",{"sourceInterval":[1104,1112]},["not",{"sourceInterval":[1104,1108]},["terminal",{"sourceInterval":[1105,1108]},")"]],["app",{"sourceInterval":[1109,1112]},"any",[]]]]],"caseName":["define",{"sourceInterval":[1118,1186]},null,[],["seq",{"sourceInterval":[1133,1186]},["terminal",{"sourceInterval":[1133,1137]},"--"],["star",{"sourceInterval":[1138,1152]},["seq",{"sourceInterval":[1139,1150]},["not",{"sourceInterval":[1139,1144]},["terminal",{"sourceInterval":[1140,1144]},"\n"]],["app",{"sourceInterval":[1145,1150]},"space",[]]]],["app",{"sourceInterval":[1153,1157]},"name",[]],["star",{"sourceInterval":[1158,1172]},["seq",{"sourceInterval":[1159,1170]},["not",{"sourceInterval":[1159,1164]},["terminal",{"sourceInterval":[1160,1164]},"\n"]],["app",{"sourceInterval":[1165,1170]},"space",[]]]],["alt",{"sourceInterval":[1174,1185]},["terminal",{"sourceInterval":[1174,1178]},"\n"],["lookahead",{"sourceInterval":[1181,1185]},["terminal",{"sourceInterval":[1182,1185]},"}"]]]]],"name":["define",{"sourceInterval":[1190,1230]},"a name",[],["seq",{"sourceInterval":[1211,1230]},["app",{"sourceInterval":[1211,1220]},"nameFirst",[]],["star",{"sourceInterval":[1221,1230]},["app",{"sourceInterval":[1221,1229]},"nameRest",[]]]]],"nameFirst":["define",{"sourceInterval":[1234,1266]},null,[],["alt",{"sourceInterval":[1250,1266]},["terminal",{"sourceInterval":[1250,1253]},"_"],["app",{"sourceInterval":[1260,1266]},"letter",[]]]],"nameRest":["define",{"sourceInterval":[1270,1300]},null,[],["alt",{"sourceInterval":[1285,1300]},["terminal",{"sourceInterval":[1285,1288]},"_"],["app",{"sourceInterval":[1295,1300]},"alnum",[]]]],"ident":["define",{"sourceInterval":[1304,1337]},"an identifier",[],["app",{"sourceInterval":[1333,1337]},"name",[]]],"terminal":["define",{"sourceInterval":[1341,1379]},null,[],["seq",{"sourceInterval":[1356,1379]},["terminal",{"sourceInterval":[1356,1360]},"\""],["star",{"sourceInterval":[1361,1374]},["app",{"sourceInterval":[1361,1373]},"terminalChar",[]]],["terminal",{"sourceInterval":[1375,1379]},"\""]]],"oneCharTerminal":["define",{"sourceInterval":[1383,1427]},null,[],["seq",{"sourceInterval":[1405,1427]},["terminal",{"sourceInterval":[1405,1409]},"\""],["app",{"sourceInterval":[1410,1422]},"terminalChar",[]],["terminal",{"sourceInterval":[1423,1427]},"\""]]],"terminalChar":["define",{"sourceInterval":[1431,1488]},null,[],["alt",{"sourceInterval":[1450,1488]},["app",{"sourceInterval":[1450,1460]},"escapeChar",[]],["seq",{"sourceInterval":[1467,1488]},["not",{"sourceInterval":[1467,1472]},["terminal",{"sourceInterval":[1468,1472]},"\\"]],["not",{"sourceInterval":[1473,1478]},["terminal",{"sourceInterval":[1474,1478]},"\""]],["not",{"sourceInterval":[1479,1484]},["terminal",{"sourceInterval":[1480,1484]},"\n"]],["app",{"sourceInterval":[1485,1488]},"any",[]]]]],"escapeChar_backslash":["define",{"sourceInterval":[1531,1586]},null,[],["terminal",{"sourceInterval":[1531,1537]},"\\\\"]],"escapeChar_doubleQuote":["define",{"sourceInterval":[1593,1650]},null,[],["terminal",{"sourceInterval":[1593,1599]},"\\\""]],"escapeChar_singleQuote":["define",{"sourceInterval":[1657,1714]},null,[],["terminal",{"sourceInterval":[1657,1663]},"\\'"]],"escapeChar_backspace":["define",{"sourceInterval":[1721,1776]},null,[],["terminal",{"sourceInterval":[1721,1726]},"\\b"]],"escapeChar_lineFeed":["define",{"sourceInterval":[1783,1837]},null,[],["terminal",{"sourceInterval":[1783,1788]},"\\n"]],"escapeChar_carriageReturn":["define",{"sourceInterval":[1844,1904]},null,[],["terminal",{"sourceInterval":[1844,1849]},"\\r"]],"escapeChar_tab":["define",{"sourceInterval":[1911,1960]},null,[],["terminal",{"sourceInterval":[1911,1916]},"\\t"]],"escapeChar_unicodeEscape":["define",{"sourceInterval":[1967,2026]},null,[],["seq",{"sourceInterval":[1967,2008]},["terminal",{"sourceInterval":[1967,1972]},"\\u"],["app",{"sourceInterval":[1973,1981]},"hexDigit",[]],["app",{"sourceInterval":[1982,1990]},"hexDigit",[]],["app",{"sourceInterval":[1991,1999]},"hexDigit",[]],["app",{"sourceInterval":[2000,2008]},"hexDigit",[]]]],"escapeChar_hexEscape":["define",{"sourceInterval":[2033,2088]},null,[],["seq",{"sourceInterval":[2033,2056]},["terminal",{"sourceInterval":[2033,2038]},"\\x"],["app",{"sourceInterval":[2039,2047]},"hexDigit",[]],["app",{"sourceInterval":[2048,2056]},"hexDigit",[]]]],"escapeChar":["define",{"sourceInterval":[1492,2088]},"an escape sequence",[],["alt",{"sourceInterval":[1531,2088]},["app",{"sourceInterval":[1531,1537]},"escapeChar_backslash",[]],["app",{"sourceInterval":[1593,1599]},"escapeChar_doubleQuote",[]],["app",{"sourceInterval":[1657,1663]},"escapeChar_singleQuote",[]],["app",{"sourceInterval":[1721,1726]},"escapeChar_backspace",[]],["app",{"sourceInterval":[1783,1788]},"escapeChar_lineFeed",[]],["app",{"sourceInterval":[1844,1849]},"escapeChar_carriageReturn",[]],["app",{"sourceInterval":[1911,1916]},"escapeChar_tab",[]],["app",{"sourceInterval":[1967,2008]},"escapeChar_unicodeEscape",[]],["app",{"sourceInterval":[2033,2056]},"escapeChar_hexEscape",[]]]],"space":["extend",{"sourceInterval":[2092,2111]},null,[],["app",{"sourceInterval":[2104,2111]},"comment",[]]],"comment_singleLine":["define",{"sourceInterval":[2129,2166]},null,[],["seq",{"sourceInterval":[2129,2151]},["terminal",{"sourceInterval":[2129,2133]},"//"],["star",{"sourceInterval":[2134,2146]},["seq",{"sourceInterval":[2135,2144]},["not",{"sourceInterval":[2135,2140]},["terminal",{"sourceInterval":[2136,2140]},"\n"]],["app",{"sourceInterval":[2141,2144]},"any",[]]]],["terminal",{"sourceInterval":[2147,2151]},"\n"]]],"comment_multiLine":["define",{"sourceInterval":[2173,2209]},null,[],["seq",{"sourceInterval":[2173,2195]},["terminal",{"sourceInterval":[2173,2177]},"/*"],["star",{"sourceInterval":[2178,2190]},["seq",{"sourceInterval":[2179,2188]},["not",{"sourceInterval":[2179,2184]},["terminal",{"sourceInterval":[2180,2184]},"*/"]],["app",{"sourceInterval":[2185,2188]},"any",[]]]],["terminal",{"sourceInterval":[2191,2195]},"*/"]]],"comment":["define",{"sourceInterval":[2115,2209]},null,[],["alt",{"sourceInterval":[2129,2209]},["app",{"sourceInterval":[2129,2151]},"comment_singleLine",[]],["app",{"sourceInterval":[2173,2195]},"comment_multiLine",[]]]],"tokens":["define",{"sourceInterval":[2213,2228]},null,[],["star",{"sourceInterval":[2222,2228]},["app",{"sourceInterval":[2222,2227]},"token",[]]]],"token":["define",{"sourceInterval":[2232,2308]},null,[],["alt",{"sourceInterval":[2240,2308]},["app",{"sourceInterval":[2240,2248]},"caseName",[]],["app",{"sourceInterval":[2251,2258]},"comment",[]],["app",{"sourceInterval":[2261,2266]},"ident",[]],["app",{"sourceInterval":[2269,2277]},"operator",[]],["app",{"sourceInterval":[2280,2291]},"punctuation",[]],["app",{"sourceInterval":[2294,2302]},"terminal",[]],["app",{"sourceInterval":[2305,2308]},"any",[]]]],"operator":["define",{"sourceInterval":[2312,2377]},null,[],["alt",{"sourceInterval":[2323,2377]},["terminal",{"sourceInterval":[2323,2327]},"<:"],["terminal",{"sourceInterval":[2330,2333]},"="],["terminal",{"sourceInterval":[2336,2340]},":="],["terminal",{"sourceInterval":[2343,2347]},"+="],["terminal",{"sourceInterval":[2350,2353]},"*"],["terminal",{"sourceInterval":[2356,2359]},"+"],["terminal",{"sourceInterval":[2362,2365]},"?"],["terminal",{"sourceInterval":[2368,2371]},"~"],["terminal",{"sourceInterval":[2374,2377]},"&"]]],"punctuation":["define",{"sourceInterval":[2381,2417]},null,[],["alt",{"sourceInterval":[2395,2417]},["terminal",{"sourceInterval":[2395,2398]},"<"],["terminal",{"sourceInterval":[2401,2404]},">"],["terminal",{"sourceInterval":[2407,2410]},","],["terminal",{"sourceInterval":[2413,2417]},"--"]]]}]);
- },{"..":46}],3:[function(require,module,exports){
- var ohm = require('..');
- module.exports = ohm.makeRecipe(["grammar",{"source":"OperationsAndAttributes {\n\n AttributeSignature =\n name\n\n OperationSignature =\n name Formals?\n\n Formals\n = \"(\" ListOf<name, \",\"> \")\"\n\n name (a name)\n = nameFirst nameRest*\n\n nameFirst\n = \"_\"\n | letter\n\n nameRest\n = \"_\"\n | alnum\n\n}"},"OperationsAndAttributes",null,"AttributeSignature",{"AttributeSignature":["define",{"sourceInterval":[29,58]},null,[],["app",{"sourceInterval":[54,58]},"name",[]]],"OperationSignature":["define",{"sourceInterval":[62,100]},null,[],["seq",{"sourceInterval":[87,100]},["app",{"sourceInterval":[87,91]},"name",[]],["opt",{"sourceInterval":[92,100]},["app",{"sourceInterval":[92,99]},"Formals",[]]]]],"Formals":["define",{"sourceInterval":[104,143]},null,[],["seq",{"sourceInterval":[118,143]},["terminal",{"sourceInterval":[118,121]},"("],["app",{"sourceInterval":[122,139]},"ListOf",[["app",{"sourceInterval":[129,133]},"name",[]],["terminal",{"sourceInterval":[135,138]},","]]],["terminal",{"sourceInterval":[140,143]},")"]]],"name":["define",{"sourceInterval":[147,187]},"a name",[],["seq",{"sourceInterval":[168,187]},["app",{"sourceInterval":[168,177]},"nameFirst",[]],["star",{"sourceInterval":[178,187]},["app",{"sourceInterval":[178,186]},"nameRest",[]]]]],"nameFirst":["define",{"sourceInterval":[191,223]},null,[],["alt",{"sourceInterval":[207,223]},["terminal",{"sourceInterval":[207,210]},"_"],["app",{"sourceInterval":[217,223]},"letter",[]]]],"nameRest":["define",{"sourceInterval":[227,257]},null,[],["alt",{"sourceInterval":[242,257]},["terminal",{"sourceInterval":[242,245]},"_"],["app",{"sourceInterval":[252,257]},"alnum",[]]]]}]);
- },{"..":46}],4:[function(require,module,exports){
- 'use strict';
- var assert = require('../src/common').assert;
- function getProp(name, thing, fn) {
- return fn(thing[name]);
- }
- function mapProp(name, thing, fn) {
- return thing[name].map(fn);
- }
- function getPropWalkFn(descriptor) {
- var parts = descriptor.split(/ ?\[\]/);
- if (parts.length === 2) {
- return mapProp.bind(null, parts[0]);
- }
- return getProp.bind(null, descriptor);
- }
- function getProps(walkFns, thing, fn) {
- return walkFns.map(function(walkFn) {
- return walkFn(thing, fn);
- });
- }
- function getWalkFn(shape) {
- if (typeof shape === 'string') {
- return getProps.bind(null, [getPropWalkFn(shape)]);
- } else if (Array.isArray(shape)) {
- return getProps.bind(null, shape.map(getPropWalkFn));
- } else {
- assert(typeof shape === 'function', 'Expected a string, Array, or function');
- assert(shape.length === 2, 'Expected a function of arity 2, got ' + shape.length);
- return shape;
- }
- }
- function isRestrictedIdentifier(str) {
- return /^[a-zA-Z_][0-9a-zA-Z_]*$/.test(str);
- }
- function trim(s) {
- return s.trim();
- }
- function parseSignature(sig) {
- var parts = sig.split(/[()]/).map(trim);
- if (parts.length === 3 && parts[2] === '') {
- var name = parts[0];
- var params = [];
- if (parts[1].length > 0) {
- params = parts[1].split(',').map(trim);
- }
- if (isRestrictedIdentifier(name) && params.every(isRestrictedIdentifier)) {
- return {name: name, formals: params};
- }
- }
- throw new Error('Invalid operation signature: ' + sig);
- }
- function VisitorFamily(config) {
- this._shapes = config.shapes;
- this._getTag = config.getTag;
- this.Adapter = function(thing, family) {
- this._adaptee = thing;
- this._family = family;
- };
- this.Adapter.prototype.valueOf = function() {
- throw new Error('heeey!');
- };
- this.operations = {};
- this._arities = Object.create(null);
- this._getChildren = Object.create(null);
- var self = this;
- Object.keys(this._shapes).forEach(function(k) {
- var shape = self._shapes[k];
- self._getChildren[k] = getWalkFn(shape);
-
- if (typeof shape !== 'function') {
- self._arities[k] = Array.isArray(shape) ? shape.length : 1;
- }
- });
- this._wrap = function(thing) { return new self.Adapter(thing, self); };
- }
- VisitorFamily.prototype.wrap = function(thing) {
- return this._wrap(thing);
- };
- VisitorFamily.prototype._checkActionDict = function(dict) {
- var self = this;
- Object.keys(dict).forEach(function(k) {
- assert(k in self._getChildren, "Unrecognized action name '" + k + "'");
- var action = dict[k];
- assert(typeof action === 'function', "Key '" + k + "': expected function, got " + action);
- if (k in self._arities) {
- var expected = self._arities[k];
- var actual = dict[k].length;
- assert(actual === expected,
- "Action '" + k + "' has the wrong arity: expected " + expected + ', got ' + actual);
- }
- });
- };
- VisitorFamily.prototype.addOperation = function(signature, actions) {
- var sig = parseSignature(signature);
- var name = sig.name;
- this._checkActionDict(actions);
- this.operations[name] = {
- name: name,
- formals: sig.formals,
- actions: actions
- };
- var family = this;
- this.Adapter.prototype[name] = function() {
- var tag = family._getTag(this._adaptee);
- assert(tag in family._getChildren, "getTag returned unrecognized tag '" + tag + "'");
- assert(tag in actions, "No action for '" + tag + "' in operation '" + name + "'");
-
-
- var args = Object.create(null);
- for (var i = 0; i < arguments.length; i++) {
- args[sig.formals[i]] = arguments[i];
- }
- var oldArgs = this.args;
- this.args = args;
- var ans = actions[tag].apply(this, family._getChildren[tag](this._adaptee, family._wrap));
- this.args = oldArgs;
- return ans;
- };
- return this;
- };
- module.exports = VisitorFamily;
- },{"../src/common":44}],5:[function(require,module,exports){
- 'use strict';
- module.exports = {
- VisitorFamily: require('./VisitorFamily'),
- semanticsForToAST: require('./semantics-toAST').semantics,
- toAST: require('./semantics-toAST').helper
- };
- },{"./VisitorFamily":4,"./semantics-toAST":6}],6:[function(require,module,exports){
- 'use strict';
- var pexprs = require('../src/pexprs');
- var MatchResult = require('../src/MatchResult');
- var Grammar = require('../src/Grammar');
- var extend = require('util-extend');
- var defaultOperation = {
- _terminal: function() {
- return this.primitiveValue;
- },
- _nonterminal: function(children) {
- var ctorName = this._node.ctorName;
- var mapping = this.args.mapping;
-
- if (!mapping.hasOwnProperty(ctorName)) {
-
- if (this._node instanceof pexprs.Alt || this._node instanceof pexprs.Apply) {
- return children[0].toAST(mapping);
- }
-
- if (this.isLexical()) {
- return this.sourceString;
- }
-
- var realChildren = children.filter(function(child) {
- return !child.isTerminal();
- });
- if (realChildren.length === 1) {
- return realChildren[0].toAST(mapping);
- }
-
- }
-
- if (typeof mapping[ctorName] === 'number') {
- return children[mapping[ctorName]].toAST(mapping);
- }
-
- var propMap = mapping[ctorName] || children;
- var node = {
- type: ctorName
- };
- for (var prop in propMap) {
- var mappedProp = mapping[ctorName] && mapping[ctorName][prop];
- if (typeof mappedProp === 'number') {
-
- node[prop] = children[mappedProp].toAST(mapping);
- } else if ((typeof mappedProp === 'string') || (typeof mappedProp === 'boolean') ||
- (mappedProp === null)) {
-
- node[prop] = mappedProp;
- } else if ((typeof mappedProp === 'object') && (mappedProp instanceof Number)) {
-
- node[prop] = Number(mappedProp);
- } else if (typeof mappedProp === 'function') {
-
- node[prop] = mappedProp.call(this, children);
- } else if (mappedProp === undefined) {
- if (children[prop] && !children[prop].isTerminal()) {
- node[prop] = children[prop].toAST(mapping);
- } else {
-
- delete node[prop];
- }
- }
- }
- return node;
- },
- _iter: function(children) {
- if (this._node.isOptional()) {
- if (this.numChildren === 0) {
- return null;
- } else {
- return children[0].toAST(this.args.mapping);
- }
- }
- return children.map(function(child) {
- return child.toAST(this.args.mapping);
- }, this);
- },
- NonemptyListOf: function(first, sep, rest) {
- return [first.toAST(this.args.mapping)].concat(rest.toAST(this.args.mapping));
- },
- EmptyListOf: function() {
- return [];
- }
- };
- function toAST(res, mapping) {
- if (!(res instanceof MatchResult) || res.failed()) {
- throw new Error('toAST() expects a succesfull MatchResult as first parameter');
- }
- mapping = extend({}, mapping);
- var operation = extend({}, defaultOperation);
- for (var termName in mapping) {
- if (typeof mapping[termName] === 'function') {
- operation[termName] = mapping[termName];
- delete mapping[termName];
- }
- }
- var g = res._cst.grammar;
- var s = g.createSemantics().addOperation('toAST(mapping)', operation);
- return s(res).toAST(mapping);
- }
- function semanticsForToAST(g) {
- if (!(g instanceof Grammar)) {
- throw new Error('semanticsToAST() expects a Grammar as parameter');
- }
- return g.createSemantics().addOperation('toAST(mapping)', defaultOperation);
- }
- module.exports = {
- helper: toAST,
- semantics: semanticsForToAST
- };
- },{"../src/Grammar":33,"../src/MatchResult":37,"../src/pexprs":64,"util-extend":29}],7:[function(require,module,exports){
- 'use strict';
- var assign = require('es5-ext/object/assign')
- , normalizeOpts = require('es5-ext/object/normalize-options')
- , isCallable = require('es5-ext/object/is-callable')
- , contains = require('es5-ext/string/#/contains')
- , d;
- d = module.exports = function (dscr, value/*, options*/) {
- var c, e, w, options, desc;
- if ((arguments.length < 2) || (typeof dscr !== 'string')) {
- options = value;
- value = dscr;
- dscr = null;
- } else {
- options = arguments[2];
- }
- if (dscr == null) {
- c = w = true;
- e = false;
- } else {
- c = contains.call(dscr, 'c');
- e = contains.call(dscr, 'e');
- w = contains.call(dscr, 'w');
- }
- desc = { value: value, configurable: c, enumerable: e, writable: w };
- return !options ? desc : assign(normalizeOpts(options), desc);
- };
- d.gs = function (dscr, get, set/*, options*/) {
- var c, e, options, desc;
- if (typeof dscr !== 'string') {
- options = set;
- set = get;
- get = dscr;
- dscr = null;
- } else {
- options = arguments[3];
- }
- if (get == null) {
- get = undefined;
- } else if (!isCallable(get)) {
- options = get;
- get = set = undefined;
- } else if (set == null) {
- set = undefined;
- } else if (!isCallable(set)) {
- options = set;
- set = undefined;
- }
- if (dscr == null) {
- c = true;
- e = false;
- } else {
- c = contains.call(dscr, 'c');
- e = contains.call(dscr, 'e');
- }
- desc = { get: get, set: set, configurable: c, enumerable: e };
- return !options ? desc : assign(normalizeOpts(options), desc);
- };
- },{"es5-ext/object/assign":9,"es5-ext/object/is-callable":12,"es5-ext/object/normalize-options":17,"es5-ext/string/#/contains":19}],8:[function(require,module,exports){
- "use strict";
- module.exports = function () {};
- },{}],9:[function(require,module,exports){
- "use strict";
- module.exports = require("./is-implemented")()
- ? Object.assign
- : require("./shim");
- },{"./is-implemented":10,"./shim":11}],10:[function(require,module,exports){
- "use strict";
- module.exports = function () {
- var assign = Object.assign, obj;
- if (typeof assign !== "function") return false;
- obj = { foo: "raz" };
- assign(obj, { bar: "dwa" }, { trzy: "trzy" });
- return (obj.foo + obj.bar + obj.trzy) === "razdwatrzy";
- };
- },{}],11:[function(require,module,exports){
- "use strict";
- var keys = require("../keys")
- , value = require("../valid-value")
- , max = Math.max;
- module.exports = function (dest, src /*, …srcn*/) {
- var error, i, length = max(arguments.length, 2), assign;
- dest = Object(value(dest));
- assign = function (key) {
- try {
- dest[key] = src[key];
- } catch (e) {
- if (!error) error = e;
- }
- };
- for (i = 1; i < length; ++i) {
- src = arguments[i];
- keys(src).forEach(assign);
- }
- if (error !== undefined) throw error;
- return dest;
- };
- },{"../keys":14,"../valid-value":18}],12:[function(require,module,exports){
- "use strict";
- module.exports = function (obj) {
- return typeof obj === "function";
- };
- },{}],13:[function(require,module,exports){
- "use strict";
- var _undefined = require("../function/noop")();
- module.exports = function (val) {
- return (val !== _undefined) && (val !== null);
- };
- },{"../function/noop":8}],14:[function(require,module,exports){
- "use strict";
- module.exports = require("./is-implemented")()
- ? Object.keys
- : require("./shim");
- },{"./is-implemented":15,"./shim":16}],15:[function(require,module,exports){
- "use strict";
- module.exports = function () {
- try {
- Object.keys("primitive");
- return true;
- } catch (e) {
- return false;
- }
- };
- },{}],16:[function(require,module,exports){
- "use strict";
- var isValue = require("../is-value");
- var keys = Object.keys;
- module.exports = function (object) {
- return keys(isValue(object) ? Object(object) : object);
- };
- },{"../is-value":13}],17:[function(require,module,exports){
- "use strict";
- var isValue = require("./is-value");
- var forEach = Array.prototype.forEach, create = Object.create;
- var process = function (src, obj) {
- var key;
- for (key in src) obj[key] = src[key];
- };
- module.exports = function (opts1 /*, …options*/) {
- var result = create(null);
- forEach.call(arguments, function (options) {
- if (!isValue(options)) return;
- process(Object(options), result);
- });
- return result;
- };
- },{"./is-value":13}],18:[function(require,module,exports){
- "use strict";
- var isValue = require("./is-value");
- module.exports = function (value) {
- if (!isValue(value)) throw new TypeError("Cannot use null or undefined");
- return value;
- };
- },{"./is-value":13}],19:[function(require,module,exports){
- "use strict";
- module.exports = require("./is-implemented")()
- ? String.prototype.contains
- : require("./shim");
- },{"./is-implemented":20,"./shim":21}],20:[function(require,module,exports){
- "use strict";
- var str = "razdwatrzy";
- module.exports = function () {
- if (typeof str.contains !== "function") return false;
- return (str.contains("dwa") === true) && (str.contains("foo") === false);
- };
- },{}],21:[function(require,module,exports){
- "use strict";
- var indexOf = String.prototype.indexOf;
- module.exports = function (searchString/*, position*/) {
- return indexOf.call(this, searchString, arguments[1]) > -1;
- };
- },{}],22:[function(require,module,exports){
- 'use strict';
- module.exports = require('./is-implemented')() ? Symbol : require('./polyfill');
- },{"./is-implemented":23,"./polyfill":25}],23:[function(require,module,exports){
- 'use strict';
- var validTypes = { object: true, symbol: true };
- module.exports = function () {
- var symbol;
- if (typeof Symbol !== 'function') return false;
- symbol = Symbol('test symbol');
- try { String(symbol); } catch (e) { return false; }
-
- if (!validTypes[typeof Symbol.iterator]) return false;
- if (!validTypes[typeof Symbol.toPrimitive]) return false;
- if (!validTypes[typeof Symbol.toStringTag]) return false;
- return true;
- };
- },{}],24:[function(require,module,exports){
- 'use strict';
- module.exports = function (x) {
- if (!x) return false;
- if (typeof x === 'symbol') return true;
- if (!x.constructor) return false;
- if (x.constructor.name !== 'Symbol') return false;
- return (x[x.constructor.toStringTag] === 'Symbol');
- };
- },{}],25:[function(require,module,exports){
- 'use strict';
- var d = require('d')
- , validateSymbol = require('./validate-symbol')
- , create = Object.create, defineProperties = Object.defineProperties
- , defineProperty = Object.defineProperty, objPrototype = Object.prototype
- , NativeSymbol, SymbolPolyfill, HiddenSymbol, globalSymbols = create(null)
- , isNativeSafe;
- if (typeof Symbol === 'function') {
- NativeSymbol = Symbol;
- try {
- String(NativeSymbol());
- isNativeSafe = true;
- } catch (ignore) {}
- }
- var generateName = (function () {
- var created = create(null);
- return function (desc) {
- var postfix = 0, name, ie11BugWorkaround;
- while (created[desc + (postfix || '')]) ++postfix;
- desc += (postfix || '');
- created[desc] = true;
- name = '@@' + desc;
- defineProperty(objPrototype, name, d.gs(null, function (value) {
-
-
-
-
- if (ie11BugWorkaround) return;
- ie11BugWorkaround = true;
- defineProperty(this, name, d(value));
- ie11BugWorkaround = false;
- }));
- return name;
- };
- }());
- HiddenSymbol = function Symbol(description) {
- if (this instanceof HiddenSymbol) throw new TypeError('Symbol is not a constructor');
- return SymbolPolyfill(description);
- };
- module.exports = SymbolPolyfill = function Symbol(description) {
- var symbol;
- if (this instanceof Symbol) throw new TypeError('Symbol is not a constructor');
- if (isNativeSafe) return NativeSymbol(description);
- symbol = create(HiddenSymbol.prototype);
- description = (description === undefined ? '' : String(description));
- return defineProperties(symbol, {
- __description__: d('', description),
- __name__: d('', generateName(description))
- });
- };
- defineProperties(SymbolPolyfill, {
- for: d(function (key) {
- if (globalSymbols[key]) return globalSymbols[key];
- return (globalSymbols[key] = SymbolPolyfill(String(key)));
- }),
- keyFor: d(function (s) {
- var key;
- validateSymbol(s);
- for (key in globalSymbols) if (globalSymbols[key] === s) return key;
- }),
-
-
- hasInstance: d('', (NativeSymbol && NativeSymbol.hasInstance) || SymbolPolyfill('hasInstance')),
- isConcatSpreadable: d('', (NativeSymbol && NativeSymbol.isConcatSpreadable) ||
- SymbolPolyfill('isConcatSpreadable')),
- iterator: d('', (NativeSymbol && NativeSymbol.iterator) || SymbolPolyfill('iterator')),
- match: d('', (NativeSymbol && NativeSymbol.match) || SymbolPolyfill('match')),
- replace: d('', (NativeSymbol && NativeSymbol.replace) || SymbolPolyfill('replace')),
- search: d('', (NativeSymbol && NativeSymbol.search) || SymbolPolyfill('search')),
- species: d('', (NativeSymbol && NativeSymbol.species) || SymbolPolyfill('species')),
- split: d('', (NativeSymbol && NativeSymbol.split) || SymbolPolyfill('split')),
- toPrimitive: d('', (NativeSymbol && NativeSymbol.toPrimitive) || SymbolPolyfill('toPrimitive')),
- toStringTag: d('', (NativeSymbol && NativeSymbol.toStringTag) || SymbolPolyfill('toStringTag')),
- unscopables: d('', (NativeSymbol && NativeSymbol.unscopables) || SymbolPolyfill('unscopables'))
- });
- defineProperties(HiddenSymbol.prototype, {
- constructor: d(SymbolPolyfill),
- toString: d('', function () { return this.__name__; })
- });
- defineProperties(SymbolPolyfill.prototype, {
- toString: d(function () { return 'Symbol (' + validateSymbol(this).__description__ + ')'; }),
- valueOf: d(function () { return validateSymbol(this); })
- });
- defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toPrimitive, d('', function () {
- var symbol = validateSymbol(this);
- if (typeof symbol === 'symbol') return symbol;
- return symbol.toString();
- }));
- defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toStringTag, d('c', 'Symbol'));
- defineProperty(HiddenSymbol.prototype, SymbolPolyfill.toStringTag,
- d('c', SymbolPolyfill.prototype[SymbolPolyfill.toStringTag]));
- defineProperty(HiddenSymbol.prototype, SymbolPolyfill.toPrimitive,
- d('c', SymbolPolyfill.prototype[SymbolPolyfill.toPrimitive]));
- },{"./validate-symbol":26,"d":7}],26:[function(require,module,exports){
- 'use strict';
- var isSymbol = require('./is-symbol');
- module.exports = function (value) {
- if (!isSymbol(value)) throw new TypeError(value + " is not a symbol");
- return value;
- };
- },{"./is-symbol":24}],27:[function(require,module,exports){
- if (typeof Object.create === 'function') {
-
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor
- ctor.prototype = Object.create(superCtor.prototype, {
- constructor: {
- value: ctor,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- };
- } else {
-
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor
- var TempCtor = function () {}
- TempCtor.prototype = superCtor.prototype
- ctor.prototype = new TempCtor()
- ctor.prototype.constructor = ctor
- }
- }
- },{}],28:[function(require,module,exports){
- module.exports = function (obj) {
- return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
- }
- function isBuffer (obj) {
- return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
- }
- function isSlowBuffer (obj) {
- return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
- }
- },{}],29:[function(require,module,exports){
- module.exports = extend;
- function extend(origin, add) {
-
- if (!add || typeof add !== 'object') return origin;
- var keys = Object.keys(add);
- var i = keys.length;
- while (i--) {
- origin[keys[i]] = add[keys[i]];
- }
- return origin;
- }
- },{}],30:[function(require,module,exports){
- 'use strict';
- var GrammarDecl = require('./GrammarDecl');
- var pexprs = require('./pexprs');
- function Builder() {}
- Builder.prototype = {
- currentDecl: null,
- newGrammar: function(name) {
- return new GrammarDecl(name);
- },
- grammar: function(metaInfo, name, superGrammar, defaultStartRule, rules) {
- var gDecl = new GrammarDecl(name);
- if (superGrammar) {
- gDecl.withSuperGrammar(this.fromRecipe(superGrammar));
- }
- if (defaultStartRule) {
- gDecl.withDefaultStartRule(defaultStartRule);
- }
- if (metaInfo && metaInfo.source) {
- gDecl.withSource(metaInfo.source);
- }
- var self = this;
- this.currentDecl = gDecl;
- Object.keys(rules).forEach(function(ruleName) {
- var ruleRecipe = rules[ruleName];
- var action = ruleRecipe[0];
- var metaInfo = ruleRecipe[1];
- var description = ruleRecipe[2];
- var formals = ruleRecipe[3];
- var body = self.fromRecipe(ruleRecipe[4]);
- var source;
- if (gDecl.source && metaInfo && metaInfo.sourceInterval) {
- source = gDecl.source.subInterval(
- metaInfo.sourceInterval[0],
- metaInfo.sourceInterval[1] - metaInfo.sourceInterval[0]);
- }
- gDecl[action](ruleName, formals, body, description, source);
- });
- this.currentDecl = null;
- return gDecl.build();
- },
- terminal: function(x) {
- return new pexprs.Terminal(x);
- },
- range: function(from, to) {
- return new pexprs.Range(from, to);
- },
- param: function(index) {
- return new pexprs.Param(index);
- },
- alt: function(/* term1, term1, ... */) {
- var terms = [];
- for (var idx = 0; idx < arguments.length; idx++) {
- var arg = arguments[idx];
- if (!(arg instanceof pexprs.PExpr)) {
- arg = this.fromRecipe(arg);
- }
- if (arg instanceof pexprs.Alt) {
- terms = terms.concat(arg.terms);
- } else {
- terms.push(arg);
- }
- }
- return terms.length === 1 ? terms[0] : new pexprs.Alt(terms);
- },
- seq: function(/* factor1, factor2, ... */) {
- var factors = [];
- for (var idx = 0; idx < arguments.length; idx++) {
- var arg = arguments[idx];
- if (!(arg instanceof pexprs.PExpr)) {
- arg = this.fromRecipe(arg);
- }
- if (arg instanceof pexprs.Seq) {
- factors = factors.concat(arg.factors);
- } else {
- factors.push(arg);
- }
- }
- return factors.length === 1 ? factors[0] : new pexprs.Seq(factors);
- },
- star: function(expr) {
- if (!(expr instanceof pexprs.PExpr)) {
- expr = this.fromRecipe(expr);
- }
- return new pexprs.Star(expr);
- },
- plus: function(expr) {
- if (!(expr instanceof pexprs.PExpr)) {
- expr = this.fromRecipe(expr);
- }
- return new pexprs.Plus(expr);
- },
- opt: function(expr) {
- if (!(expr instanceof pexprs.PExpr)) {
- expr = this.fromRecipe(expr);
- }
- return new pexprs.Opt(expr);
- },
- not: function(expr) {
- if (!(expr instanceof pexprs.PExpr)) {
- expr = this.fromRecipe(expr);
- }
- return new pexprs.Not(expr);
- },
- la: function(expr) {
-
- return this.lookahead(expr);
- },
- lookahead: function(expr) {
- if (!(expr instanceof pexprs.PExpr)) {
- expr = this.fromRecipe(expr);
- }
- return new pexprs.Lookahead(expr);
- },
- lex: function(expr) {
- if (!(expr instanceof pexprs.PExpr)) {
- expr = this.fromRecipe(expr);
- }
- return new pexprs.Lex(expr);
- },
- app: function(ruleName, optParams) {
- if (optParams && optParams.length > 0) {
- optParams = optParams.map(function(param) {
- return param instanceof pexprs.PExpr ? param :
- this.fromRecipe(param);
- }, this);
- }
- return new pexprs.Apply(ruleName, optParams);
- },
- fromRecipe: function(recipe) {
-
- var result = this[recipe[0]].apply(this,
- recipe[0] === 'grammar' ? recipe.slice(1) : recipe.slice(2));
- var metaInfo = recipe[1];
- if (metaInfo) {
- if (metaInfo.sourceInterval && this.currentDecl) {
- result.withSource(
- this.currentDecl.sourceInterval.apply(this.currentDecl, metaInfo.sourceInterval)
- );
- }
- }
- return result;
- }
- };
- module.exports = Builder;
- },{"./GrammarDecl":34,"./pexprs":64}],31:[function(require,module,exports){
- 'use strict';
- var Failure = require('./Failure');
- var TerminalNode = require('./nodes').TerminalNode;
- var assert = require('./common').assert;
- var inherits = require('inherits');
- var pexprs = require('./pexprs');
- function CaseInsensitiveTerminal(param) {
- this.obj = param;
- }
- inherits(CaseInsensitiveTerminal, pexprs.PExpr);
- CaseInsensitiveTerminal.prototype = {
- _getString: function(state) {
- var terminal = state.currentApplication().args[this.obj.index];
- assert(terminal instanceof pexprs.Terminal, 'expected a Terminal expression');
- return terminal.obj;
- },
-
- allowsSkippingPrecedingSpace: function() {
- return true;
- },
- eval: function(state) {
- var inputStream = state.inputStream;
- var origPos = inputStream.pos;
- var matchStr = this._getString(state);
- if (!inputStream.matchString(matchStr, true)) {
- state.processFailure(origPos, this);
- return false;
- } else {
- state.pushBinding(new TerminalNode(state.grammar, matchStr), origPos);
- return true;
- }
- },
- generateExample: function(grammar, examples, inSyntacticContext, actuals) {
-
- var str = this.obj.generateExample(grammar, examples, inSyntacticContext, actuals).value;
-
- var value = '';
- for (var i = 0; i < str.length; ++i) {
- value += Math.random() < 0.5 ? str[i].toLocaleLowerCase() : str[i].toLocaleUpperCase();
- }
- return {value: value};
- },
- getArity: function() {
- return 1;
- },
- substituteParams: function(actuals) {
- return new CaseInsensitiveTerminal(this.obj.substituteParams(actuals));
- },
- toDisplayString: function() {
- return this.obj.toDisplayString() + ' (case-insensitive)';
- },
- toFailure: function(grammar) {
- return new Failure(this, this.obj.toFailure(grammar) + ' (case-insensitive)', 'description');
- },
- _isNullable: function(grammar, memo) {
- return this.obj._isNullable(grammar, memo);
- }
- };
- module.exports = CaseInsensitiveTerminal;
- },{"./Failure":32,"./common":44,"./nodes":47,"./pexprs":64,"inherits":27}],32:[function(require,module,exports){
- 'use strict';
- function isValidType(type) {
- return type === 'description' || type === 'string' || type === 'code';
- }
- function Failure(pexpr, text, type) {
- if (!isValidType(type)) {
- throw new Error('invalid Failure type: ' + type);
- }
- this.pexpr = pexpr;
- this.text = text;
- this.type = type;
- this.fluffy = false;
- }
- Failure.prototype.getPExpr = function() {
- return this.pexpr;
- };
- Failure.prototype.getText = function() {
- return this.text;
- };
- Failure.prototype.getType = function() {
- return this.type;
- };
- Failure.prototype.isDescription = function() {
- return this.type === 'description';
- };
- Failure.prototype.isStringTerminal = function() {
- return this.type === 'string';
- };
- Failure.prototype.isCode = function() {
- return this.type === 'code';
- };
- Failure.prototype.isFluffy = function() {
- return this.fluffy;
- };
- Failure.prototype.makeFluffy = function() {
- this.fluffy = true;
- };
- Failure.prototype.clearFluffy = function() {
- this.fluffy = false;
- };
- Failure.prototype.subsumes = function(that) {
- return this.getText() === that.getText() &&
- this.type === that.type &&
- (!this.isFluffy() || this.isFluffy() && that.isFluffy());
- };
- Failure.prototype.toString = function() {
- return this.type === 'string' ?
- JSON.stringify(this.getText()) :
- this.getText();
- };
- Failure.prototype.clone = function() {
- var failure = new Failure(this.pexpr, this.text, this.type);
- if (this.isFluffy()) {
- failure.makeFluffy();
- }
- return failure;
- };
- Failure.prototype.toKey = function() {
- return this.toString() + '#' + this.type;
- };
- module.exports = Failure;
- },{}],33:[function(require,module,exports){
- 'use strict';
- var CaseInsensitiveTerminal = require('./CaseInsensitiveTerminal');
- var Matcher = require('./Matcher');
- var Semantics = require('./Semantics');
- var common = require('./common');
- var errors = require('./errors');
- var pexprs = require('./pexprs');
- function getSortedRuleValues(grammar) {
- return Object.keys(grammar.rules).sort().map(function(name) { return grammar.rules[name]; });
- }
- function Grammar(
- name,
- superGrammar,
- rules,
- optDefaultStartRule) {
- this.name = name;
- this.superGrammar = superGrammar;
- this.rules = rules;
- if (optDefaultStartRule) {
- if (!(optDefaultStartRule in rules)) {
- throw new Error("Invalid start rule: '" + optDefaultStartRule +
- "' is not a rule in grammar '" + name + "'");
- }
- this.defaultStartRule = optDefaultStartRule;
- }
- }
- var ohmGrammar;
- var buildGrammar;
- Grammar.initApplicationParser = function(grammar, builderFn) {
- ohmGrammar = grammar;
- buildGrammar = builderFn;
- };
- Grammar.prototype = {
- matcher: function() {
- return new Matcher(this);
- },
-
-
- isBuiltIn: function() {
- return this === Grammar.ProtoBuiltInRules || this === Grammar.BuiltInRules;
- },
- equals: function(g) {
- if (this === g) {
- return true;
- }
-
- if (g == null ||
- this.name !== g.name ||
- this.defaultStartRule !== g.defaultStartRule ||
- !(this.superGrammar === g.superGrammar || this.superGrammar.equals(g.superGrammar))) {
- return false;
- }
- var myRules = getSortedRuleValues(this);
- var otherRules = getSortedRuleValues(g);
- return myRules.length === otherRules.length && myRules.every(function(rule, i) {
- return rule.description === otherRules[i].description &&
- rule.formals.join(',') === otherRules[i].formals.join(',') &&
- rule.body.toString() === otherRules[i].body.toString();
- });
- },
- match: function(input, optStartApplication) {
- var m = this.matcher();
- m.replaceInputRange(0, 0, input);
- return m.match(optStartApplication);
- },
- trace: function(input, optStartApplication) {
- var m = this.matcher();
- m.replaceInputRange(0, 0, input);
- return m.trace(optStartApplication);
- },
- semantics: function() {
-
- throw new Error('semantics() is deprecated -- use createSemantics() instead.');
- },
- createSemantics: function() {
- return Semantics.createSemantics(this);
- },
- extendSemantics: function(superSemantics) {
- return Semantics.createSemantics(this, superSemantics._getSemantics());
- },
-
-
- _checkTopDownActionDict: function(what, name, actionDict) {
- function isSpecialAction(a) {
- return a === '_iter' || a === '_terminal' || a === '_nonterminal' || a === '_default';
- }
- var problems = [];
- for (var k in actionDict) {
- var v = actionDict[k];
- if (!isSpecialAction(k) && !(k in this.rules)) {
- problems.push("'" + k + "' is not a valid semantic action for '" + this.name + "'");
- } else if (typeof v !== 'function') {
- problems.push(
- "'" + k + "' must be a function in an action dictionary for '" + this.name + "'");
- } else {
- var actual = v.length;
- var expected = this._topDownActionArity(k);
- if (actual !== expected) {
- problems.push(
- "Semantic action '" + k + "' has the wrong arity: " +
- 'expected ' + expected + ', got ' + actual);
- }
- }
- }
- if (problems.length > 0) {
- var prettyProblems = problems.map(function(problem) { return '- ' + problem; });
- var error = new Error(
- "Found errors in the action dictionary of the '" + name + "' " + what + ':\n' +
- prettyProblems.join('\n'));
- error.problems = problems;
- throw error;
- }
- },
-
-
- _topDownActionArity: function(actionName) {
- if (actionName === '_iter' || actionName === '_nonterminal' || actionName === '_default') {
- return 1;
- } else if (actionName === '_terminal') {
- return 0;
- }
- return this.rules[actionName].body.getArity();
- },
- _inheritsFrom: function(grammar) {
- var g = this.superGrammar;
- while (g) {
- if (g.equals(grammar, true)) {
- return true;
- }
- g = g.superGrammar;
- }
- return false;
- },
- toRecipe: function(optVarName) {
- var metaInfo = {};
-
- if (this.source) {
- metaInfo.source = this.source.contents;
- }
- var superGrammar = null;
- if (this.superGrammar && !this.superGrammar.isBuiltIn()) {
- superGrammar = JSON.parse(this.superGrammar.toRecipe());
- }
- var startRule = null;
- if (this.defaultStartRule) {
- startRule = this.defaultStartRule;
- }
- var rules = {};
- var self = this;
- Object.keys(this.rules).forEach(function(ruleName) {
- var ruleInfo = self.rules[ruleName];
- var body = ruleInfo.body;
- var isDefinition = !self.superGrammar || !self.superGrammar.rules[ruleName];
- var operation;
- if (isDefinition) {
- operation = 'define';
- } else {
- operation = body instanceof pexprs.Extend ? 'extend' : 'override';
- }
- var metaInfo = {};
- if (ruleInfo.source && self.source) {
- var adjusted = ruleInfo.source.relativeTo(self.source);
- metaInfo.sourceInterval = [adjusted.startIdx, adjusted.endIdx];
- }
- var description = isDefinition ? ruleInfo.description : null;
- var bodyRecipe = body.outputRecipe(ruleInfo.formals, self.source);
- rules[ruleName] = [
- operation,
- metaInfo,
- description,
- ruleInfo.formals,
- bodyRecipe
- ];
- });
- return JSON.stringify([
- 'grammar',
- metaInfo,
- this.name,
- superGrammar,
- startRule,
- rules
- ]);
- },
-
-
- toOperationActionDictionaryTemplate: function() {
- return this._toOperationOrAttributeActionDictionaryTemplate();
- },
- toAttributeActionDictionaryTemplate: function() {
- return this._toOperationOrAttributeActionDictionaryTemplate();
- },
- _toOperationOrAttributeActionDictionaryTemplate: function() {
-
-
- var sb = new common.StringBuffer();
- sb.append('{');
- var first = true;
- for (var ruleName in this.rules) {
- var body = this.rules[ruleName].body;
- if (first) {
- first = false;
- } else {
- sb.append(',');
- }
- sb.append('\n');
- sb.append(' ');
- this.addSemanticActionTemplate(ruleName, body, sb);
- }
- sb.append('\n}');
- return sb.contents();
- },
- addSemanticActionTemplate: function(ruleName, body, sb) {
- sb.append(ruleName);
- sb.append(': function(');
- var arity = this._topDownActionArity(ruleName);
- sb.append(common.repeat('_', arity).join(', '));
- sb.append(') {\n');
- sb.append(' }');
- },
-
-
- parseApplication: function(str) {
- var app;
- if (str.indexOf('<') === -1) {
-
- app = new pexprs.Apply(str);
- } else {
-
- var cst = ohmGrammar.match(str, 'Base_application');
- app = buildGrammar(cst, {});
- }
-
- if (!(app.ruleName in this.rules)) {
- throw errors.undeclaredRule(app.ruleName, this.name);
- }
- var formals = this.rules[app.ruleName].formals;
- if (formals.length !== app.args.length) {
- var source = this.rules[app.ruleName].source;
- throw errors.wrongNumberOfParameters(app.ruleName, formals.length, app.args.length, source);
- }
- return app;
- }
- };
- Grammar.ProtoBuiltInRules = new Grammar(
- 'ProtoBuiltInRules',
- undefined,
- {
- any: {
- body: pexprs.any,
- formals: [],
- description: 'any character',
- primitive: true
- },
- end: {
- body: pexprs.end,
- formals: [],
- description: 'end of input',
- primitive: true
- },
- caseInsensitive: {
- body: new CaseInsensitiveTerminal(new pexprs.Param(0)),
- formals: ['str'],
- primitive: true
- },
- lower: {
- body: new pexprs.UnicodeChar('Ll'),
- formals: [],
- description: 'a lowercase letter',
- primitive: true
- },
- upper: {
- body: new pexprs.UnicodeChar('Lu'),
- formals: [],
- description: 'an uppercase letter',
- primitive: true
- },
-
- unicodeLtmo: {
- body: new pexprs.UnicodeChar('Ltmo'),
- formals: [],
- description: 'a Unicode character in Lt, Lm, or Lo',
- primitive: true
- },
-
-
- spaces: {
- body: new pexprs.Star(new pexprs.Apply('space')),
- formals: []
- },
- space: {
- body: new pexprs.Range('\x00', ' '),
- formals: [],
- description: 'a space'
- }
- }
- );
- module.exports = Grammar;
- },{"./CaseInsensitiveTerminal":31,"./Matcher":39,"./Semantics":42,"./common":44,"./errors":45,"./pexprs":64}],34:[function(require,module,exports){
- 'use strict';
- var Grammar = require('./Grammar');
- var InputStream = require('./InputStream');
- var common = require('./common');
- var errors = require('./errors');
- var pexprs = require('./pexprs');
- function GrammarDecl(name) {
- this.name = name;
- }
- GrammarDecl.prototype.sourceInterval = function(startIdx, endIdx) {
- return this.source.subInterval(startIdx, endIdx - startIdx);
- };
- GrammarDecl.prototype.ensureSuperGrammar = function() {
- if (!this.superGrammar) {
- this.withSuperGrammar(
-
-
-
- this.name === 'BuiltInRules' ?
- Grammar.ProtoBuiltInRules :
- Grammar.BuiltInRules);
- }
- return this.superGrammar;
- };
- GrammarDecl.prototype.installOverriddenOrExtendedRule = function(name, formals, body, source) {
- var duplicateParameterNames = common.getDuplicates(formals);
- if (duplicateParameterNames.length > 0) {
- throw errors.duplicateParameterNames(name, duplicateParameterNames, source);
- }
- var ruleInfo = this.ensureSuperGrammar().rules[name];
- var expectedFormals = ruleInfo.formals;
- var expectedNumFormals = expectedFormals ? expectedFormals.length : 0;
- if (formals.length !== expectedNumFormals) {
- throw errors.wrongNumberOfParameters(name, expectedNumFormals, formals.length, source);
- }
- return this.install(name, formals, body, ruleInfo.description, source);
- };
- GrammarDecl.prototype.install = function(name, formals, body, description, source) {
- this.rules[name] = {
- body: body.introduceParams(formals),
- formals: formals,
- description: description,
- source: source
- };
- return this;
- };
- GrammarDecl.prototype.withSuperGrammar = function(superGrammar) {
- if (this.superGrammar) {
- throw new Error('the super grammar of a GrammarDecl cannot be set more than once');
- }
- this.superGrammar = superGrammar;
- this.rules = Object.create(superGrammar.rules);
-
- if (!superGrammar.isBuiltIn()) {
- this.defaultStartRule = superGrammar.defaultStartRule;
- }
- return this;
- };
- GrammarDecl.prototype.withDefaultStartRule = function(ruleName) {
- this.defaultStartRule = ruleName;
- return this;
- };
- GrammarDecl.prototype.withSource = function(source) {
- this.source = new InputStream(source).interval(0, source.length);
- return this;
- };
- GrammarDecl.prototype.build = function() {
- var grammar = new Grammar(
- this.name,
- this.ensureSuperGrammar(),
- this.rules,
- this.defaultStartRule);
-
-
-
-
-
- var grammarErrors = [];
- var grammarHasInvalidApplications = false;
- Object.keys(grammar.rules).forEach(function(ruleName) {
- var body = grammar.rules[ruleName].body;
- try {
- body.assertChoicesHaveUniformArity(ruleName);
- } catch (e) {
- grammarErrors.push(e);
- }
- try {
- body.assertAllApplicationsAreValid(ruleName, grammar);
- } catch (e) {
- grammarErrors.push(e);
- grammarHasInvalidApplications = true;
- }
- });
- if (!grammarHasInvalidApplications) {
-
- Object.keys(grammar.rules).forEach(function(ruleName) {
- var body = grammar.rules[ruleName].body;
- try {
- body.assertIteratedExprsAreNotNullable(grammar, []);
- } catch (e) {
- grammarErrors.push(e);
- }
- });
- }
- if (grammarErrors.length > 0) {
- errors.throwErrors(grammarErrors);
- }
- if (this.source) {
- grammar.source = this.source;
- }
- return grammar;
- };
- GrammarDecl.prototype.define = function(name, formals, body, description, source) {
- this.ensureSuperGrammar();
- if (this.superGrammar.rules[name]) {
- throw errors.duplicateRuleDeclaration(name, this.name, this.superGrammar.name, source);
- } else if (this.rules[name]) {
- throw errors.duplicateRuleDeclaration(name, this.name, this.name, source);
- }
- var duplicateParameterNames = common.getDuplicates(formals);
- if (duplicateParameterNames.length > 0) {
- throw errors.duplicateParameterNames(name, duplicateParameterNames, source);
- }
- return this.install(name, formals, body, description, source);
- };
- GrammarDecl.prototype.override = function(name, formals, body, descIgnored, source) {
- var ruleInfo = this.ensureSuperGrammar().rules[name];
- if (!ruleInfo) {
- throw errors.cannotOverrideUndeclaredRule(name, this.superGrammar.name, source);
- }
- this.installOverriddenOrExtendedRule(name, formals, body, source);
- return this;
- };
- GrammarDecl.prototype.extend = function(name, formals, fragment, descIgnored, source) {
- var ruleInfo = this.ensureSuperGrammar().rules[name];
- if (!ruleInfo) {
- throw errors.cannotExtendUndeclaredRule(name, this.superGrammar.name, source);
- }
- var body = new pexprs.Extend(this.superGrammar, name, fragment);
- body.source = fragment.source;
- this.installOverriddenOrExtendedRule(name, formals, body, source);
- return this;
- };
- module.exports = GrammarDecl;
- },{"./Grammar":33,"./InputStream":35,"./common":44,"./errors":45,"./pexprs":64}],35:[function(require,module,exports){
- 'use strict';
- var Interval = require('./Interval');
- function InputStream(source) {
- this.source = source;
- this.pos = 0;
- this.examinedLength = 0;
- }
- InputStream.prototype = {
- atEnd: function() {
- var ans = this.pos === this.source.length;
- this.examinedLength = Math.max(this.examinedLength, this.pos + 1);
- return ans;
- },
- next: function() {
- var ans = this.source[this.pos++];
- this.examinedLength = Math.max(this.examinedLength, this.pos);
- return ans;
- },
- matchString: function(s, optIgnoreCase) {
- var idx;
- if (optIgnoreCase) {
-
- for (idx = 0; idx < s.length; idx++) {
- var actual = this.next();
- var expected = s[idx];
- if (actual == null || actual.toUpperCase() !== expected.toUpperCase()) {
- return false;
- }
- }
- return true;
- }
-
- for (idx = 0; idx < s.length; idx++) {
- if (this.next() !== s[idx]) { return false; }
- }
- return true;
- },
- sourceSlice: function(startIdx, endIdx) {
- return this.source.slice(startIdx, endIdx);
- },
- interval: function(startIdx, optEndIdx) {
- return new Interval(this.source, startIdx, optEndIdx ? optEndIdx : this.pos);
- }
- };
- module.exports = InputStream;
- },{"./Interval":36}],36:[function(require,module,exports){
- 'use strict';
- var assert = require('./common').assert;
- var errors = require('./errors');
- var util = require('./util');
- function Interval(sourceString, startIdx, endIdx) {
- this.sourceString = sourceString;
- this.startIdx = startIdx;
- this.endIdx = endIdx;
- }
- Interval.coverage = function(/* interval1, interval2, ... */) {
- var sourceString = arguments[0].sourceString;
- var startIdx = arguments[0].startIdx;
- var endIdx = arguments[0].endIdx;
- for (var idx = 1; idx < arguments.length; idx++) {
- var interval = arguments[idx];
- if (interval.sourceString !== sourceString) {
- throw errors.intervalSourcesDontMatch();
- } else {
- startIdx = Math.min(startIdx, arguments[idx].startIdx);
- endIdx = Math.max(endIdx, arguments[idx].endIdx);
- }
- }
- return new Interval(sourceString, startIdx, endIdx);
- };
- Interval.prototype = {
- coverageWith: function(/* interval1, interval2, ... */) {
- var intervals = Array.prototype.slice.call(arguments);
- intervals.push(this);
- return Interval.coverage.apply(undefined, intervals);
- },
- collapsedLeft: function() {
- return new Interval(this.sourceString, this.startIdx, this.startIdx);
- },
- collapsedRight: function() {
- return new Interval(this.sourceString, this.endIdx, this.endIdx);
- },
- getLineAndColumnMessage: function() {
- var range = [this.startIdx, this.endIdx];
- return util.getLineAndColumnMessage(this.sourceString, this.startIdx, range);
- },
-
-
- minus: function(that) {
- if (this.sourceString !== that.sourceString) {
- throw errors.intervalSourcesDontMatch();
- } else if (this.startIdx === that.startIdx && this.endIdx === that.endIdx) {
-
- return [
- ];
- } else if (this.startIdx < that.startIdx && that.endIdx < this.endIdx) {
-
- return [
- new Interval(this.sourceString, this.startIdx, that.startIdx),
- new Interval(this.sourceString, that.endIdx, this.endIdx)
- ];
- } else if (this.startIdx < that.endIdx && that.endIdx < this.endIdx) {
-
- return [
- new Interval(this.sourceString, that.endIdx, this.endIdx)
- ];
- } else if (this.startIdx < that.startIdx && that.startIdx < this.endIdx) {
-
- return [
- new Interval(this.sourceString, this.startIdx, that.startIdx)
- ];
- } else {
-
- return [
- this
- ];
- }
- },
-
-
- relativeTo: function(that) {
- if (this.sourceString !== that.sourceString) {
- throw errors.intervalSourcesDontMatch();
- }
- assert(this.startIdx >= that.startIdx && this.endIdx <= that.endIdx,
- 'other interval does not cover this one');
- return new Interval(this.sourceString,
- this.startIdx - that.startIdx,
- this.endIdx - that.startIdx);
- },
-
-
-
- trimmed: function() {
- var contents = this.contents;
- var startIdx = this.startIdx + contents.match(/^\s*/)[0].length;
- var endIdx = this.endIdx - contents.match(/\s*$/)[0].length;
- return new Interval(this.sourceString, startIdx, endIdx);
- },
- subInterval: function(offset, len) {
- var newStartIdx = this.startIdx + offset;
- return new Interval(this.sourceString, newStartIdx, newStartIdx + len);
- }
- };
- Object.defineProperties(Interval.prototype, {
- contents: {
- get: function() {
- if (this._contents === undefined) {
- this._contents = this.sourceString.slice(this.startIdx, this.endIdx);
- }
- return this._contents;
- },
- enumerable: true
- },
- length: {
- get: function() { return this.endIdx - this.startIdx; },
- enumerable: true
- }
- });
- module.exports = Interval;
- },{"./common":44,"./errors":45,"./util":65}],37:[function(require,module,exports){
- 'use strict';
- var common = require('./common');
- var util = require('./util');
- var Interval = require('./Interval');
- function MatchResult(
- matcher,
- input,
- startExpr,
- cst,
- cstOffset,
- rightmostFailurePosition,
- optRecordedFailures) {
- this.matcher = matcher;
- this.input = input;
- this.startExpr = startExpr;
- this._cst = cst;
- this._cstOffset = cstOffset;
- this._rightmostFailurePosition = rightmostFailurePosition;
- this._rightmostFailures = optRecordedFailures;
- if (this.failed()) {
- common.defineLazyProperty(this, 'message', function() {
- var detail = 'Expected ' + this.getExpectedText();
- return util.getLineAndColumnMessage(this.input, this.getRightmostFailurePosition()) + detail;
- });
- common.defineLazyProperty(this, 'shortMessage', function() {
- var detail = 'expected ' + this.getExpectedText();
- var errorInfo = util.getLineAndColumn(this.input, this.getRightmostFailurePosition());
- return 'Line ' + errorInfo.lineNum + ', col ' + errorInfo.colNum + ': ' + detail;
- });
- }
- }
- MatchResult.prototype.succeeded = function() {
- return !!this._cst;
- };
- MatchResult.prototype.failed = function() {
- return !this.succeeded();
- };
- MatchResult.prototype.getRightmostFailurePosition = function() {
- return this._rightmostFailurePosition;
- };
- MatchResult.prototype.getRightmostFailures = function() {
- if (!this._rightmostFailures) {
- this.matcher.setInput(this.input);
- var matchResultWithFailures =
- this.matcher._match(this.startExpr, false, this.getRightmostFailurePosition());
- this._rightmostFailures = matchResultWithFailures.getRightmostFailures();
- }
- return this._rightmostFailures;
- };
- MatchResult.prototype.toString = function() {
- return this.succeeded() ?
- '[match succeeded]' :
- '[match failed at position ' + this.getRightmostFailurePosition() + ']';
- };
- MatchResult.prototype.getExpectedText = function() {
- if (this.succeeded()) {
- throw new Error('cannot get expected text of a successful MatchResult');
- }
- var sb = new common.StringBuffer();
- var failures = this.getRightmostFailures();
-
- failures = failures.filter(function(failure) {
- return !failure.isFluffy();
- });
- for (var idx = 0; idx < failures.length; idx++) {
- if (idx > 0) {
- if (idx === failures.length - 1) {
- sb.append(failures.length > 2 ? ', or ' : ' or ');
- } else {
- sb.append(', ');
- }
- }
- sb.append(failures[idx].toString());
- }
- return sb.contents();
- };
- MatchResult.prototype.getInterval = function() {
- var pos = this.getRightmostFailurePosition();
- return new Interval(this.input, pos, pos);
- };
- module.exports = MatchResult;
- },{"./Interval":36,"./common":44,"./util":65}],38:[function(require,module,exports){
- 'use strict';
- var InputStream = require('./InputStream');
- var MatchResult = require('./MatchResult');
- var PosInfo = require('./PosInfo');
- var Trace = require('./Trace');
- var pexprs = require('./pexprs');
- var applySpaces = new pexprs.Apply('spaces');
- function MatchState(matcher, startExpr, optPositionToRecordFailures) {
- this.matcher = matcher;
- this.startExpr = startExpr;
- this.grammar = matcher.grammar;
- this.input = matcher.input;
- this.inputStream = new InputStream(matcher.input);
- this.memoTable = matcher.memoTable;
- this._bindings = [];
- this._bindingOffsets = [];
- this._applicationStack = [];
- this._posStack = [0];
- this.inLexifiedContextStack = [false];
- this.rightmostFailurePosition = -1;
- this._rightmostFailurePositionStack = [];
- this._recordedFailuresStack = [];
- if (optPositionToRecordFailures !== undefined) {
- this.positionToRecordFailures = optPositionToRecordFailures;
- this.recordedFailures = Object.create(null);
- }
- }
- MatchState.prototype = {
- posToOffset: function(pos) {
- return pos - this._posStack[this._posStack.length - 1];
- },
- enterApplication: function(posInfo, app) {
- this._posStack.push(this.inputStream.pos);
- this._applicationStack.push(app);
- this.inLexifiedContextStack.push(false);
- posInfo.enter(app);
- this._rightmostFailurePositionStack.push(this.rightmostFailurePosition);
- this.rightmostFailurePosition = -1;
- },
- exitApplication: function(posInfo, optNode) {
- var origPos = this._posStack.pop();
- this._applicationStack.pop();
- this.inLexifiedContextStack.pop();
- posInfo.exit();
- this.rightmostFailurePosition = Math.max(
- this.rightmostFailurePosition,
- this._rightmostFailurePositionStack.pop());
- if (optNode) {
- this.pushBinding(optNode, origPos);
- }
- },
- enterLexifiedContext: function() {
- this.inLexifiedContextStack.push(true);
- },
- exitLexifiedContext: function() {
- this.inLexifiedContextStack.pop();
- },
- currentApplication: function() {
- return this._applicationStack[this._applicationStack.length - 1];
- },
- inSyntacticContext: function() {
- if (typeof this.inputStream.source !== 'string') {
- return false;
- }
- var currentApplication = this.currentApplication();
- if (currentApplication) {
- return currentApplication.isSyntactic() && !this.inLexifiedContext();
- } else {
-
- return this.startExpr.factors[0].isSyntactic();
- }
- },
- inLexifiedContext: function() {
- return this.inLexifiedContextStack[this.inLexifiedContextStack.length - 1];
- },
- skipSpaces: function() {
- this.pushFailuresInfo();
- this.eval(applySpaces);
- this.popBinding();
- this.popFailuresInfo();
- return this.inputStream.pos;
- },
- skipSpacesIfInSyntacticContext: function() {
- return this.inSyntacticContext() ?
- this.skipSpaces() :
- this.inputStream.pos;
- },
- maybeSkipSpacesBefore: function(expr) {
- if (expr instanceof pexprs.Apply && expr.isSyntactic()) {
- return this.skipSpaces();
- } else if (expr.allowsSkippingPrecedingSpace() && expr !== applySpaces) {
- return this.skipSpacesIfInSyntacticContext();
- } else {
- return this.inputStream.pos;
- }
- },
- pushBinding: function(node, origPos) {
- this._bindings.push(node);
- this._bindingOffsets.push(this.posToOffset(origPos));
- },
- popBinding: function() {
- this._bindings.pop();
- this._bindingOffsets.pop();
- },
- numBindings: function() {
- return this._bindings.length;
- },
- truncateBindings: function(newLength) {
-
-
- while (this._bindings.length > newLength) {
- this.popBinding();
- }
- },
- getCurrentPosInfo: function() {
- return this.getPosInfo(this.inputStream.pos);
- },
- getPosInfo: function(pos) {
- var posInfo = this.memoTable[pos];
- if (!posInfo) {
- posInfo = this.memoTable[pos] = new PosInfo();
- }
- return posInfo;
- },
- processFailure: function(pos, expr) {
- this.rightmostFailurePosition = Math.max(this.rightmostFailurePosition, pos);
- if (this.recordedFailures && pos === this.positionToRecordFailures) {
- var app = this.currentApplication();
- if (app) {
-
-
- expr = expr.substituteParams(app.args);
- } else {
-
-
-
-
- }
- this.recordFailure(expr.toFailure(this.grammar), false);
- }
- },
- recordFailure: function(failure, shouldCloneIfNew) {
- var key = failure.toKey();
- if (!this.recordedFailures[key]) {
- this.recordedFailures[key] = shouldCloneIfNew ? failure.clone() : failure;
- } else if (this.recordedFailures[key].isFluffy() && !failure.isFluffy()) {
- this.recordedFailures[key].clearFluffy();
- }
- },
- recordFailures: function(failures, shouldCloneIfNew) {
- var self = this;
- Object.keys(failures).forEach(function(key) {
- self.recordFailure(failures[key], shouldCloneIfNew);
- });
- },
- cloneRecordedFailures: function() {
- if (!this.recordedFailures) {
- return undefined;
- }
- var ans = Object.create(null);
- var self = this;
- Object.keys(this.recordedFailures).forEach(function(key) {
- ans[key] = self.recordedFailures[key].clone();
- });
- return ans;
- },
- getRightmostFailurePosition: function() {
- return this.rightmostFailurePosition;
- },
- _getRightmostFailureOffset: function() {
- return this.rightmostFailurePosition >= 0 ?
- this.posToOffset(this.rightmostFailurePosition) :
- -1;
- },
-
- getMemoizedTraceEntry: function(pos, expr) {
- var posInfo = this.memoTable[pos];
- if (posInfo && expr.ruleName) {
- var memoRec = posInfo.memo[expr.toMemoKey()];
- if (memoRec && memoRec.traceEntry) {
- var entry = memoRec.traceEntry.cloneWithExpr(expr);
- entry.isMemoized = true;
- return entry;
- }
- }
- return null;
- },
-
- getTraceEntry: function(pos, expr, succeeded, bindings) {
- if (expr instanceof pexprs.Apply) {
- var app = this.currentApplication();
- var actuals = app ? app.args : [];
- expr = expr.substituteParams(actuals);
- }
- return this.getMemoizedTraceEntry(pos, expr) ||
- new Trace(this.input, pos, this.inputStream.pos, expr, succeeded, bindings, this.trace);
- },
- isTracing: function() {
- return !!this.trace;
- },
- hasNecessaryInfo: function(memoRec) {
- if (this.trace && !memoRec.traceEntry) {
- return false;
- }
- if (this.recordedFailures &&
- this.inputStream.pos + memoRec.rightmostFailureOffset === this.positionToRecordFailures) {
- return !!memoRec.failuresAtRightmostPosition;
- }
- return true;
- },
- useMemoizedResult: function(origPos, memoRec) {
- if (this.trace) {
- this.trace.push(memoRec.traceEntry);
- }
- var memoRecRightmostFailurePosition = this.inputStream.pos + memoRec.rightmostFailureOffset;
- this.rightmostFailurePosition =
- Math.max(this.rightmostFailurePosition, memoRecRightmostFailurePosition);
- if (this.recordedFailures &&
- this.positionToRecordFailures === memoRecRightmostFailurePosition &&
- memoRec.failuresAtRightmostPosition) {
- this.recordFailures(memoRec.failuresAtRightmostPosition, true);
- }
- this.inputStream.examinedLength =
- Math.max(this.inputStream.examinedLength, memoRec.examinedLength + origPos);
- if (memoRec.value) {
- this.inputStream.pos += memoRec.matchLength;
- this.pushBinding(memoRec.value, origPos);
- return true;
- }
- return false;
- },
-
-
-
- eval: function(expr) {
- var inputStream = this.inputStream;
- var origNumBindings = this._bindings.length;
- var origRecordedFailures;
- if (this.recordedFailures) {
- origRecordedFailures = this.recordedFailures;
- this.recordedFailures = Object.create(null);
- }
- var origPos = inputStream.pos;
- var memoPos = this.maybeSkipSpacesBefore(expr);
- var origTrace;
- if (this.trace) {
- origTrace = this.trace;
- this.trace = [];
- }
-
- var ans = expr.eval(this);
- if (this.trace) {
- var bindings = this._bindings.slice(origNumBindings);
- var traceEntry = this.getTraceEntry(memoPos, expr, ans, bindings);
- traceEntry.isImplicitSpaces = expr === applySpaces;
- traceEntry.isRootNode = expr === this.startExpr;
- origTrace.push(traceEntry);
- this.trace = origTrace;
- }
- if (ans) {
- if (this.recordedFailures && inputStream.pos === this.positionToRecordFailures) {
- var self = this;
- Object.keys(this.recordedFailures).forEach(function(key) {
- self.recordedFailures[key].makeFluffy();
- });
- }
- } else {
-
- inputStream.pos = origPos;
- this.truncateBindings(origNumBindings);
- }
- if (this.recordedFailures) {
- this.recordFailures(origRecordedFailures, false);
- }
- return ans;
- },
- getMatchResult: function() {
- this.eval(this.startExpr);
- var rightmostFailures;
- if (this.recordedFailures) {
- var self = this;
- rightmostFailures = Object.keys(this.recordedFailures).map(function(key) {
- return self.recordedFailures[key];
- });
- }
- return new MatchResult(
- this.matcher,
- this.input,
- this.startExpr,
- this._bindings[0],
- this._bindingOffsets[0],
- this.rightmostFailurePosition,
- rightmostFailures);
- },
- getTrace: function() {
- this.trace = [];
- var matchResult = this.getMatchResult();
-
-
-
-
- var rootTrace = this.trace[this.trace.length - 1];
- rootTrace.result = matchResult;
- return rootTrace;
- },
- pushFailuresInfo: function() {
- this._rightmostFailurePositionStack.push(this.rightmostFailurePosition);
- this._recordedFailuresStack.push(this.recordedFailures);
- },
- popFailuresInfo: function() {
- this.rightmostFailurePosition = this._rightmostFailurePositionStack.pop();
- this.recordedFailures = this._recordedFailuresStack.pop();
- }
- };
- module.exports = MatchState;
- },{"./InputStream":35,"./MatchResult":37,"./PosInfo":41,"./Trace":43,"./pexprs":64}],39:[function(require,module,exports){
- 'use strict';
- var MatchState = require('./MatchState');
- var pexprs = require('./pexprs');
- function Matcher(grammar) {
- this.grammar = grammar;
- this.memoTable = [];
- this.input = '';
- }
- Matcher.prototype.getInput = function() {
- return this.input;
- };
- Matcher.prototype.setInput = function(str) {
- if (this.input !== str) {
- this.replaceInputRange(0, this.input.length, str);
- }
- return this;
- };
- Matcher.prototype.replaceInputRange = function(startIdx, endIdx, str) {
- var currentInput = this.input;
- if (startIdx < 0 || startIdx > currentInput.length ||
- endIdx < 0 || endIdx > currentInput.length ||
- startIdx > endIdx) {
- throw new Error('Invalid indices: ' + startIdx + ' and ' + endIdx);
- }
-
- this.input = currentInput.slice(0, startIdx) + str + currentInput.slice(endIdx);
-
- var restOfMemoTable = this.memoTable.slice(endIdx);
- this.memoTable.length = startIdx;
- for (var idx = 0; idx < str.length; idx++) {
- this.memoTable.push(undefined);
- }
- restOfMemoTable.forEach(
- function(posInfo) { this.memoTable.push(posInfo); },
- this);
-
- for (var pos = 0; pos < startIdx; pos++) {
- var posInfo = this.memoTable[pos];
- if (posInfo) {
- posInfo.clearObsoleteEntries(pos, startIdx);
- }
- }
- return this;
- };
- Matcher.prototype.match = function(optStartApplicationStr) {
- return this._match(this._getStartExpr(optStartApplicationStr), false);
- };
- Matcher.prototype.trace = function(optStartApplicationStr) {
- return this._match(this._getStartExpr(optStartApplicationStr), true);
- };
- Matcher.prototype._match = function(startExpr, tracing, optPositionToRecordFailures) {
- var state = new MatchState(this, startExpr, optPositionToRecordFailures);
- return tracing ? state.getTrace() : state.getMatchResult();
- };
- Matcher.prototype._getStartExpr = function(optStartApplicationStr) {
- var applicationStr = optStartApplicationStr || this.grammar.defaultStartRule;
- if (!applicationStr) {
- throw new Error('Missing start rule argument -- the grammar has no default start rule.');
- }
- var startApp = this.grammar.parseApplication(applicationStr);
- return new pexprs.Seq([startApp, pexprs.end]);
- };
- module.exports = Matcher;
- },{"./MatchState":38,"./pexprs":64}],40:[function(require,module,exports){
- 'use strict';
- var extend = require('util-extend');
- function Namespace() {
- }
- Namespace.prototype = Object.create(null);
- Namespace.asNamespace = function(objOrNamespace) {
- if (objOrNamespace instanceof Namespace) {
- return objOrNamespace;
- }
- return Namespace.createNamespace(objOrNamespace);
- };
- Namespace.createNamespace = function(optProps) {
- return Namespace.extend(Namespace.prototype, optProps);
- };
- Namespace.extend = function(namespace, optProps) {
- if (namespace !== Namespace.prototype && !(namespace instanceof Namespace)) {
- throw new TypeError('not a Namespace object: ' + namespace);
- }
- var ns = Object.create(namespace, {
- constructor: {
- value: Namespace,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- return extend(ns, optProps);
- };
- Namespace.toString = function(ns) {
- return Object.prototype.toString.call(ns);
- };
- module.exports = Namespace;
- },{"util-extend":29}],41:[function(require,module,exports){
- 'use strict';
- function PosInfo() {
- this.applicationMemoKeyStack = [];
- this.memo = {};
- this.maxExaminedLength = 0;
- this.maxRightmostFailureOffset = -1;
- this.currentLeftRecursion = undefined;
- }
- PosInfo.prototype = {
- isActive: function(application) {
- return this.applicationMemoKeyStack.indexOf(application.toMemoKey()) >= 0;
- },
- enter: function(application) {
- this.applicationMemoKeyStack.push(application.toMemoKey());
- },
- exit: function() {
- this.applicationMemoKeyStack.pop();
- },
- startLeftRecursion: function(headApplication, memoRec) {
- memoRec.isLeftRecursion = true;
- memoRec.headApplication = headApplication;
- memoRec.nextLeftRecursion = this.currentLeftRecursion;
- this.currentLeftRecursion = memoRec;
- var applicationMemoKeyStack = this.applicationMemoKeyStack;
- var indexOfFirstInvolvedRule = applicationMemoKeyStack.indexOf(headApplication.toMemoKey()) + 1;
- var involvedApplicationMemoKeys = applicationMemoKeyStack.slice(indexOfFirstInvolvedRule);
- memoRec.isInvolved = function(applicationMemoKey) {
- return involvedApplicationMemoKeys.indexOf(applicationMemoKey) >= 0;
- };
- memoRec.updateInvolvedApplicationMemoKeys = function() {
- for (var idx = indexOfFirstInvolvedRule; idx < applicationMemoKeyStack.length; idx++) {
- var applicationMemoKey = applicationMemoKeyStack[idx];
- if (!this.isInvolved(applicationMemoKey)) {
- involvedApplicationMemoKeys.push(applicationMemoKey);
- }
- }
- };
- },
- endLeftRecursion: function() {
- this.currentLeftRecursion = this.currentLeftRecursion.nextLeftRecursion;
- },
-
-
- shouldUseMemoizedResult: function(memoRec) {
- if (!memoRec.isLeftRecursion) {
- return true;
- }
- var applicationMemoKeyStack = this.applicationMemoKeyStack;
- for (var idx = 0; idx < applicationMemoKeyStack.length; idx++) {
- var applicationMemoKey = applicationMemoKeyStack[idx];
- if (memoRec.isInvolved(applicationMemoKey)) {
- return false;
- }
- }
- return true;
- },
- memoize: function(memoKey, memoRec) {
- this.memo[memoKey] = memoRec;
- this.maxExaminedLength = Math.max(this.maxExaminedLength, memoRec.examinedLength);
- this.maxRightmostFailureOffset =
- Math.max(this.maxRightmostFailureOffset, memoRec.rightmostFailureOffset);
- return memoRec;
- },
- clearObsoleteEntries: function(pos, invalidatedIdx) {
- if (pos + this.maxExaminedLength <= invalidatedIdx) {
-
-
- return;
- }
- var memo = this.memo;
- this.maxExaminedLength = 0;
- this.maxRightmostFailureOffset = -1;
- var self = this;
- Object.keys(memo).forEach(function(k) {
- var memoRec = memo[k];
- if (pos + memoRec.examinedLength > invalidatedIdx) {
- delete memo[k];
- } else {
- self.maxExaminedLength = Math.max(self.maxExaminedLength, memoRec.examinedLength);
- self.maxRightmostFailureOffset =
- Math.max(self.maxRightmostFailureOffset, memoRec.rightmostFailureOffset);
- }
- });
- }
- };
- module.exports = PosInfo;
- },{}],42:[function(require,module,exports){
- 'use strict';
- var Symbol = require('es6-symbol');
- var inherits = require('inherits');
- var InputStream = require('./InputStream');
- var IterationNode = require('./nodes').IterationNode;
- var MatchResult = require('./MatchResult');
- var common = require('./common');
- var errors = require('./errors');
- var util = require('./util');
- var globalActionStack = [];
- var prototypeGrammar;
- var prototypeGrammarSemantics;
- function jsonToJS(str) {
- var output = str.replace(/[\u2028\u2029]/g, function(char, pos, str) {
- var hex = char.codePointAt(0).toString(16);
- return '\\u' + '0000'.slice(hex.length) + hex;
- });
- return output;
- }
- function Wrapper() {}
- Wrapper.prototype.toString = function() {
- return '[semantics wrapper for ' + this._node.grammar.name + ']';
- };
- Wrapper.prototype.toJSON = function() {
- return this.toString();
- };
- Wrapper.prototype._forgetMemoizedResultFor = function(attributeName) {
-
- delete this._node[this._semantics.attributeKeys[attributeName]];
- this.children.forEach(function(child) {
- child._forgetMemoizedResultFor(attributeName);
- });
- };
- Wrapper.prototype.child = function(idx) {
- if (!(0 <= idx && idx < this._node.numChildren())) {
-
- return undefined;
- }
- var childWrapper = this._childWrappers[idx];
- if (!childWrapper) {
- var childNode = this._node.childAt(idx);
- var offset = this._node.childOffsets[idx];
- var source = this._baseInterval.subInterval(offset, childNode.matchLength);
- var base = childNode.isNonterminal() ? source : this._baseInterval;
- childWrapper = this._childWrappers[idx] = this._semantics.wrap(childNode, source, base);
- }
- return childWrapper;
- };
- Wrapper.prototype._children = function() {
-
- for (var idx = 0; idx < this._node.numChildren(); idx++) {
- this.child(idx);
- }
- return this._childWrappers;
- };
- Wrapper.prototype.isIteration = function() {
- return this._node.isIteration();
- };
- Wrapper.prototype.isTerminal = function() {
- return this._node.isTerminal();
- };
- Wrapper.prototype.isNonterminal = function() {
- return this._node.isNonterminal();
- };
- Wrapper.prototype.isSyntactic = function() {
- return this.isNonterminal() && this._node.isSyntactic();
- };
- Wrapper.prototype.isLexical = function() {
- return this.isNonterminal() && this._node.isLexical();
- };
- Wrapper.prototype.isOptional = function() {
- return this._node.isOptional();
- };
- Wrapper.prototype.iteration = function(optChildWrappers) {
- var childWrappers = optChildWrappers || [];
- var childNodes = childWrappers.map(function(c) { return c._node; });
- var iter = new IterationNode(this._node.grammar, childNodes, [], -1, false);
- var wrapper = this._semantics.wrap(iter, null, null);
- wrapper._childWrappers = childWrappers;
- return wrapper;
- };
- Object.defineProperties(Wrapper.prototype, {
-
- children: {get: function() { return this._children(); }},
-
- ctorName: {get: function() { return this._node.ctorName; }},
-
- interval: {get: function() {
- throw new Error('The `interval` property is deprecated -- use `source` instead');
- }},
-
- numChildren: {get: function() { return this._node.numChildren(); }},
-
-
- primitiveValue: {
- get: function() {
- if (this.isTerminal()) {
- return this._node.primitiveValue;
- }
- throw new TypeError(
- "tried to access the 'primitiveValue' attribute of a non-terminal CST node");
- }
- },
-
- sourceString: {get: function() { return this.source.contents; }}
- });
- function Semantics(grammar, superSemantics) {
- var self = this;
- this.grammar = grammar;
- this.checkedActionDicts = false;
-
-
-
-
-
- this.Wrapper = function(node, sourceInterval, baseInterval) {
- self.checkActionDictsIfHaventAlready();
- this._semantics = self;
- this._node = node;
- this.source = sourceInterval;
-
-
- this._baseInterval = baseInterval;
- if (node.isNonterminal()) {
- common.assert(sourceInterval === baseInterval);
- }
- this._childWrappers = [];
- };
- this.super = superSemantics;
- if (superSemantics) {
- if (!(grammar.equals(this.super.grammar) || grammar._inheritsFrom(this.super.grammar))) {
- throw new Error(
- "Cannot extend a semantics for grammar '" + this.super.grammar.name +
- "' for use with grammar '" + grammar.name + "' (not a sub-grammar)");
- }
- inherits(this.Wrapper, this.super.Wrapper);
- this.operations = Object.create(this.super.operations);
- this.attributes = Object.create(this.super.attributes);
- this.attributeKeys = Object.create(null);
-
-
- for (var attributeName in this.attributes) {
- this.attributeKeys[attributeName] = Symbol();
- }
- } else {
- inherits(this.Wrapper, Wrapper);
- this.operations = Object.create(null);
- this.attributes = Object.create(null);
- this.attributeKeys = Object.create(null);
- }
- }
- Semantics.prototype.toString = function() {
- return '[semantics for ' + this.grammar.name + ']';
- };
- Semantics.prototype.checkActionDictsIfHaventAlready = function() {
- if (!this.checkedActionDicts) {
- this.checkActionDicts();
- this.checkedActionDicts = true;
- }
- };
- Semantics.prototype.checkActionDicts = function() {
- var name;
- for (name in this.operations) {
- this.operations[name].checkActionDict(this.grammar);
- }
- for (name in this.attributes) {
- this.attributes[name].checkActionDict(this.grammar);
- }
- };
- Semantics.prototype.toRecipe = function(semanticsOnly) {
- function hasSuperSemantics(s) {
- return s.super !== Semantics.BuiltInSemantics._getSemantics();
- }
- var str = '(function(g) {\n';
- if (hasSuperSemantics(this)) {
- str += ' var semantics = ' + this.super.toRecipe(true) + '(g';
- var superSemanticsGrammar = this.super.grammar;
- var relatedGrammar = this.grammar;
- while (relatedGrammar !== superSemanticsGrammar) {
- str += '.superGrammar';
- relatedGrammar = relatedGrammar.superGrammar;
- }
- str += ');\n';
- str += ' return g.extendSemantics(semantics)';
- } else {
- str += ' return g.createSemantics()';
- }
- ['Operation', 'Attribute'].forEach(function(type) {
- var semanticOperations = this[type.toLowerCase() + 's'];
- Object.keys(semanticOperations).forEach(function(name) {
- var signature = name;
- if (semanticOperations[name].formals.length > 0) {
- signature += '(' + semanticOperations[name].formals.join(', ') + ')';
- }
- var method;
- if (hasSuperSemantics(this) && this.super[type.toLowerCase() + 's'][name]) {
- method = 'extend' + type;
- } else {
- method = 'add' + type;
- }
- str += '\n .' + method + '(' + JSON.stringify(signature) + ', {';
- var actions = semanticOperations[name].actionDict;
- var srcArray = [];
- Object.keys(actions).forEach(function(actionName) {
- if (semanticOperations[name].builtInDefault !== actions[actionName]) {
- srcArray.push('\n ' + JSON.stringify(actionName) + ': ' +
- actions[actionName].toString());
- }
- });
- str += srcArray.join(',');
- str += '\n })';
- }, this);
- }, this);
- str += ';\n })';
- if (!semanticsOnly) {
- str =
- '(function() {\n' +
- ' var grammar = this.fromRecipe(' + jsonToJS(this.grammar.toRecipe()) + ');\n' +
- ' var semantics = ' + str + '(grammar);\n' +
- ' return semantics;\n' +
- '});\n';
- }
- return str;
- };
- function parseSignature(signature, type) {
- if (!prototypeGrammar) {
-
-
-
- common.assert(signature.indexOf('(') === -1);
- return {
- name: signature,
- formals: []
- };
- }
- var r = prototypeGrammar.match(
- signature,
- type === 'operation' ? 'OperationSignature' : 'AttributeSignature');
- if (r.failed()) {
- throw new Error(r.message);
- }
- return prototypeGrammarSemantics(r).parse();
- }
- function newDefaultAction(type, name, doIt) {
- return function(children) {
- var self = this;
- var thisThing = this._semantics.operations[name] || this._semantics.attributes[name];
- var args = thisThing.formals.map(function(formal) {
- return self.args[formal];
- });
- if (this.isIteration()) {
-
-
- return children.map(function(child) { return doIt.apply(child, args); });
- }
-
-
-
- if (children.length === 1) {
-
-
- return doIt.apply(children[0], args);
- } else {
-
-
- throw errors.missingSemanticAction(this.ctorName, name, type, globalActionStack);
- }
- };
- }
- Semantics.prototype.addOperationOrAttribute = function(type, signature, actionDict) {
- var typePlural = type + 's';
- var parsedNameAndFormalArgs = parseSignature(signature, type);
- var name = parsedNameAndFormalArgs.name;
- var formals = parsedNameAndFormalArgs.formals;
-
- this.assertNewName(name, type);
-
-
- var builtInDefault = newDefaultAction(type, name, doIt);
- var realActionDict = {_default: builtInDefault};
-
-
- Object.keys(actionDict).forEach(function(name) {
- realActionDict[name] = actionDict[name];
- });
- var entry = type === 'operation' ?
- new Operation(name, formals, realActionDict, builtInDefault) :
- new Attribute(name, realActionDict, builtInDefault);
-
-
- entry.checkActionDict(this.grammar);
- this[typePlural][name] = entry;
- function doIt() {
-
-
- var thisThing = this._semantics[typePlural][name];
-
- if (arguments.length !== thisThing.formals.length) {
- throw new Error(
- 'Invalid number of arguments passed to ' + name + ' ' + type + ' (expected ' +
- thisThing.formals.length + ', got ' + arguments.length + ')');
- }
-
-
- var args = Object.create(null);
- for (var idx = 0; idx < arguments.length; idx++) {
- var formal = thisThing.formals[idx];
- args[formal] = arguments[idx];
- }
- var oldArgs = this.args;
- this.args = args;
- var ans = thisThing.execute(this._semantics, this);
- this.args = oldArgs;
- return ans;
- }
- if (type === 'operation') {
- this.Wrapper.prototype[name] = doIt;
- this.Wrapper.prototype[name].toString = function() {
- return '[' + name + ' operation]';
- };
- } else {
- Object.defineProperty(this.Wrapper.prototype, name, {
- get: doIt,
- configurable: true
- });
- this.attributeKeys[name] = Symbol();
- }
- };
- Semantics.prototype.extendOperationOrAttribute = function(type, name, actionDict) {
- var typePlural = type + 's';
-
- parseSignature(name, 'attribute');
- if (!(this.super && name in this.super[typePlural])) {
- throw new Error('Cannot extend ' + type + " '" + name +
- "': did not inherit an " + type + ' with that name');
- }
- if (Object.prototype.hasOwnProperty.call(this[typePlural], name)) {
- throw new Error('Cannot extend ' + type + " '" + name + "' again");
- }
-
-
- var inheritedFormals = this[typePlural][name].formals;
- var inheritedActionDict = this[typePlural][name].actionDict;
- var newActionDict = Object.create(inheritedActionDict);
- Object.keys(actionDict).forEach(function(name) {
- newActionDict[name] = actionDict[name];
- });
- this[typePlural][name] = type === 'operation' ?
- new Operation(name, inheritedFormals, newActionDict) :
- new Attribute(name, newActionDict);
-
-
- this[typePlural][name].checkActionDict(this.grammar);
- };
- Semantics.prototype.assertNewName = function(name, type) {
- if (Wrapper.prototype.hasOwnProperty(name)) {
- throw new Error(
- 'Cannot add ' + type + " '" + name + "': that's a reserved name");
- }
- if (name in this.operations) {
- throw new Error(
- 'Cannot add ' + type + " '" + name + "': an operation with that name already exists");
- }
- if (name in this.attributes) {
- throw new Error(
- 'Cannot add ' + type + " '" + name + "': an attribute with that name already exists");
- }
- };
- Semantics.prototype.wrap = function(node, source, optBaseInterval) {
- var baseInterval = optBaseInterval || source;
- return node instanceof this.Wrapper ? node : new this.Wrapper(node, source, baseInterval);
- };
- Semantics.createSemantics = function(grammar, optSuperSemantics) {
- var s = new Semantics(
- grammar,
- optSuperSemantics !== undefined ?
- optSuperSemantics :
- Semantics.BuiltInSemantics._getSemantics());
-
-
- var proxy = function ASemantics(matchResult) {
- if (!(matchResult instanceof MatchResult)) {
- throw new TypeError(
- 'Semantics expected a MatchResult, but got ' + common.unexpectedObjToString(matchResult));
- }
- if (matchResult.failed()) {
- throw new TypeError('cannot apply Semantics to ' + matchResult.toString());
- }
- var cst = matchResult._cst;
- if (cst.grammar !== grammar) {
- throw new Error(
- "Cannot use a MatchResult from grammar '" + cst.grammar.name +
- "' with a semantics for '" + grammar.name + "'");
- }
- var inputStream = new InputStream(matchResult.input);
- return s.wrap(cst, inputStream.interval(matchResult._cstOffset, matchResult.input.length));
- };
-
- proxy.addOperation = function(signature, actionDict) {
- s.addOperationOrAttribute('operation', signature, actionDict);
- return proxy;
- };
- proxy.extendOperation = function(name, actionDict) {
- s.extendOperationOrAttribute('operation', name, actionDict);
- return proxy;
- };
- proxy.addAttribute = function(name, actionDict) {
- s.addOperationOrAttribute('attribute', name, actionDict);
- return proxy;
- };
- proxy.extendAttribute = function(name, actionDict) {
- s.extendOperationOrAttribute('attribute', name, actionDict);
- return proxy;
- };
- proxy._getActionDict = function(operationOrAttributeName) {
- var action = s.operations[operationOrAttributeName] || s.attributes[operationOrAttributeName];
- if (!action) {
- throw new Error('"' + operationOrAttributeName + '" is not a valid operation or attribute ' +
- 'name in this semantics for "' + grammar.name + '"');
- }
- return action.actionDict;
- };
- proxy._remove = function(operationOrAttributeName) {
- var semantic;
- if (operationOrAttributeName in s.operations) {
- semantic = s.operations[operationOrAttributeName];
- delete s.operations[operationOrAttributeName];
- } else if (operationOrAttributeName in s.attributes) {
- semantic = s.attributes[operationOrAttributeName];
- delete s.attributes[operationOrAttributeName];
- }
- delete s.Wrapper.prototype[operationOrAttributeName];
- return semantic;
- };
- proxy.getOperationNames = function() {
- return Object.keys(s.operations);
- };
- proxy.getAttributeNames = function() {
- return Object.keys(s.attributes);
- };
- proxy.getGrammar = function() {
- return s.grammar;
- };
- proxy.toRecipe = function(semanticsOnly) {
- return s.toRecipe(semanticsOnly);
- };
-
- proxy.toString = s.toString.bind(s);
-
- proxy._getSemantics = function() {
- return s;
- };
- return proxy;
- };
- function Operation(name, formals, actionDict, builtInDefault) {
- this.name = name;
- this.formals = formals;
- this.actionDict = actionDict;
- this.builtInDefault = builtInDefault;
- }
- Operation.prototype.typeName = 'operation';
- Operation.prototype.checkActionDict = function(grammar) {
- grammar._checkTopDownActionDict(this.typeName, this.name, this.actionDict);
- };
- Operation.prototype.execute = function(semantics, nodeWrapper) {
- try {
-
-
-
-
- var ctorName = nodeWrapper._node.ctorName;
- var actionFn = this.actionDict[ctorName];
- var ans;
- if (actionFn) {
- globalActionStack.push([this, ctorName]);
- ans = this.doAction(semantics, nodeWrapper, actionFn, nodeWrapper.isIteration());
- return ans;
- }
-
-
-
- if (nodeWrapper.isNonterminal()) {
- actionFn = this.actionDict._nonterminal;
- if (actionFn) {
- globalActionStack.push([this, '_nonterminal', ctorName]);
- ans = this.doAction(semantics, nodeWrapper, actionFn, true);
- return ans;
- }
- }
-
- globalActionStack.push([this, 'default action', ctorName]);
- ans = this.doAction(semantics, nodeWrapper, this.actionDict._default, true);
- return ans;
- } finally {
- globalActionStack.pop();
- }
- };
- Operation.prototype.doAction = function(semantics, nodeWrapper, actionFn, optPassChildrenAsArray) {
- return optPassChildrenAsArray ?
- actionFn.call(nodeWrapper, nodeWrapper._children()) :
- actionFn.apply(nodeWrapper, nodeWrapper._children());
- };
- function Attribute(name, actionDict, builtInDefault) {
- this.name = name;
- this.formals = [];
- this.actionDict = actionDict;
- this.builtInDefault = builtInDefault;
- }
- inherits(Attribute, Operation);
- Attribute.prototype.typeName = 'attribute';
- Attribute.prototype.execute = function(semantics, nodeWrapper) {
- var node = nodeWrapper._node;
- var key = semantics.attributeKeys[this.name];
- if (!node.hasOwnProperty(key)) {
-
- node[key] = Operation.prototype.execute.call(this, semantics, nodeWrapper);
- }
- return node[key];
- };
- util.awaitBuiltInRules(function(builtInRules) {
- var operationsAndAttributesGrammar = require('../dist/operations-and-attributes');
- initBuiltInSemantics(builtInRules);
- initPrototypeParser(operationsAndAttributesGrammar);
- });
- function initBuiltInSemantics(builtInRules) {
- var actions = {
- empty: function() {
- return this.iteration();
- },
- nonEmpty: function(first, _, rest) {
- return this.iteration([first].concat(rest.children));
- }
- };
- Semantics.BuiltInSemantics = Semantics
- .createSemantics(builtInRules, null)
- .addOperation('asIteration', {
- emptyListOf: actions.empty,
- nonemptyListOf: actions.nonEmpty,
- EmptyListOf: actions.empty,
- NonemptyListOf: actions.nonEmpty
- });
- }
- function initPrototypeParser(grammar) {
- prototypeGrammarSemantics = grammar.createSemantics().addOperation('parse', {
- AttributeSignature: function(name) {
- return {
- name: name.parse(),
- formals: []
- };
- },
- OperationSignature: function(name, optFormals) {
- return {
- name: name.parse(),
- formals: optFormals.parse()[0] || []
- };
- },
- Formals: function(oparen, fs, cparen) {
- return fs.asIteration().parse();
- },
- name: function(first, rest) {
- return this.sourceString;
- }
- });
- prototypeGrammar = grammar;
- };
- module.exports = Semantics;
- },{"../dist/operations-and-attributes":3,"./InputStream":35,"./MatchResult":37,"./common":44,"./errors":45,"./nodes":47,"./util":65,"es6-symbol":22,"inherits":27}],43:[function(require,module,exports){
- 'use strict';
- var Interval = require('./Interval');
- var common = require('./common');
- var BALLOT_X = '\u2717';
- var CHECK_MARK = '\u2713';
- var DOT_OPERATOR = '\u22C5';
- var RIGHTWARDS_DOUBLE_ARROW = '\u21D2';
- var SYMBOL_FOR_HORIZONTAL_TABULATION = '\u2409';
- var SYMBOL_FOR_LINE_FEED = '\u240A';
- var SYMBOL_FOR_CARRIAGE_RETURN = '\u240D';
- var Flags = {
- succeeded: 1 << 0,
- isRootNode: 1 << 1,
- isImplicitSpaces: 1 << 2,
- isMemoized: 1 << 3,
- isHeadOfLeftRecursion: 1 << 4,
- terminatesLR: 1 << 5
- };
- function spaces(n) {
- return common.repeat(' ', n).join('');
- }
- function getInputExcerpt(input, pos, len) {
- var excerpt = asEscapedString(input.slice(pos, pos + len));
-
- if (excerpt.length < len) {
- return excerpt + common.repeat(' ', len - excerpt.length).join('');
- }
- return excerpt;
- }
- function asEscapedString(obj) {
- if (typeof obj === 'string') {
-
- return obj
- .replace(/ /g, DOT_OPERATOR)
- .replace(/\t/g, SYMBOL_FOR_HORIZONTAL_TABULATION)
- .replace(/\n/g, SYMBOL_FOR_LINE_FEED)
- .replace(/\r/g, SYMBOL_FOR_CARRIAGE_RETURN);
- }
- return String(obj);
- }
- function Trace(input, pos1, pos2, expr, succeeded, bindings, optChildren) {
- this.input = input;
- this.pos = this.pos1 = pos1;
- this.pos2 = pos2;
- this.source = new Interval(input, pos1, pos2);
- this.expr = expr;
- this.bindings = bindings;
- this.children = optChildren || [];
- this.terminatingLREntry = null;
- this._flags = succeeded ? Flags.succeeded : 0;
- }
- Trace.prototype.SKIP = {};
- Object.defineProperty(Trace.prototype, 'displayString', {
- get: function() { return this.expr.toDisplayString(); }
- });
- Object.keys(Flags).forEach(function(name) {
- var mask = Flags[name];
- Object.defineProperty(Trace.prototype, name, {
- get: function() {
- return (this._flags & mask) !== 0;
- },
- set: function(val) {
- if (val) {
- this._flags |= mask;
- } else {
- this._flags &= ~mask;
- }
- }
- });
- });
- Trace.prototype.clone = function() {
- return this.cloneWithExpr(this.expr);
- };
- Trace.prototype.cloneWithExpr = function(expr) {
- var ans = new Trace(
- this.input, this.pos, this.pos2, expr, this.succeeded, this.bindings, this.children);
- ans.isHeadOfLeftRecursion = this.isHeadOfLeftRecursion;
- ans.isImplicitSpaces = this.isImplicitSpaces;
- ans.isMemoized = this.isMemoized;
- ans.isRootNode = this.isRootNode;
- ans.terminatesLR = this.terminatesLR;
- ans.terminatingLREntry = this.terminatingLREntry;
- return ans;
- };
- Trace.prototype.recordLRTermination = function(ruleBodyTrace, value) {
- this.terminatingLREntry =
- new Trace(this.input, this.pos, this.pos2, this.expr, false, [value], [ruleBodyTrace]);
- this.terminatingLREntry.terminatesLR = true;
- };
- Trace.prototype.walk = function(visitorObjOrFn, optThisArg) {
- var visitor = visitorObjOrFn;
- if (typeof visitor === 'function') {
- visitor = {enter: visitor};
- }
- function _walk(node, parent, depth) {
- var recurse = true;
- if (visitor.enter) {
- if (visitor.enter.call(optThisArg, node, parent, depth) === Trace.prototype.SKIP) {
- recurse = false;
- }
- }
- if (recurse) {
- node.children.forEach(function(child) {
- _walk(child, node, depth + 1);
- });
- if (visitor.exit) {
- visitor.exit.call(optThisArg, node, parent, depth);
- }
- }
- }
- if (this.isRootNode) {
-
- this.children.forEach(function(c) { _walk(c, null, 0); });
- } else {
- _walk(this, null, 0);
- }
- };
- Trace.prototype.toString = function() {
- var sb = new common.StringBuffer();
- this.walk(function(node, parent, depth) {
- if (!node) {
- return this.SKIP;
- }
- var ctorName = node.expr.constructor.name;
-
- if (ctorName === 'Alt') {
- return;
- }
- sb.append(getInputExcerpt(node.input, node.pos, 10) + spaces(depth * 2 + 1));
- sb.append((node.succeeded ? CHECK_MARK : BALLOT_X) + ' ' + node.displayString);
- if (node.isHeadOfLeftRecursion) {
- sb.append(' (LR)');
- }
- if (node.succeeded) {
- var contents = asEscapedString(node.source.contents);
- sb.append(' ' + RIGHTWARDS_DOUBLE_ARROW + ' ');
- sb.append(typeof contents === 'string' ? '"' + contents + '"' : contents);
- }
- sb.append('\n');
- }.bind(this));
- return sb.contents();
- };
- module.exports = Trace;
- },{"./Interval":36,"./common":44}],44:[function(require,module,exports){
- 'use strict';
- var extend = require('util-extend');
- var escapeStringFor = {};
- for (var c = 0; c < 128; c++) {
- escapeStringFor[c] = String.fromCharCode(c);
- }
- escapeStringFor["'".charCodeAt(0)] = "\\'";
- escapeStringFor['"'.charCodeAt(0)] = '\\"';
- escapeStringFor['\\'.charCodeAt(0)] = '\\\\';
- escapeStringFor['\b'.charCodeAt(0)] = '\\b';
- escapeStringFor['\f'.charCodeAt(0)] = '\\f';
- escapeStringFor['\n'.charCodeAt(0)] = '\\n';
- escapeStringFor['\r'.charCodeAt(0)] = '\\r';
- escapeStringFor['\t'.charCodeAt(0)] = '\\t';
- escapeStringFor['\u000b'.charCodeAt(0)] = '\\v';
- exports.abstract = function(optMethodName) {
- var methodName = optMethodName || '';
- return function() {
- throw new Error(
- 'this method ' + methodName + ' is abstract! ' +
- '(it has no implementation in class ' + this.constructor.name + ')');
- };
- };
- exports.assert = function(cond, message) {
- if (!cond) {
- throw new Error(message);
- }
- };
- exports.defineLazyProperty = function(obj, propName, getterFn) {
- var memo;
- Object.defineProperty(obj, propName, {
- get: function() {
- if (!memo) {
- memo = getterFn.call(this);
- }
- return memo;
- }
- });
- };
- exports.clone = function(obj) {
- if (obj) {
- return extend({}, obj);
- }
- return obj;
- };
- exports.extend = extend;
- exports.repeatFn = function(fn, n) {
- var arr = [];
- while (n-- > 0) {
- arr.push(fn());
- }
- return arr;
- };
- exports.repeatStr = function(str, n) {
- return new Array(n + 1).join(str);
- };
- exports.repeat = function(x, n) {
- return exports.repeatFn(function() { return x; }, n);
- };
- exports.getDuplicates = function(array) {
- var duplicates = [];
- for (var idx = 0; idx < array.length; idx++) {
- var x = array[idx];
- if (array.lastIndexOf(x) !== idx && duplicates.indexOf(x) < 0) {
- duplicates.push(x);
- }
- }
- return duplicates;
- };
- exports.copyWithoutDuplicates = function(array) {
- var noDuplicates = [];
- array.forEach(function(entry) {
- if (noDuplicates.indexOf(entry) < 0) {
- noDuplicates.push(entry);
- }
- });
- return noDuplicates;
- };
- exports.isSyntactic = function(ruleName) {
- var firstChar = ruleName[0];
- return firstChar === firstChar.toUpperCase();
- };
- exports.isLexical = function(ruleName) {
- return !exports.isSyntactic(ruleName);
- };
- exports.padLeft = function(str, len, optChar) {
- var ch = optChar || ' ';
- if (str.length < len) {
- return exports.repeatStr(ch, len - str.length) + str;
- }
- return str;
- };
- exports.StringBuffer = function() {
- this.strings = [];
- };
- exports.StringBuffer.prototype.append = function(str) {
- this.strings.push(str);
- };
- exports.StringBuffer.prototype.contents = function() {
- return this.strings.join('');
- };
- exports.escapeChar = function(c, optDelim) {
- var charCode = c.charCodeAt(0);
- if ((c === '"' || c === "'") && optDelim && c !== optDelim) {
- return c;
- } else if (charCode < 128) {
- return escapeStringFor[charCode];
- } else if (128 <= charCode && charCode < 256) {
- return '\\x' + exports.padLeft(charCode.toString(16), 2, '0');
- } else {
- return '\\u' + exports.padLeft(charCode.toString(16), 4, '0');
- }
- };
- exports.unescapeChar = function(s) {
- if (s.charAt(0) === '\\') {
- switch (s.charAt(1)) {
- case 'b': return '\b';
- case 'f': return '\f';
- case 'n': return '\n';
- case 'r': return '\r';
- case 't': return '\t';
- case 'v': return '\v';
- case 'x': return String.fromCharCode(parseInt(s.substring(2, 4), 16));
- case 'u': return String.fromCharCode(parseInt(s.substring(2, 6), 16));
- default: return s.charAt(1);
- }
- } else {
- return s;
- }
- };
- exports.unexpectedObjToString = function(obj) {
- if (obj == null) {
- return String(obj);
- }
- var baseToString = Object.prototype.toString.call(obj);
- try {
- var typeName;
- if (obj.constructor && obj.constructor.name) {
- typeName = obj.constructor.name;
- } else if (baseToString.indexOf('[object ') === 0) {
- typeName = baseToString.slice(8, -1);
- } else {
- typeName = typeof obj;
- }
- return typeName + ': ' + JSON.stringify(String(obj));
- } catch (e) {
- return baseToString;
- }
- };
- },{"util-extend":29}],45:[function(require,module,exports){
- 'use strict';
- var pexprs = require('./pexprs');
- var Namespace = require('./Namespace');
- function createError(message, optInterval) {
- var e;
- if (optInterval) {
- e = new Error(optInterval.getLineAndColumnMessage() + message);
- e.shortMessage = message;
- e.interval = optInterval;
- } else {
- e = new Error(message);
- }
- return e;
- }
- function intervalSourcesDontMatch() {
- return createError("Interval sources don't match");
- }
- function grammarSyntaxError(matchFailure) {
- var e = new Error();
- Object.defineProperty(e, 'message', {get: function() { return matchFailure.message; }});
- Object.defineProperty(e, 'shortMessage', {get: function() {
- return 'Expected ' + matchFailure.getExpectedText();
- }});
- e.interval = matchFailure.getInterval();
- return e;
- }
- function undeclaredGrammar(grammarName, namespace, interval) {
- var message = namespace ?
- 'Grammar ' + grammarName + ' is not declared in namespace ' + Namespace.toString(namespace) :
- 'Undeclared grammar ' + grammarName;
- return createError(message, interval);
- }
- function duplicateGrammarDeclaration(grammar, namespace) {
- return createError('Grammar ' + grammar.name + ' is already declared in this namespace');
- }
- function undeclaredRule(ruleName, grammarName, optInterval) {
- return createError(
- 'Rule ' + ruleName + ' is not declared in grammar ' + grammarName,
- optInterval);
- }
- function cannotOverrideUndeclaredRule(ruleName, grammarName, optSource) {
- return createError(
- 'Cannot override rule ' + ruleName + ' because it is not declared in ' + grammarName,
- optSource);
- }
- function cannotExtendUndeclaredRule(ruleName, grammarName, optSource) {
- return createError(
- 'Cannot extend rule ' + ruleName + ' because it is not declared in ' + grammarName,
- optSource);
- }
- function duplicateRuleDeclaration(ruleName, grammarName, declGrammarName, optSource) {
- var message = "Duplicate declaration for rule '" + ruleName +
- "' in grammar '" + grammarName + "'";
- if (grammarName !== declGrammarName) {
- message += " (originally declared in '" + declGrammarName + "')";
- }
- return createError(message, optSource);
- }
- function wrongNumberOfParameters(ruleName, expected, actual, source) {
- return createError(
- 'Wrong number of parameters for rule ' + ruleName +
- ' (expected ' + expected + ', got ' + actual + ')',
- source);
- }
- function wrongNumberOfArguments(ruleName, expected, actual, expr) {
- return createError(
- 'Wrong number of arguments for rule ' + ruleName +
- ' (expected ' + expected + ', got ' + actual + ')',
- expr.source);
- }
- function duplicateParameterNames(ruleName, duplicates, source) {
- return createError(
- 'Duplicate parameter names in rule ' + ruleName + ': ' + duplicates.join(', '),
- source);
- }
- function invalidParameter(ruleName, expr) {
- return createError(
- 'Invalid parameter to rule ' + ruleName + ': ' + expr + ' has arity ' + expr.getArity() +
- ', but parameter expressions must have arity 1',
- expr.source);
- }
- function applicationOfSyntacticRuleFromLexicalContext(ruleName, applyExpr) {
- return createError(
- 'Cannot apply syntactic rule ' + ruleName + ' from here (inside a lexical context)',
- applyExpr.source);
- }
- function incorrectArgumentType(expectedType, expr) {
- return createError('Incorrect argument type: expected ' + expectedType, expr.source);
- }
- function kleeneExprHasNullableOperand(kleeneExpr, applicationStack) {
- var actuals = applicationStack.length > 0 ?
- applicationStack[applicationStack.length - 1].args :
- [];
- var expr = kleeneExpr.expr.substituteParams(actuals);
- var message =
- 'Nullable expression ' + expr + " is not allowed inside '" +
- kleeneExpr.operator + "' (possible infinite loop)";
- if (applicationStack.length > 0) {
- var stackTrace = applicationStack
- .map(function(app) { return new pexprs.Apply(app.ruleName, app.args); })
- .join('\n');
- message += '\nApplication stack (most recent application last):\n' + stackTrace;
- }
- return createError(message, kleeneExpr.expr.source);
- }
- function inconsistentArity(ruleName, expected, actual, expr) {
- return createError(
- 'Rule ' + ruleName + ' involves an alternation which has inconsistent arity ' +
- '(expected ' + expected + ', got ' + actual + ')',
- expr.source);
- }
- function duplicatePropertyNames(duplicates) {
- return createError('Object pattern has duplicate property names: ' + duplicates.join(', '));
- }
- function invalidConstructorCall(grammar, ctorName, children) {
- return createError(
- 'Attempt to invoke constructor ' + ctorName + ' with invalid or unexpected arguments');
- }
- function multipleErrors(errors) {
- var messages = errors.map(function(e) { return e.message; });
- return createError(
- ['Errors:'].concat(messages).join('\n- '),
- errors[0].interval);
- }
- function missingSemanticAction(ctorName, name, type, stack) {
- var stackTrace = stack.slice(0, -1).map(function(info) {
- var ans = ' ' + info[0].name + ' > ' + info[1];
- return info.length === 3
- ? ans + " for '" + info[2] + "'"
- : ans;
- }).join('\n');
- stackTrace += '\n ' + name + ' > ' + ctorName;
- var where = type + " '" + name + "'";
- var message = "Missing semantic action for '" + ctorName + "' in " + where + '\n' +
- 'Action stack (most recent call last):\n' + stackTrace;
- var e = createError(message);
- e.name = 'missingSemanticAction';
- return e;
- }
- module.exports = {
- applicationOfSyntacticRuleFromLexicalContext: applicationOfSyntacticRuleFromLexicalContext,
- cannotExtendUndeclaredRule: cannotExtendUndeclaredRule,
- cannotOverrideUndeclaredRule: cannotOverrideUndeclaredRule,
- duplicateGrammarDeclaration: duplicateGrammarDeclaration,
- duplicateParameterNames: duplicateParameterNames,
- duplicatePropertyNames: duplicatePropertyNames,
- duplicateRuleDeclaration: duplicateRuleDeclaration,
- inconsistentArity: inconsistentArity,
- incorrectArgumentType: incorrectArgumentType,
- intervalSourcesDontMatch: intervalSourcesDontMatch,
- invalidConstructorCall: invalidConstructorCall,
- invalidParameter: invalidParameter,
- grammarSyntaxError: grammarSyntaxError,
- kleeneExprHasNullableOperand: kleeneExprHasNullableOperand,
- missingSemanticAction: missingSemanticAction,
- undeclaredGrammar: undeclaredGrammar,
- undeclaredRule: undeclaredRule,
- wrongNumberOfArguments: wrongNumberOfArguments,
- wrongNumberOfParameters: wrongNumberOfParameters,
- throwErrors: function(errors) {
- if (errors.length === 1) {
- throw errors[0];
- }
- if (errors.length > 1) {
- throw multipleErrors(errors);
- }
- }
- };
- },{"./Namespace":40,"./pexprs":64}],46:[function(require,module,exports){
- 'use strict';
- var Builder = require('./Builder');
- var Grammar = require('./Grammar');
- var Namespace = require('./Namespace');
- var common = require('./common');
- var errors = require('./errors');
- var pexprs = require('./pexprs');
- var util = require('./util');
- var version = require('./version');
- var isBuffer = require('is-buffer');
- var ohmGrammar;
- var documentInterface = {
- querySelector: function(sel) { return document.querySelector(sel); },
- querySelectorAll: function(sel) { return document.querySelectorAll(sel); }
- };
- function isElement(obj) {
- return !!(obj && obj.nodeType === 1);
- }
- function isUndefined(obj) {
- return obj === void 0;
- }
- var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
- function isArrayLike(obj) {
- if (obj == null) {
- return false;
- }
- var length = obj.length;
- return typeof length === 'number' && length >= 0 && length <= MAX_ARRAY_INDEX;
- }
- function load(url) {
- var req = new XMLHttpRequest();
- req.open('GET', url, false);
- try {
- req.send();
- if (req.status === 0 || req.status === 200) {
- return req.responseText;
- }
- } catch (e) {}
- throw new Error('unable to load url ' + url);
- }
- function buildGrammar(match, namespace, optOhmGrammarForTesting) {
- var builder = new Builder();
- var decl;
- var currentRuleName;
- var currentRuleFormals;
- var overriding = false;
- var metaGrammar = optOhmGrammarForTesting || ohmGrammar;
-
- var helpers = metaGrammar.createSemantics().addOperation('visit', {
- Grammar: function(n, s, open, rs, close) {
- var grammarName = n.visit();
- decl = builder.newGrammar(grammarName, namespace);
- s.visit();
- rs.visit();
- var g = decl.build();
- g.source = this.source.trimmed();
- if (grammarName in namespace) {
- throw errors.duplicateGrammarDeclaration(g, namespace);
- }
- namespace[grammarName] = g;
- return g;
- },
- SuperGrammar: function(_, n) {
- var superGrammarName = n.visit();
- if (superGrammarName === 'null') {
- decl.withSuperGrammar(null);
- } else {
- if (!namespace || !(superGrammarName in namespace)) {
- throw errors.undeclaredGrammar(superGrammarName, namespace, n.source);
- }
- decl.withSuperGrammar(namespace[superGrammarName]);
- }
- },
- Rule_define: function(n, fs, d, _, b) {
- currentRuleName = n.visit();
- currentRuleFormals = fs.visit()[0] || [];
-
-
- if (!decl.defaultStartRule && decl.ensureSuperGrammar() !== Grammar.ProtoBuiltInRules) {
- decl.withDefaultStartRule(currentRuleName);
- }
- var body = b.visit();
- var description = d.visit()[0];
- var source = this.source.trimmed();
- return decl.define(currentRuleName, currentRuleFormals, body, description, source);
- },
- Rule_override: function(n, fs, _, b) {
- currentRuleName = n.visit();
- currentRuleFormals = fs.visit()[0] || [];
- overriding = true;
- var body = b.visit();
- var source = this.source.trimmed();
- var ans = decl.override(currentRuleName, currentRuleFormals, body, null, source);
- overriding = false;
- return ans;
- },
- Rule_extend: function(n, fs, _, b) {
- currentRuleName = n.visit();
- currentRuleFormals = fs.visit()[0] || [];
- var body = b.visit();
- var source = this.source.trimmed();
- var ans = decl.extend(currentRuleName, currentRuleFormals, body, null, source);
- return ans;
- },
- RuleBody: function(_, terms) {
- var args = terms.visit();
- return builder.alt.apply(builder, args).withSource(this.source);
- },
- Formals: function(opointy, fs, cpointy) {
- return fs.visit();
- },
- Params: function(opointy, ps, cpointy) {
- return ps.visit();
- },
- Alt: function(seqs) {
- var args = seqs.visit();
- return builder.alt.apply(builder, args).withSource(this.source);
- },
- TopLevelTerm_inline: function(b, n) {
- var inlineRuleName = currentRuleName + '_' + n.visit();
- var body = b.visit();
- var source = this.source.trimmed();
- var isNewRuleDeclaration =
- !(decl.superGrammar && decl.superGrammar.rules[inlineRuleName]);
- if (overriding && !isNewRuleDeclaration) {
- decl.override(inlineRuleName, currentRuleFormals, body, null, source);
- } else {
- decl.define(inlineRuleName, currentRuleFormals, body, null, source);
- }
- var params = currentRuleFormals.map(function(formal) { return builder.app(formal); });
- return builder.app(inlineRuleName, params).withSource(body.source);
- },
- Seq: function(expr) {
- return builder.seq.apply(builder, expr.visit()).withSource(this.source);
- },
- Iter_star: function(x, _) {
- return builder.star(x.visit()).withSource(this.source);
- },
- Iter_plus: function(x, _) {
- return builder.plus(x.visit()).withSource(this.source);
- },
- Iter_opt: function(x, _) {
- return builder.opt(x.visit()).withSource(this.source);
- },
- Pred_not: function(_, x) {
- return builder.not(x.visit()).withSource(this.source);
- },
- Pred_lookahead: function(_, x) {
- return builder.lookahead(x.visit()).withSource(this.source);
- },
- Lex_lex: function(_, x) {
- return builder.lex(x.visit()).withSource(this.source);
- },
- Base_application: function(rule, ps) {
- return builder.app(rule.visit(), ps.visit()[0] || []).withSource(this.source);
- },
- Base_range: function(from, _, to) {
- return builder.range(from.visit(), to.visit()).withSource(this.source);
- },
- Base_terminal: function(expr) {
- return builder.terminal(expr.visit()).withSource(this.source);
- },
- Base_paren: function(open, x, close) {
- return x.visit();
- },
- ruleDescr: function(open, t, close) {
- return t.visit();
- },
- ruleDescrText: function(_) {
- return this.sourceString.trim();
- },
- caseName: function(_, space1, n, space2, end) {
- return n.visit();
- },
- name: function(first, rest) {
- return this.sourceString;
- },
- nameFirst: function(expr) {},
- nameRest: function(expr) {},
- terminal: function(open, cs, close) {
- return cs.visit().join('');
- },
- oneCharTerminal: function(open, c, close) {
- return c.visit();
- },
- terminalChar: function(_) {
- return common.unescapeChar(this.sourceString);
- },
- escapeChar: function(_) {
- return this.sourceString;
- },
- NonemptyListOf: function(x, _, xs) {
- return [x.visit()].concat(xs.visit());
- },
- EmptyListOf: function() {
- return [];
- },
- _terminal: function() {
- return this.primitiveValue;
- }
- });
- return helpers(match).visit();
- }
- function compileAndLoad(source, namespace) {
- var m = ohmGrammar.match(source, 'Grammars');
- if (m.failed()) {
- throw errors.grammarSyntaxError(m);
- }
- return buildGrammar(m, namespace);
- }
- function getScriptElementContents(el) {
- if (!isElement(el)) {
- throw new TypeError('Expected a DOM Node, got ' + common.unexpectedObjToString(el));
- }
- if (el.type !== 'text/ohm-js') {
- throw new Error('Expected a script tag with type="text/ohm-js", got ' + el);
- }
- return el.getAttribute('src') ? load(el.getAttribute('src')) : el.innerHTML;
- }
- function grammar(source, optNamespace) {
- var ns = grammars(source, optNamespace);
-
- var grammarNames = Object.keys(ns);
- if (grammarNames.length === 0) {
- throw new Error('Missing grammar definition');
- } else if (grammarNames.length > 1) {
- var secondGrammar = ns[grammarNames[1]];
- var interval = secondGrammar.source;
- throw new Error(
- util.getLineAndColumnMessage(interval.sourceString, interval.startIdx) +
- 'Found more than one grammar definition -- use ohm.grammars() instead.');
- }
- return ns[grammarNames[0]];
- }
- function grammars(source, optNamespace) {
- var ns = Namespace.extend(Namespace.asNamespace(optNamespace));
- if (typeof source !== 'string') {
-
- if (isBuffer(source)) {
- source = source.toString();
- } else {
- throw new TypeError(
- 'Expected string as first argument, got ' + common.unexpectedObjToString(source));
- }
- }
- compileAndLoad(source, ns);
- return ns;
- }
- function grammarFromScriptElement(optNode) {
- var node = optNode;
- if (isUndefined(node)) {
- var nodeList = documentInterface.querySelectorAll('script[type="text/ohm-js"]');
- if (nodeList.length !== 1) {
- throw new Error(
- 'Expected exactly one script tag with type="text/ohm-js", found ' + nodeList.length);
- }
- node = nodeList[0];
- }
- return grammar(getScriptElementContents(node));
- }
- function grammarsFromScriptElements(optNodeOrNodeList) {
-
- if (isElement(optNodeOrNodeList)) {
- return grammars(optNodeOrNodeList);
- }
-
- var nodeList = optNodeOrNodeList;
- if (isUndefined(nodeList)) {
-
- nodeList = documentInterface.querySelectorAll('script[type="text/ohm-js"]');
- } else if (typeof nodeList === 'string' || (!isElement(nodeList) && !isArrayLike(nodeList))) {
- throw new TypeError('Expected a Node, NodeList, or Array, but got ' + nodeList);
- }
- var ns = Namespace.createNamespace();
- for (var i = 0; i < nodeList.length; ++i) {
-
- common.extend(ns, grammars(getScriptElementContents(nodeList[i]), ns));
- }
- return ns;
- }
- function makeRecipe(recipe) {
- if (typeof recipe === 'function') {
- return recipe.call(new Builder());
- } else {
- if (typeof recipe === 'string') {
-
- recipe = JSON.parse(recipe);
- }
- return (new Builder()).fromRecipe(recipe);
- }
- }
- module.exports = {
- createNamespace: Namespace.createNamespace,
- grammar: grammar,
- grammars: grammars,
- grammarFromScriptElement: grammarFromScriptElement,
- grammarsFromScriptElements: grammarsFromScriptElements,
- makeRecipe: makeRecipe,
- ohmGrammar: null,
- pexprs: pexprs,
- util: util,
- extras: require('../extras'),
- version: version
- };
- module.exports._buildGrammar = buildGrammar;
- module.exports._setDocumentInterfaceForTesting = function(doc) { documentInterface = doc; };
- Grammar.BuiltInRules = require('../dist/built-in-rules');
- util.announceBuiltInRules(Grammar.BuiltInRules);
- module.exports.ohmGrammar = ohmGrammar = require('../dist/ohm-grammar');
- Grammar.initApplicationParser(ohmGrammar, buildGrammar);
- },{"../dist/built-in-rules":1,"../dist/ohm-grammar":2,"../extras":5,"./Builder":30,"./Grammar":33,"./Namespace":40,"./common":44,"./errors":45,"./pexprs":64,"./util":65,"./version":66,"is-buffer":28}],47:[function(require,module,exports){
- 'use strict';
- var inherits = require('inherits');
- var common = require('./common');
- function Node(grammar, ctorName, matchLength) {
- this.grammar = grammar;
- this.ctorName = ctorName;
- this.matchLength = matchLength;
- }
- Node.prototype.numChildren = function() {
- return this.children ? this.children.length : 0;
- };
- Node.prototype.childAt = function(idx) {
- if (this.children) {
- return this.children[idx];
- }
- };
- Node.prototype.indexOfChild = function(arg) {
- return this.children.indexOf(arg);
- };
- Node.prototype.hasChildren = function() {
- return this.numChildren() > 1;
- };
- Node.prototype.hasNoChildren = function() {
- return !this.hasChildren();
- };
- Node.prototype.onlyChild = function() {
- if (this.numChildren() !== 1) {
- throw new Error(
- 'cannot get only child of a node of type ' + this.ctorName +
- ' (it has ' + this.numChildren() + ' children)');
- } else {
- return this.firstChild();
- }
- };
- Node.prototype.firstChild = function() {
- if (this.hasNoChildren()) {
- throw new Error(
- 'cannot get first child of a ' + this.ctorName + ' node, which has no children');
- } else {
- return this.childAt(0);
- }
- };
- Node.prototype.lastChild = function() {
- if (this.hasNoChildren()) {
- throw new Error(
- 'cannot get last child of a ' + this.ctorName + ' node, which has no children');
- } else {
- return this.childAt(this.numChildren() - 1);
- }
- };
- Node.prototype.childBefore = function(child) {
- var childIdx = this.indexOfChild(child);
- if (childIdx < 0) {
- throw new Error('Node.childBefore() called w/ an argument that is not a child');
- } else if (childIdx === 0) {
- throw new Error('cannot get child before first child');
- } else {
- return this.childAt(childIdx - 1);
- }
- };
- Node.prototype.childAfter = function(child) {
- var childIdx = this.indexOfChild(child);
- if (childIdx < 0) {
- throw new Error('Node.childAfter() called w/ an argument that is not a child');
- } else if (childIdx === this.numChildren() - 1) {
- throw new Error('cannot get child after last child');
- } else {
- return this.childAt(childIdx + 1);
- }
- };
- Node.prototype.isTerminal = function() {
- return false;
- };
- Node.prototype.isNonterminal = function() {
- return false;
- };
- Node.prototype.isIteration = function() {
- return false;
- };
- Node.prototype.isOptional = function() {
- return false;
- };
- Node.prototype.toJSON = function() {
- var r = {};
- r[this.ctorName] = this.children;
- return r;
- };
- function TerminalNode(grammar, value) {
- var matchLength = value ? value.length : 0;
- Node.call(this, grammar, '_terminal', matchLength);
- this.primitiveValue = value;
- }
- inherits(TerminalNode, Node);
- TerminalNode.prototype.isTerminal = function() {
- return true;
- };
- TerminalNode.prototype.toJSON = function() {
- var r = {};
- r[this.ctorName] = this.primitiveValue;
- return r;
- };
- function NonterminalNode(grammar, ruleName, children, childOffsets, matchLength) {
- Node.call(this, grammar, ruleName, matchLength);
- this.children = children;
- this.childOffsets = childOffsets;
- }
- inherits(NonterminalNode, Node);
- NonterminalNode.prototype.isNonterminal = function() {
- return true;
- };
- NonterminalNode.prototype.isLexical = function() {
- return common.isLexical(this.ctorName);
- };
- NonterminalNode.prototype.isSyntactic = function() {
- return common.isSyntactic(this.ctorName);
- };
- function IterationNode(grammar, children, childOffsets, matchLength, isOptional) {
- Node.call(this, grammar, '_iter', matchLength);
- this.children = children;
- this.childOffsets = childOffsets;
- this.optional = isOptional;
- }
- inherits(IterationNode, Node);
- IterationNode.prototype.isIteration = function() {
- return true;
- };
- IterationNode.prototype.isOptional = function() {
- return this.optional;
- };
- module.exports = {
- Node: Node,
- TerminalNode: TerminalNode,
- NonterminalNode: NonterminalNode,
- IterationNode: IterationNode
- };
- },{"./common":44,"inherits":27}],48:[function(require,module,exports){
- 'use strict';
- var common = require('./common');
- var pexprs = require('./pexprs');
- pexprs.PExpr.prototype.allowsSkippingPrecedingSpace = common.abstract(
- 'allowsSkippingPrecedingSpace'
- );
- pexprs.any.allowsSkippingPrecedingSpace =
- pexprs.end.allowsSkippingPrecedingSpace =
- pexprs.Apply.prototype.allowsSkippingPrecedingSpace =
- pexprs.Terminal.prototype.allowsSkippingPrecedingSpace =
- pexprs.Range.prototype.allowsSkippingPrecedingSpace =
- pexprs.UnicodeChar.prototype.allowsSkippingPrecedingSpace = function() {
- return true;
- };
- pexprs.Alt.prototype.allowsSkippingPrecedingSpace =
- pexprs.Iter.prototype.allowsSkippingPrecedingSpace =
- pexprs.Lex.prototype.allowsSkippingPrecedingSpace =
- pexprs.Lookahead.prototype.allowsSkippingPrecedingSpace =
- pexprs.Not.prototype.allowsSkippingPrecedingSpace =
- pexprs.Param.prototype.allowsSkippingPrecedingSpace =
- pexprs.Seq.prototype.allowsSkippingPrecedingSpace = function() {
- return false;
- };
- },{"./common":44,"./pexprs":64}],49:[function(require,module,exports){
- 'use strict';
- var common = require('./common');
- var errors = require('./errors');
- var pexprs = require('./pexprs');
- var util = require('./util');
- var BuiltInRules;
- util.awaitBuiltInRules(function(g) { BuiltInRules = g; });
- var lexifyCount;
- pexprs.PExpr.prototype.assertAllApplicationsAreValid = function(ruleName, grammar) {
- lexifyCount = 0;
- this._assertAllApplicationsAreValid(ruleName, grammar);
- };
- pexprs.PExpr.prototype._assertAllApplicationsAreValid = common.abstract(
- '_assertAllApplicationsAreValid'
- );
- pexprs.any._assertAllApplicationsAreValid =
- pexprs.end._assertAllApplicationsAreValid =
- pexprs.Terminal.prototype._assertAllApplicationsAreValid =
- pexprs.Range.prototype._assertAllApplicationsAreValid =
- pexprs.Param.prototype._assertAllApplicationsAreValid =
- pexprs.UnicodeChar.prototype._assertAllApplicationsAreValid = function(ruleName, grammar) {
-
- };
- pexprs.Lex.prototype._assertAllApplicationsAreValid = function(ruleName, grammar) {
- lexifyCount++;
- this.expr._assertAllApplicationsAreValid(ruleName, grammar);
- lexifyCount--;
- };
- pexprs.Alt.prototype._assertAllApplicationsAreValid = function(ruleName, grammar) {
- for (var idx = 0; idx < this.terms.length; idx++) {
- this.terms[idx]._assertAllApplicationsAreValid(ruleName, grammar);
- }
- };
- pexprs.Seq.prototype._assertAllApplicationsAreValid = function(ruleName, grammar) {
- for (var idx = 0; idx < this.factors.length; idx++) {
- this.factors[idx]._assertAllApplicationsAreValid(ruleName, grammar);
- }
- };
- pexprs.Iter.prototype._assertAllApplicationsAreValid =
- pexprs.Not.prototype._assertAllApplicationsAreValid =
- pexprs.Lookahead.prototype._assertAllApplicationsAreValid = function(ruleName, grammar) {
- this.expr._assertAllApplicationsAreValid(ruleName, grammar);
- };
- pexprs.Apply.prototype._assertAllApplicationsAreValid = function(ruleName, grammar) {
- var ruleInfo = grammar.rules[this.ruleName];
-
- if (!ruleInfo) {
- throw errors.undeclaredRule(this.ruleName, grammar.name, this.source);
- }
-
- if (common.isSyntactic(this.ruleName) && (!common.isSyntactic(ruleName) || lexifyCount > 0)) {
- throw errors.applicationOfSyntacticRuleFromLexicalContext(this.ruleName, this);
- }
-
- var actual = this.args.length;
- var expected = ruleInfo.formals.length;
- if (actual !== expected) {
- throw errors.wrongNumberOfArguments(this.ruleName, expected, actual, this.source);
- }
-
- var self = this;
- this.args.forEach(function(arg) {
- arg._assertAllApplicationsAreValid(ruleName, grammar);
- if (arg.getArity() !== 1) {
- throw errors.invalidParameter(self.ruleName, arg);
- }
- });
-
-
- if (BuiltInRules && ruleInfo === BuiltInRules.rules.caseInsensitive) {
- if (!(this.args[0] instanceof pexprs.Terminal)) {
- throw errors.incorrectArgumentType('a Terminal (e.g. \"abc\")', this.args[0]);
- }
- }
- };
- },{"./common":44,"./errors":45,"./pexprs":64,"./util":65}],50:[function(require,module,exports){
- 'use strict';
- var common = require('./common');
- var errors = require('./errors');
- var pexprs = require('./pexprs');
- pexprs.PExpr.prototype.assertChoicesHaveUniformArity = common.abstract(
- 'assertChoicesHaveUniformArity'
- );
- pexprs.any.assertChoicesHaveUniformArity =
- pexprs.end.assertChoicesHaveUniformArity =
- pexprs.Terminal.prototype.assertChoicesHaveUniformArity =
- pexprs.Range.prototype.assertChoicesHaveUniformArity =
- pexprs.Param.prototype.assertChoicesHaveUniformArity =
- pexprs.Lex.prototype.assertChoicesHaveUniformArity =
- pexprs.UnicodeChar.prototype.assertChoicesHaveUniformArity = function(ruleName) {
-
- };
- pexprs.Alt.prototype.assertChoicesHaveUniformArity = function(ruleName) {
- if (this.terms.length === 0) {
- return;
- }
- var arity = this.terms[0].getArity();
- for (var idx = 0; idx < this.terms.length; idx++) {
- var term = this.terms[idx];
- term.assertChoicesHaveUniformArity();
- var otherArity = term.getArity();
- if (arity !== otherArity) {
- throw errors.inconsistentArity(ruleName, arity, otherArity, term);
- }
- }
- };
- pexprs.Extend.prototype.assertChoicesHaveUniformArity = function(ruleName) {
-
-
- var actualArity = this.terms[0].getArity();
- var expectedArity = this.terms[1].getArity();
- if (actualArity !== expectedArity) {
- throw errors.inconsistentArity(ruleName, expectedArity, actualArity, this.terms[0]);
- }
- };
- pexprs.Seq.prototype.assertChoicesHaveUniformArity = function(ruleName) {
- for (var idx = 0; idx < this.factors.length; idx++) {
- this.factors[idx].assertChoicesHaveUniformArity(ruleName);
- }
- };
- pexprs.Iter.prototype.assertChoicesHaveUniformArity = function(ruleName) {
- this.expr.assertChoicesHaveUniformArity(ruleName);
- };
- pexprs.Not.prototype.assertChoicesHaveUniformArity = function(ruleName) {
-
- };
- pexprs.Lookahead.prototype.assertChoicesHaveUniformArity = function(ruleName) {
- this.expr.assertChoicesHaveUniformArity(ruleName);
- };
- pexprs.Apply.prototype.assertChoicesHaveUniformArity = function(ruleName) {
-
-
- };
- },{"./common":44,"./errors":45,"./pexprs":64}],51:[function(require,module,exports){
- 'use strict';
- var common = require('./common');
- var errors = require('./errors');
- var pexprs = require('./pexprs');
- pexprs.PExpr.prototype.assertIteratedExprsAreNotNullable = common.abstract(
- 'assertIteratedExprsAreNotNullable'
- );
- pexprs.any.assertIteratedExprsAreNotNullable =
- pexprs.end.assertIteratedExprsAreNotNullable =
- pexprs.Terminal.prototype.assertIteratedExprsAreNotNullable =
- pexprs.Range.prototype.assertIteratedExprsAreNotNullable =
- pexprs.Param.prototype.assertIteratedExprsAreNotNullable =
- pexprs.UnicodeChar.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
-
- };
- pexprs.Alt.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
- for (var idx = 0; idx < this.terms.length; idx++) {
- this.terms[idx].assertIteratedExprsAreNotNullable(grammar);
- }
- };
- pexprs.Seq.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
- for (var idx = 0; idx < this.factors.length; idx++) {
- this.factors[idx].assertIteratedExprsAreNotNullable(grammar);
- }
- };
- pexprs.Iter.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
-
-
- this.expr.assertIteratedExprsAreNotNullable(grammar);
- if (this.expr.isNullable(grammar)) {
- throw errors.kleeneExprHasNullableOperand(this, []);
- }
- };
- pexprs.Opt.prototype.assertIteratedExprsAreNotNullable =
- pexprs.Not.prototype.assertIteratedExprsAreNotNullable =
- pexprs.Lookahead.prototype.assertIteratedExprsAreNotNullable =
- pexprs.Lex.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
- this.expr.assertIteratedExprsAreNotNullable(grammar);
- };
- pexprs.Apply.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
- this.args.forEach(function(arg) {
- arg.assertIteratedExprsAreNotNullable(grammar);
- });
- };
- },{"./common":44,"./errors":45,"./pexprs":64}],52:[function(require,module,exports){
- 'use strict';
- var common = require('./common');
- var nodes = require('./nodes');
- var pexprs = require('./pexprs');
- pexprs.PExpr.prototype.check = common.abstract('check');
- pexprs.any.check = function(grammar, vals) {
- return vals.length >= 1;
- };
- pexprs.end.check = function(grammar, vals) {
- return vals[0] instanceof nodes.Node &&
- vals[0].isTerminal() &&
- vals[0].primitiveValue === undefined;
- };
- pexprs.Terminal.prototype.check = function(grammar, vals) {
- return vals[0] instanceof nodes.Node &&
- vals[0].isTerminal() &&
- vals[0].primitiveValue === this.obj;
- };
- pexprs.Range.prototype.check = function(grammar, vals) {
- return vals[0] instanceof nodes.Node &&
- vals[0].isTerminal() &&
- typeof vals[0].primitiveValue === typeof this.from;
- };
- pexprs.Param.prototype.check = function(grammar, vals) {
- return vals.length >= 1;
- };
- pexprs.Alt.prototype.check = function(grammar, vals) {
- for (var i = 0; i < this.terms.length; i++) {
- var term = this.terms[i];
- if (term.check(grammar, vals)) {
- return true;
- }
- }
- return false;
- };
- pexprs.Seq.prototype.check = function(grammar, vals) {
- var pos = 0;
- for (var i = 0; i < this.factors.length; i++) {
- var factor = this.factors[i];
- if (factor.check(grammar, vals.slice(pos))) {
- pos += factor.getArity();
- } else {
- return false;
- }
- }
- return true;
- };
- pexprs.Iter.prototype.check = function(grammar, vals) {
- var arity = this.getArity();
- var columns = vals.slice(0, arity);
- if (columns.length !== arity) {
- return false;
- }
- var rowCount = columns[0].length;
- var i;
- for (i = 1; i < arity; i++) {
- if (columns[i].length !== rowCount) {
- return false;
- }
- }
- for (i = 0; i < rowCount; i++) {
- var row = [];
- for (var j = 0; j < arity; j++) {
- row.push(columns[j][i]);
- }
- if (!this.expr.check(grammar, row)) {
- return false;
- }
- }
- return true;
- };
- pexprs.Not.prototype.check = function(grammar, vals) {
- return true;
- };
- pexprs.Lookahead.prototype.check =
- pexprs.Lex.prototype.check = function(grammar, vals) {
- return this.expr.check(grammar, vals);
- };
- pexprs.Apply.prototype.check = function(grammar, vals) {
- if (!(vals[0] instanceof nodes.Node &&
- vals[0].grammar === grammar &&
- vals[0].ctorName === this.ruleName)) {
- return false;
- }
-
-
- var ruleNode = vals[0];
- var body = grammar.rules[this.ruleName].body;
- return body.check(grammar, ruleNode.children) && ruleNode.numChildren() === body.getArity();
- };
- pexprs.UnicodeChar.prototype.check = function(grammar, vals) {
- return vals[0] instanceof nodes.Node &&
- vals[0].isTerminal() &&
- typeof vals[0].primitiveValue === 'string';
- };
- },{"./common":44,"./nodes":47,"./pexprs":64}],53:[function(require,module,exports){
- 'use strict';
- var Trace = require('./Trace');
- var common = require('./common');
- var errors = require('./errors');
- var nodes = require('./nodes');
- var pexprs = require('./pexprs');
- var TerminalNode = nodes.TerminalNode;
- var NonterminalNode = nodes.NonterminalNode;
- var IterationNode = nodes.IterationNode;
- pexprs.PExpr.prototype.eval = common.abstract('eval');
- pexprs.any.eval = function(state) {
- var inputStream = state.inputStream;
- var origPos = inputStream.pos;
- var ch = inputStream.next();
- if (ch) {
- state.pushBinding(new TerminalNode(state.grammar, ch), origPos);
- return true;
- } else {
- state.processFailure(origPos, this);
- return false;
- }
- };
- pexprs.end.eval = function(state) {
- var inputStream = state.inputStream;
- var origPos = inputStream.pos;
- if (inputStream.atEnd()) {
- state.pushBinding(new TerminalNode(state.grammar, undefined), origPos);
- return true;
- } else {
- state.processFailure(origPos, this);
- return false;
- }
- };
- pexprs.Terminal.prototype.eval = function(state) {
- var inputStream = state.inputStream;
- var origPos = inputStream.pos;
- if (!inputStream.matchString(this.obj)) {
- state.processFailure(origPos, this);
- return false;
- } else {
- state.pushBinding(new TerminalNode(state.grammar, this.obj), origPos);
- return true;
- }
- };
- pexprs.Range.prototype.eval = function(state) {
- var inputStream = state.inputStream;
- var origPos = inputStream.pos;
- var ch = inputStream.next();
- if (ch && this.from <= ch && ch <= this.to) {
- state.pushBinding(new TerminalNode(state.grammar, ch), origPos);
- return true;
- } else {
- state.processFailure(origPos, this);
- return false;
- }
- };
- pexprs.Param.prototype.eval = function(state) {
- return state.eval(state.currentApplication().args[this.index]);
- };
- pexprs.Lex.prototype.eval = function(state) {
- state.enterLexifiedContext();
- var ans = state.eval(this.expr);
- state.exitLexifiedContext();
- return ans;
- };
- pexprs.Alt.prototype.eval = function(state) {
- for (var idx = 0; idx < this.terms.length; idx++) {
- if (state.eval(this.terms[idx])) {
- return true;
- }
- }
- return false;
- };
- pexprs.Seq.prototype.eval = function(state) {
- for (var idx = 0; idx < this.factors.length; idx++) {
- var factor = this.factors[idx];
- if (!state.eval(factor)) {
- return false;
- }
- }
- return true;
- };
- pexprs.Iter.prototype.eval = function(state) {
- var inputStream = state.inputStream;
- var origPos = inputStream.pos;
- var arity = this.getArity();
- var cols = [];
- var colOffsets = [];
- while (cols.length < arity) {
- cols.push([]);
- colOffsets.push([]);
- }
- var numMatches = 0;
- var prevPos = origPos;
- var idx;
- while (numMatches < this.maxNumMatches && state.eval(this.expr)) {
- if (inputStream.pos === prevPos) {
- throw errors.kleeneExprHasNullableOperand(this, state._applicationStack);
- }
- prevPos = inputStream.pos;
- numMatches++;
- var row = state._bindings.splice(state._bindings.length - arity, arity);
- var rowOffsets = state._bindingOffsets.splice(state._bindingOffsets.length - arity, arity);
- for (idx = 0; idx < row.length; idx++) {
- cols[idx].push(row[idx]);
- colOffsets[idx].push(rowOffsets[idx]);
- }
- }
- if (numMatches < this.minNumMatches) {
- return false;
- }
- var offset = state.posToOffset(origPos);
- var matchLength = 0;
- if (numMatches > 0) {
- var lastCol = cols[arity - 1];
- var lastColOffsets = colOffsets[arity - 1];
- var endOffset =
- lastColOffsets[lastColOffsets.length - 1] + lastCol[lastCol.length - 1].matchLength;
- offset = colOffsets[0][0];
- matchLength = endOffset - offset;
- }
- var isOptional = this instanceof pexprs.Opt;
- for (idx = 0; idx < cols.length; idx++) {
- state._bindings.push(
- new IterationNode(state.grammar, cols[idx], colOffsets[idx], matchLength, isOptional));
- state._bindingOffsets.push(offset);
- }
- return true;
- };
- pexprs.Not.prototype.eval = function(state) {
-
- var inputStream = state.inputStream;
- var origPos = inputStream.pos;
- state.pushFailuresInfo();
- var ans = state.eval(this.expr);
- state.popFailuresInfo();
- if (ans) {
- state.processFailure(origPos, this);
- return false;
- }
- inputStream.pos = origPos;
- return true;
- };
- pexprs.Lookahead.prototype.eval = function(state) {
- var inputStream = state.inputStream;
- var origPos = inputStream.pos;
- if (state.eval(this.expr)) {
- inputStream.pos = origPos;
- return true;
- } else {
- return false;
- }
- };
- pexprs.Apply.prototype.eval = function(state) {
- var caller = state.currentApplication();
- var actuals = caller ? caller.args : [];
- var app = this.substituteParams(actuals);
- var posInfo = state.getCurrentPosInfo();
- if (posInfo.isActive(app)) {
-
- return app.handleCycle(state);
- }
- var memoKey = app.toMemoKey();
- var memoRec = posInfo.memo[memoKey];
- if (memoRec && posInfo.shouldUseMemoizedResult(memoRec)) {
- if (state.hasNecessaryInfo(memoRec)) {
- return state.useMemoizedResult(state.inputStream.pos, memoRec);
- }
- delete posInfo.memo[memoKey];
- }
- return app.reallyEval(state);
- };
- pexprs.Apply.prototype.handleCycle = function(state) {
- var posInfo = state.getCurrentPosInfo();
- var currentLeftRecursion = posInfo.currentLeftRecursion;
- var memoKey = this.toMemoKey();
- var memoRec = posInfo.memo[memoKey];
- if (currentLeftRecursion && currentLeftRecursion.headApplication.toMemoKey() === memoKey) {
-
-
- memoRec.updateInvolvedApplicationMemoKeys();
- } else if (!memoRec) {
-
- memoRec = posInfo.memoize(
- memoKey,
- {matchLength: 0, examinedLength: 0, value: false, rightmostFailureOffset: -1});
- posInfo.startLeftRecursion(this, memoRec);
- }
- return state.useMemoizedResult(state.inputStream.pos, memoRec);
- };
- pexprs.Apply.prototype.reallyEval = function(state) {
- var inputStream = state.inputStream;
- var origPos = inputStream.pos;
- var origPosInfo = state.getCurrentPosInfo();
- var ruleInfo = state.grammar.rules[this.ruleName];
- var body = ruleInfo.body;
- var description = ruleInfo.description;
- state.enterApplication(origPosInfo, this);
- if (description) {
- state.pushFailuresInfo();
- }
-
-
- var origInputStreamExaminedLength = inputStream.examinedLength;
- inputStream.examinedLength = 0;
- var value = this.evalOnce(body, state);
- var currentLR = origPosInfo.currentLeftRecursion;
- var memoKey = this.toMemoKey();
- var isHeadOfLeftRecursion = currentLR && currentLR.headApplication.toMemoKey() === memoKey;
- var memoRec;
- if (isHeadOfLeftRecursion) {
- value = this.growSeedResult(body, state, origPos, currentLR, value);
- origPosInfo.endLeftRecursion();
- memoRec = currentLR;
- memoRec.examinedLength = inputStream.examinedLength - origPos;
- memoRec.rightmostFailureOffset = state._getRightmostFailureOffset();
- origPosInfo.memoize(memoKey, memoRec);
- } else if (!currentLR || !currentLR.isInvolved(memoKey)) {
-
- memoRec = origPosInfo.memoize(memoKey, {
- matchLength: inputStream.pos - origPos,
- examinedLength: inputStream.examinedLength - origPos,
- value: value,
- failuresAtRightmostPosition: state.cloneRecordedFailures(),
- rightmostFailureOffset: state._getRightmostFailureOffset()
- });
- }
- var succeeded = !!value;
- if (description) {
- state.popFailuresInfo();
- if (!succeeded) {
- state.processFailure(origPos, this);
- }
- if (memoRec) {
- memoRec.failuresAtRightmostPosition = state.cloneRecordedFailures();
- }
- }
-
-
- if (state.isTracing() && memoRec) {
- var entry = state.getTraceEntry(origPos, this, succeeded, succeeded ? [value] : []);
- if (isHeadOfLeftRecursion) {
- common.assert(entry.terminatingLREntry != null || !succeeded);
- entry.isHeadOfLeftRecursion = true;
- }
- memoRec.traceEntry = entry;
- }
-
-
- inputStream.examinedLength = Math.max(inputStream.examinedLength, origInputStreamExaminedLength);
- state.exitApplication(origPosInfo, value);
- return succeeded;
- };
- pexprs.Apply.prototype.evalOnce = function(expr, state) {
- var inputStream = state.inputStream;
- var origPos = inputStream.pos;
- if (state.eval(expr)) {
- var arity = expr.getArity();
- var bindings = state._bindings.splice(state._bindings.length - arity, arity);
- var offsets = state._bindingOffsets.splice(state._bindingOffsets.length - arity, arity);
- return new NonterminalNode(
- state.grammar, this.ruleName, bindings, offsets, inputStream.pos - origPos);
- } else {
- return false;
- }
- };
- pexprs.Apply.prototype.growSeedResult = function(body, state, origPos, lrMemoRec, newValue) {
- if (!newValue) {
- return false;
- }
- var inputStream = state.inputStream;
- while (true) {
- lrMemoRec.matchLength = inputStream.pos - origPos;
- lrMemoRec.value = newValue;
- lrMemoRec.failuresAtRightmostPosition = state.cloneRecordedFailures();
- if (state.isTracing()) {
-
-
-
- var seedTrace = state.trace[state.trace.length - 1];
- lrMemoRec.traceEntry = new Trace(
- state.input, origPos, inputStream.pos, this, true, [newValue], [seedTrace.clone()]);
- }
- inputStream.pos = origPos;
- newValue = this.evalOnce(body, state);
- if (inputStream.pos - origPos <= lrMemoRec.matchLength) {
- break;
- }
- if (state.isTracing()) {
- state.trace.splice(-2, 1);
- }
- }
- if (state.isTracing()) {
-
- lrMemoRec.traceEntry.recordLRTermination(state.trace.pop(), newValue);
- }
- inputStream.pos = origPos + lrMemoRec.matchLength;
- return lrMemoRec.value;
- };
- pexprs.UnicodeChar.prototype.eval = function(state) {
- var inputStream = state.inputStream;
- var origPos = inputStream.pos;
- var ch = inputStream.next();
- if (ch && this.pattern.test(ch)) {
- state.pushBinding(new TerminalNode(state.grammar, ch), origPos);
- return true;
- } else {
- state.processFailure(origPos, this);
- return false;
- }
- };
- },{"./Trace":43,"./common":44,"./errors":45,"./nodes":47,"./pexprs":64}],54:[function(require,module,exports){
- 'use strict';
- var common = require('./common');
- var pexprs = require('./pexprs');
- function flatten(listOfLists) {
- return Array.prototype.concat.apply([], listOfLists);
- }
- pexprs.PExpr.prototype.generateExample = common.abstract('generateExample');
- function categorizeExamples(examples) {
-
-
- var examplesNeeded = examples.filter(function(example) {
- return example.hasOwnProperty('examplesNeeded');
- })
- .map(function(example) { return example.examplesNeeded; });
- examplesNeeded = flatten(examplesNeeded);
- var uniqueExamplesNeeded = {};
- for (var i = 0; i < examplesNeeded.length; i++) {
- var currentExampleNeeded = examplesNeeded[i];
- uniqueExamplesNeeded[currentExampleNeeded] = true;
- }
- examplesNeeded = Object.keys(uniqueExamplesNeeded);
-
- var successfulExamples = examples.filter(function(example) {
- return example.hasOwnProperty('value');
- })
- .map(function(item) { return item.value; });
-
-
-
-
- var needHelp = examples.some(function(item) { return item.needHelp; });
- return {
- examplesNeeded: examplesNeeded,
- successfulExamples: successfulExamples,
- needHelp: needHelp
- };
- }
- pexprs.any.generateExample = function(grammar, examples, inSyntacticContext, actuals) {
- return {value: String.fromCharCode(Math.floor(Math.random() * 255))};
- };
- pexprs.Terminal.prototype.generateExample = function(grammar, examples, inSyntacticContext) {
- return {value: this.obj};
- };
- pexprs.Range.prototype.generateExample = function(grammar, examples, inSyntacticContext) {
- var rangeSize = this.to.charCodeAt(0) - this.from.charCodeAt(0);
- return {value: String.fromCharCode(
- this.from.charCodeAt(0) + Math.floor(rangeSize * Math.random())
- )};
- };
- pexprs.Param.prototype.generateExample = function(grammar, examples, inSyntacticContext, actuals) {
- return actuals[this.index].generateExample(grammar, examples, inSyntacticContext, actuals);
- };
- pexprs.Alt.prototype.generateExample = function(grammar, examples, inSyntacticContext, actuals) {
-
- var termExamples = this.terms.map(function(term) {
- return term.generateExample(grammar, examples, inSyntacticContext, actuals);
- });
- var categorizedExamples = categorizeExamples(termExamples);
- var examplesNeeded = categorizedExamples.examplesNeeded;
- var successfulExamples = categorizedExamples.successfulExamples;
- var needHelp = categorizedExamples.needHelp;
- var ans = {};
-
- if (successfulExamples.length > 0) {
- var i = Math.floor(Math.random() * successfulExamples.length);
- ans.value = successfulExamples[i];
- }
- if (examplesNeeded.length > 0) {
- ans.examplesNeeded = examplesNeeded;
- }
- ans.needHelp = needHelp;
- return ans;
- };
- pexprs.Seq.prototype.generateExample = function(grammar, examples, inSyntacticContext, actuals) {
- var factorExamples = this.factors.map(function(factor) {
- return factor.generateExample(grammar, examples, inSyntacticContext, actuals);
- });
- var categorizedExamples = categorizeExamples(factorExamples);
- var examplesNeeded = categorizedExamples.examplesNeeded;
- var successfulExamples = categorizedExamples.successfulExamples;
- var needHelp = categorizedExamples.needHelp;
- var ans = {};
-
- if (examplesNeeded.length > 0 || needHelp) {
- ans.examplesNeeded = examplesNeeded;
- ans.needHelp = needHelp;
- } else {
- ans.value = successfulExamples.join(inSyntacticContext ? ' ' : '');
- }
- return ans;
- };
- pexprs.Iter.prototype.generateExample = function(grammar, examples, inSyntacticContext, actuals) {
- var rangeTimes = Math.min(this.maxNumMatches - this.minNumMatches, 3);
- var numTimes = Math.floor(Math.random() * (rangeTimes + 1) + this.minNumMatches);
- var items = [];
- for (var i = 0; i < numTimes; i++) {
- items.push(this.expr.generateExample(grammar, examples, inSyntacticContext, actuals));
- }
- var categorizedExamples = categorizeExamples(items);
- var examplesNeeded = categorizedExamples.examplesNeeded;
- var successfulExamples = categorizedExamples.successfulExamples;
- var ans = {};
-
-
- ans.value = successfulExamples.join(inSyntacticContext ? ' ' : '');
- if (examplesNeeded.length > 0) {
- ans.examplesNeeded = examplesNeeded;
- }
- return ans;
- };
- pexprs.Not.prototype.generateExample = function(grammar, examples, inSyntacticContext) {
- return {value: ''};
- };
- pexprs.Lookahead.prototype.generateExample = function(grammar, examples, inSyntacticContext) {
- return {value: ''};
- };
- pexprs.Lex.prototype.generateExample = function(grammar, examples, inSyntacticContext, actuals) {
- return this.expr.generateExample(grammar, examples, false, actuals);
- };
- pexprs.Apply.prototype.generateExample = function(grammar, examples, inSyntacticContext, actuals) {
- var ans = {};
- var ruleName = this.substituteParams(actuals).toString();
- if (!examples.hasOwnProperty(ruleName)) {
- ans.examplesNeeded = [ruleName];
- } else {
- var relevantExamples = examples[ruleName];
- var i = Math.floor(Math.random() * relevantExamples.length);
- ans.value = relevantExamples[i];
- }
- return ans;
- };
- pexprs.UnicodeChar.prototype.generateExample = function(
- grammar, examples, inSyntacticContext, actuals) {
- var char;
- switch (this.category) {
- case 'Lu': char = 'Á'; break;
- case 'Ll': char = 'ŏ'; break;
- case 'Lt': char = 'Dž'; break;
- case 'Lm': char = 'ˮ'; break;
- case 'Lo': char = 'ƻ'; break;
- case 'Nl': char = 'ↂ'; break;
- case 'Nd': char = '½'; break;
- case 'Mn': char = '\u0487'; break;
- case 'Mc': char = 'ि'; break;
- case 'Pc': char = '⁀'; break;
- case 'Zs': char = '\u2001'; break;
- case 'L': char = 'Á'; break;
- case 'Ltmo': char = 'Dž'; break;
- }
- return {value: char};
- };
- },{"./common":44,"./pexprs":64}],55:[function(require,module,exports){
- 'use strict';
- var common = require('./common');
- var pexprs = require('./pexprs');
- pexprs.PExpr.prototype.getArity = common.abstract('getArity');
- pexprs.any.getArity =
- pexprs.end.getArity =
- pexprs.Terminal.prototype.getArity =
- pexprs.Range.prototype.getArity =
- pexprs.Param.prototype.getArity =
- pexprs.Apply.prototype.getArity =
- pexprs.UnicodeChar.prototype.getArity = function() {
- return 1;
- };
- pexprs.Alt.prototype.getArity = function() {
-
-
- return this.terms.length === 0 ? 0 : this.terms[0].getArity();
- };
- pexprs.Seq.prototype.getArity = function() {
- var arity = 0;
- for (var idx = 0; idx < this.factors.length; idx++) {
- arity += this.factors[idx].getArity();
- }
- return arity;
- };
- pexprs.Iter.prototype.getArity = function() {
- return this.expr.getArity();
- };
- pexprs.Not.prototype.getArity = function() {
- return 0;
- };
- pexprs.Lookahead.prototype.getArity =
- pexprs.Lex.prototype.getArity = function() {
- return this.expr.getArity();
- };
- },{"./common":44,"./pexprs":64}],56:[function(require,module,exports){
- 'use strict';
- var common = require('./common');
- var pexprs = require('./pexprs');
- pexprs.PExpr.prototype.introduceParams = common.abstract('introduceParams');
- pexprs.any.introduceParams =
- pexprs.end.introduceParams =
- pexprs.Terminal.prototype.introduceParams =
- pexprs.Range.prototype.introduceParams =
- pexprs.Param.prototype.introduceParams =
- pexprs.UnicodeChar.prototype.introduceParams = function(formals) {
- return this;
- };
- pexprs.Alt.prototype.introduceParams = function(formals) {
- this.terms.forEach(function(term, idx, terms) {
- terms[idx] = term.introduceParams(formals);
- });
- return this;
- };
- pexprs.Seq.prototype.introduceParams = function(formals) {
- this.factors.forEach(function(factor, idx, factors) {
- factors[idx] = factor.introduceParams(formals);
- });
- return this;
- };
- pexprs.Iter.prototype.introduceParams =
- pexprs.Not.prototype.introduceParams =
- pexprs.Lookahead.prototype.introduceParams =
- pexprs.Lex.prototype.introduceParams = function(formals) {
- this.expr = this.expr.introduceParams(formals);
- return this;
- };
- pexprs.Apply.prototype.introduceParams = function(formals) {
- var index = formals.indexOf(this.ruleName);
- if (index >= 0) {
- if (this.args.length > 0) {
-
- throw new Error('Parameterized rules cannot be passed as arguments to another rule.');
- }
- return new pexprs.Param(index).withSource(this.source);
- } else {
- this.args.forEach(function(arg, idx, args) {
- args[idx] = arg.introduceParams(formals);
- });
- return this;
- }
- };
- },{"./common":44,"./pexprs":64}],57:[function(require,module,exports){
- 'use strict';
- var common = require('./common');
- var pexprs = require('./pexprs');
- pexprs.PExpr.prototype.isNullable = function(grammar) {
- return this._isNullable(grammar, Object.create(null));
- };
- pexprs.PExpr.prototype._isNullable = common.abstract('_isNullable');
- pexprs.any._isNullable =
- pexprs.Range.prototype._isNullable =
- pexprs.Param.prototype._isNullable =
- pexprs.Plus.prototype._isNullable =
- pexprs.UnicodeChar.prototype._isNullable = function(grammar, memo) {
- return false;
- };
- pexprs.end._isNullable = function(grammar, memo) {
- return true;
- };
- pexprs.Terminal.prototype._isNullable = function(grammar, memo) {
- if (typeof this.obj === 'string') {
-
-
- return this.obj === '';
- } else {
- return false;
- }
- };
- pexprs.Alt.prototype._isNullable = function(grammar, memo) {
- return this.terms.length === 0 ||
- this.terms.some(function(term) { return term._isNullable(grammar, memo); });
- };
- pexprs.Seq.prototype._isNullable = function(grammar, memo) {
- return this.factors.every(function(factor) { return factor._isNullable(grammar, memo); });
- };
- pexprs.Star.prototype._isNullable =
- pexprs.Opt.prototype._isNullable =
- pexprs.Not.prototype._isNullable =
- pexprs.Lookahead.prototype._isNullable = function(grammar, memo) {
- return true;
- };
- pexprs.Lex.prototype._isNullable = function(grammar, memo) {
- return this.expr._isNullable(grammar, memo);
- };
- pexprs.Apply.prototype._isNullable = function(grammar, memo) {
- var key = this.toMemoKey();
- if (!Object.prototype.hasOwnProperty.call(memo, key)) {
- var body = grammar.rules[this.ruleName].body;
- var inlined = body.substituteParams(this.args);
- memo[key] = false;
- memo[key] = inlined._isNullable(grammar, memo);
- }
- return memo[key];
- };
- },{"./common":44,"./pexprs":64}],58:[function(require,module,exports){
- 'use strict';
- var common = require('./common');
- var pexprs = require('./pexprs');
- function getMetaInfo(expr, grammarInterval) {
- var metaInfo = {};
- if (expr.source && grammarInterval) {
- var adjusted = expr.source.relativeTo(grammarInterval);
- metaInfo.sourceInterval = [adjusted.startIdx, adjusted.endIdx];
- }
- return metaInfo;
- }
- pexprs.PExpr.prototype.outputRecipe = common.abstract('outputRecipe');
- pexprs.any.outputRecipe = function(formals, grammarInterval) {
- return ['any', getMetaInfo(this, grammarInterval)];
- };
- pexprs.end.outputRecipe = function(formals, grammarInterval) {
- return ['end', getMetaInfo(this, grammarInterval)];
- };
- pexprs.Terminal.prototype.outputRecipe = function(formals, grammarInterval) {
- return [
- 'terminal',
- getMetaInfo(this, grammarInterval),
- this.obj
- ];
- };
- pexprs.Range.prototype.outputRecipe = function(formals, grammarInterval) {
- return [
- 'range',
- getMetaInfo(this, grammarInterval),
- this.from,
- this.to
- ];
- };
- pexprs.Param.prototype.outputRecipe = function(formals, grammarInterval) {
- return [
- 'param',
- getMetaInfo(this, grammarInterval),
- this.index
- ];
- };
- pexprs.Alt.prototype.outputRecipe = function(formals, grammarInterval) {
- return [
- 'alt',
- getMetaInfo(this, grammarInterval)
- ].concat(this.terms.map(function(term) {
- return term.outputRecipe(formals, grammarInterval);
- }));
- };
- pexprs.Extend.prototype.outputRecipe = function(formals, grammarInterval) {
- var extension = this.terms[0];
- return extension.outputRecipe(formals, grammarInterval);
- };
- pexprs.Seq.prototype.outputRecipe = function(formals, grammarInterval) {
- return [
- 'seq',
- getMetaInfo(this, grammarInterval)
- ].concat(this.factors.map(function(factor) {
- return factor.outputRecipe(formals, grammarInterval);
- }));
- };
- pexprs.Star.prototype.outputRecipe =
- pexprs.Plus.prototype.outputRecipe =
- pexprs.Opt.prototype.outputRecipe =
- pexprs.Not.prototype.outputRecipe =
- pexprs.Lookahead.prototype.outputRecipe =
- pexprs.Lex.prototype.outputRecipe = function(formals, grammarInterval) {
- return [
- this.constructor.name.toLowerCase(),
- getMetaInfo(this, grammarInterval),
- this.expr.outputRecipe(formals, grammarInterval)
- ];
- };
- pexprs.Apply.prototype.outputRecipe = function(formals, grammarInterval) {
- return [
- 'app',
- getMetaInfo(this, grammarInterval),
- this.ruleName,
- this.args.map(function(arg) {
- return arg.outputRecipe(formals, grammarInterval);
- })
- ];
- };
- pexprs.UnicodeChar.prototype.outputRecipe = function(formals, grammarInterval) {
- return [
- 'unicodeChar',
- getMetaInfo(this, grammarInterval),
- this.category
- ];
- };
- },{"./common":44,"./pexprs":64}],59:[function(require,module,exports){
- 'use strict';
- var common = require('./common');
- var pexprs = require('./pexprs');
- pexprs.PExpr.prototype.substituteParams = common.abstract('substituteParams');
- pexprs.any.substituteParams =
- pexprs.end.substituteParams =
- pexprs.Terminal.prototype.substituteParams =
- pexprs.Range.prototype.substituteParams =
- pexprs.UnicodeChar.prototype.substituteParams = function(actuals) {
- return this;
- };
- pexprs.Param.prototype.substituteParams = function(actuals) {
- return actuals[this.index];
- };
- pexprs.Alt.prototype.substituteParams = function(actuals) {
- return new pexprs.Alt(
- this.terms.map(function(term) { return term.substituteParams(actuals); }));
- };
- pexprs.Seq.prototype.substituteParams = function(actuals) {
- return new pexprs.Seq(
- this.factors.map(function(factor) { return factor.substituteParams(actuals); }));
- };
- pexprs.Iter.prototype.substituteParams =
- pexprs.Not.prototype.substituteParams =
- pexprs.Lookahead.prototype.substituteParams =
- pexprs.Lex.prototype.substituteParams = function(actuals) {
- return new this.constructor(this.expr.substituteParams(actuals));
- };
- pexprs.Apply.prototype.substituteParams = function(actuals) {
- if (this.args.length === 0) {
-
- return this;
- } else {
- var args = this.args.map(function(arg) { return arg.substituteParams(actuals); });
- return new pexprs.Apply(this.ruleName, args);
- }
- };
- },{"./common":44,"./pexprs":64}],60:[function(require,module,exports){
- 'use strict';
- var common = require('./common');
- var pexprs = require('./pexprs');
- var copyWithoutDuplicates = common.copyWithoutDuplicates;
- function isRestrictedJSIdentifier(str) {
- return /^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(str);
- }
- function resolveDuplicatedNames(argumentNameList) {
-
-
- var count = Object.create(null);
- argumentNameList.forEach(function(argName) {
- count[argName] = (count[argName] || 0) + 1;
- });
-
- Object.keys(count).forEach(function(dupArgName) {
- if (count[dupArgName] <= 1) {
- return;
- }
-
- var subscript = 1;
- argumentNameList.forEach(function(argName, idx) {
- if (argName === dupArgName) {
- argumentNameList[idx] = argName + '_' + subscript++;
- }
- });
- });
- }
- pexprs.PExpr.prototype.toArgumentNameList = common.abstract('toArgumentNameList');
- pexprs.any.toArgumentNameList = function(firstArgIndex, noDupCheck) {
- return ['any'];
- };
- pexprs.end.toArgumentNameList = function(firstArgIndex, noDupCheck) {
- return ['end'];
- };
- pexprs.Terminal.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
- if (typeof this.obj === 'string' && /^[_a-zA-Z0-9]+$/.test(this.obj)) {
-
- return ['_' + this.obj];
- } else {
-
- return ['$' + firstArgIndex];
- }
- };
- pexprs.Range.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
- var argName = this.from + '_to_' + this.to;
-
- if (!isRestrictedJSIdentifier(argName)) {
- argName = '_' + argName;
- }
-
- if (!isRestrictedJSIdentifier(argName)) {
- argName = '$' + firstArgIndex;
- }
- return [argName];
- };
- pexprs.Alt.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
-
-
- var termArgNameLists = this.terms.map(function(term) {
- return term.toArgumentNameList(firstArgIndex, true);
- });
- var argumentNameList = [];
- var numArgs = termArgNameLists[0].length;
- for (var colIdx = 0; colIdx < numArgs; colIdx++) {
- var col = [];
- for (var rowIdx = 0; rowIdx < this.terms.length; rowIdx++) {
- col.push(termArgNameLists[rowIdx][colIdx]);
- }
- var uniqueNames = copyWithoutDuplicates(col);
- argumentNameList.push(uniqueNames.join('_or_'));
- }
- if (!noDupCheck) {
- resolveDuplicatedNames(argumentNameList);
- }
- return argumentNameList;
- };
- pexprs.Seq.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
-
- var argumentNameList = [];
- this.factors.forEach(function(factor) {
- var factorArgumentNameList = factor.toArgumentNameList(firstArgIndex, true);
- argumentNameList = argumentNameList.concat(factorArgumentNameList);
-
- firstArgIndex += factorArgumentNameList.length;
- });
- if (!noDupCheck) {
- resolveDuplicatedNames(argumentNameList);
- }
- return argumentNameList;
- };
- pexprs.Iter.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
- var argumentNameList = this.expr.toArgumentNameList(firstArgIndex, noDupCheck)
- .map(function(exprArgumentString) {
- return exprArgumentString[exprArgumentString.length - 1] === 's' ?
- exprArgumentString + 'es' :
- exprArgumentString + 's';
- });
- if (!noDupCheck) {
- resolveDuplicatedNames(argumentNameList);
- }
- return argumentNameList;
- };
- pexprs.Opt.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
- return this.expr.toArgumentNameList(firstArgIndex, noDupCheck).map(function(argName) {
- return 'opt' + argName[0].toUpperCase() + argName.slice(1);
- });
- };
- pexprs.Not.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
- return [];
- };
- pexprs.Lookahead.prototype.toArgumentNameList =
- pexprs.Lex.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
- return this.expr.toArgumentNameList(firstArgIndex, noDupCheck);
- };
- pexprs.Apply.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
- return [this.ruleName];
- };
- pexprs.UnicodeChar.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
- return ['$' + firstArgIndex];
- };
- pexprs.Param.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
- return ['param' + this.index];
- };
- },{"./common":44,"./pexprs":64}],61:[function(require,module,exports){
- 'use strict';
- var common = require('./common');
- var pexprs = require('./pexprs');
- pexprs.PExpr.prototype.toDisplayString = common.abstract('toDisplayString');
- pexprs.Alt.prototype.toDisplayString =
- pexprs.Seq.prototype.toDisplayString = function() {
- if (this.source) {
- return this.source.trimmed().contents;
- }
- return '[' + this.constructor.name + ']';
- };
- pexprs.any.toDisplayString =
- pexprs.end.toDisplayString =
- pexprs.Iter.prototype.toDisplayString =
- pexprs.Not.prototype.toDisplayString =
- pexprs.Lookahead.prototype.toDisplayString =
- pexprs.Lex.prototype.toDisplayString =
- pexprs.Terminal.prototype.toDisplayString =
- pexprs.Range.prototype.toDisplayString =
- pexprs.Param.prototype.toDisplayString = function() {
- return this.toString();
- };
- pexprs.Apply.prototype.toDisplayString = function() {
- if (this.args.length > 0) {
- var ps = this.args.map(function(arg) { return arg.toDisplayString(); });
- return this.ruleName + '<' + ps.join(',') + '>';
- } else {
- return this.ruleName;
- }
- };
- pexprs.UnicodeChar.prototype.toDisplayString = function() {
- return 'Unicode [' + this.category + '] character';
- };
- },{"./common":44,"./pexprs":64}],62:[function(require,module,exports){
- 'use strict';
- var Failure = require('./Failure');
- var common = require('./common');
- var pexprs = require('./pexprs');
- pexprs.PExpr.prototype.toFailure = common.abstract('toFailure');
- pexprs.any.toFailure = function(grammar) {
- return new Failure(this, 'any object', 'description');
- };
- pexprs.end.toFailure = function(grammar) {
- return new Failure(this, 'end of input', 'description');
- };
- pexprs.Terminal.prototype.toFailure = function(grammar) {
- return new Failure(this, this.obj, 'string');
- };
- pexprs.Range.prototype.toFailure = function(grammar) {
-
- return new Failure(this, JSON.stringify(this.from) + '..' + JSON.stringify(this.to), 'code');
- };
- pexprs.Not.prototype.toFailure = function(grammar) {
- var description = this.expr === pexprs.any ?
- 'nothing' :
- 'not ' + this.expr.toFailure(grammar);
- return new Failure(this, description, 'description');
- };
- pexprs.Lookahead.prototype.toFailure = function(grammar) {
- return this.expr.toFailure(grammar);
- };
- pexprs.Apply.prototype.toFailure = function(grammar) {
- var description = grammar.rules[this.ruleName].description;
- if (!description) {
- var article = (/^[aeiouAEIOU]/.test(this.ruleName) ? 'an' : 'a');
- description = article + ' ' + this.ruleName;
- }
- return new Failure(this, description, 'description');
- };
- pexprs.UnicodeChar.prototype.toFailure = function(grammar) {
- return new Failure(this, 'a Unicode [' + this.category + '] character', 'description');
- };
- pexprs.Alt.prototype.toFailure = function(grammar) {
- var fs = this.terms.map(function(t) { return t.toFailure(grammar); });
- var description = '(' + fs.join(' or ') + ')';
- return new Failure(this, description, 'description');
- };
- pexprs.Seq.prototype.toFailure = function(grammar) {
- var fs = this.factors.map(function(f) { return f.toFailure(grammar); });
- var description = '(' + fs.join(' ') + ')';
- return new Failure(this, description, 'description');
- };
- pexprs.Iter.prototype.toFailure = function(grammar) {
- var description = '(' + this.expr.toFailure(grammar) + this.operator + ')';
- return new Failure(this, description, 'description');
- };
- },{"./Failure":32,"./common":44,"./pexprs":64}],63:[function(require,module,exports){
- 'use strict';
- var common = require('./common');
- var pexprs = require('./pexprs');
- pexprs.PExpr.prototype.toString = common.abstract('toString');
- pexprs.any.toString = function() {
- return 'any';
- };
- pexprs.end.toString = function() {
- return 'end';
- };
- pexprs.Terminal.prototype.toString = function() {
- return JSON.stringify(this.obj);
- };
- pexprs.Range.prototype.toString = function() {
- return JSON.stringify(this.from) + '..' + JSON.stringify(this.to);
- };
- pexprs.Param.prototype.toString = function() {
- return '$' + this.index;
- };
- pexprs.Lex.prototype.toString = function() {
- return '#(' + this.expr.toString() + ')';
- };
- pexprs.Alt.prototype.toString = function() {
- return this.terms.length === 1 ?
- this.terms[0].toString() :
- '(' + this.terms.map(function(term) { return term.toString(); }).join(' | ') + ')';
- };
- pexprs.Seq.prototype.toString = function() {
- return this.factors.length === 1 ?
- this.factors[0].toString() :
- '(' + this.factors.map(function(factor) { return factor.toString(); }).join(' ') + ')';
- };
- pexprs.Iter.prototype.toString = function() {
- return this.expr + this.operator;
- };
- pexprs.Not.prototype.toString = function() {
- return '~' + this.expr;
- };
- pexprs.Lookahead.prototype.toString = function() {
- return '&' + this.expr;
- };
- pexprs.Apply.prototype.toString = function() {
- if (this.args.length > 0) {
- var ps = this.args.map(function(arg) { return arg.toString(); });
- return this.ruleName + '<' + ps.join(',') + '>';
- } else {
- return this.ruleName;
- }
- };
- pexprs.UnicodeChar.prototype.toString = function() {
- return '\\p{' + this.category + '}';
- };
- },{"./common":44,"./pexprs":64}],64:[function(require,module,exports){
- 'use strict';
- var UnicodeCategories = require('../third_party/UnicodeCategories');
- var common = require('./common');
- var inherits = require('inherits');
- function PExpr() {
- throw new Error("PExpr cannot be instantiated -- it's abstract");
- }
- PExpr.prototype.withSource = function(interval) {
- if (interval) {
- this.source = interval.trimmed();
- }
- return this;
- };
- var any = Object.create(PExpr.prototype);
- var end = Object.create(PExpr.prototype);
- function Terminal(obj) {
- this.obj = obj;
- }
- inherits(Terminal, PExpr);
- function Range(from, to) {
- this.from = from;
- this.to = to;
- }
- inherits(Range, PExpr);
- function Param(index) {
- this.index = index;
- }
- inherits(Param, PExpr);
- function Alt(terms) {
- this.terms = terms;
- }
- inherits(Alt, PExpr);
- function Extend(superGrammar, name, body) {
- this.superGrammar = superGrammar;
- this.name = name;
- this.body = body;
- var origBody = superGrammar.rules[name].body;
- this.terms = [body, origBody];
- }
- inherits(Extend, Alt);
- function Seq(factors) {
- this.factors = factors;
- }
- inherits(Seq, PExpr);
- function Iter(expr) {
- this.expr = expr;
- }
- inherits(Iter, PExpr);
- function Star(expr) {
- this.expr = expr;
- }
- inherits(Star, Iter);
- function Plus(expr) {
- this.expr = expr;
- }
- inherits(Plus, Iter);
- function Opt(expr) {
- this.expr = expr;
- }
- inherits(Opt, Iter);
- Star.prototype.operator = '*';
- Plus.prototype.operator = '+';
- Opt.prototype.operator = '?';
- Star.prototype.minNumMatches = 0;
- Plus.prototype.minNumMatches = 1;
- Opt.prototype.minNumMatches = 0;
- Star.prototype.maxNumMatches = Number.POSITIVE_INFINITY;
- Plus.prototype.maxNumMatches = Number.POSITIVE_INFINITY;
- Opt.prototype.maxNumMatches = 1;
- function Not(expr) {
- this.expr = expr;
- }
- inherits(Not, PExpr);
- function Lookahead(expr) {
- this.expr = expr;
- }
- inherits(Lookahead, PExpr);
- function Lex(expr) {
- this.expr = expr;
- }
- inherits(Lex, PExpr);
- function Apply(ruleName, optArgs) {
- this.ruleName = ruleName;
- this.args = optArgs || [];
- }
- inherits(Apply, PExpr);
- Apply.prototype.isSyntactic = function() {
- return common.isSyntactic(this.ruleName);
- };
- Apply.prototype.toMemoKey = function() {
- if (!this._memoKey) {
- Object.defineProperty(this, '_memoKey', {value: this.toString()});
- }
- return this._memoKey;
- };
- function UnicodeChar(category) {
- this.category = category;
- this.pattern = UnicodeCategories[category];
- }
- inherits(UnicodeChar, PExpr);
- exports.PExpr = PExpr;
- exports.any = any;
- exports.end = end;
- exports.Terminal = Terminal;
- exports.Range = Range;
- exports.Param = Param;
- exports.Alt = Alt;
- exports.Extend = Extend;
- exports.Seq = Seq;
- exports.Iter = Iter;
- exports.Star = Star;
- exports.Plus = Plus;
- exports.Opt = Opt;
- exports.Not = Not;
- exports.Lookahead = Lookahead;
- exports.Lex = Lex;
- exports.Apply = Apply;
- exports.UnicodeChar = UnicodeChar;
- require('./pexprs-allowsSkippingPrecedingSpace');
- require('./pexprs-assertAllApplicationsAreValid');
- require('./pexprs-assertChoicesHaveUniformArity');
- require('./pexprs-assertIteratedExprsAreNotNullable');
- require('./pexprs-check');
- require('./pexprs-eval');
- require('./pexprs-getArity');
- require('./pexprs-generateExample');
- require('./pexprs-outputRecipe');
- require('./pexprs-introduceParams');
- require('./pexprs-isNullable');
- require('./pexprs-substituteParams');
- require('./pexprs-toDisplayString');
- require('./pexprs-toArgumentNameList');
- require('./pexprs-toFailure');
- require('./pexprs-toString');
- },{"../third_party/UnicodeCategories":67,"./common":44,"./pexprs-allowsSkippingPrecedingSpace":48,"./pexprs-assertAllApplicationsAreValid":49,"./pexprs-assertChoicesHaveUniformArity":50,"./pexprs-assertIteratedExprsAreNotNullable":51,"./pexprs-check":52,"./pexprs-eval":53,"./pexprs-generateExample":54,"./pexprs-getArity":55,"./pexprs-introduceParams":56,"./pexprs-isNullable":57,"./pexprs-outputRecipe":58,"./pexprs-substituteParams":59,"./pexprs-toArgumentNameList":60,"./pexprs-toDisplayString":61,"./pexprs-toFailure":62,"./pexprs-toString":63,"inherits":27}],65:[function(require,module,exports){
- 'use strict';
- var common = require('./common');
- function padNumbersToEqualLength(arr) {
- var maxLen = 0;
- var strings = arr.map(function(n) {
- var str = n.toString();
- maxLen = Math.max(maxLen, str.length);
- return str;
- });
- return strings.map(function(s) { return common.padLeft(s, maxLen); });
- }
- function strcpy(dest, src, offset) {
- var origDestLen = dest.length;
- var start = dest.slice(0, offset);
- var end = dest.slice(offset + src.length);
- return (start + src + end).substr(0, origDestLen);
- }
- var builtInRulesCallbacks = [];
- exports.awaitBuiltInRules = function(cb) {
- builtInRulesCallbacks.push(cb);
- };
- exports.announceBuiltInRules = function(grammar) {
- builtInRulesCallbacks.forEach(function(cb) {
- cb(grammar);
- });
- builtInRulesCallbacks = null;
- };
- exports.getLineAndColumn = function(str, offset) {
- var lineNum = 1;
- var colNum = 1;
- var currOffset = 0;
- var lineStartOffset = 0;
- var nextLine = null;
- var prevLine = null;
- var prevLineStartOffset = -1;
- while (currOffset < offset) {
- var c = str.charAt(currOffset++);
- if (c === '\n') {
- lineNum++;
- colNum = 1;
- prevLineStartOffset = lineStartOffset;
- lineStartOffset = currOffset;
- } else if (c !== '\r') {
- colNum++;
- }
- }
-
- var lineEndOffset = str.indexOf('\n', lineStartOffset);
- if (lineEndOffset === -1) {
- lineEndOffset = str.length;
- } else {
-
- var nextLineEndOffset = str.indexOf('\n', lineEndOffset + 1);
- nextLine = nextLineEndOffset === -1 ? str.slice(lineEndOffset)
- : str.slice(lineEndOffset, nextLineEndOffset);
-
- nextLine = nextLine.replace(/^\r?\n/, '').replace(/\r$/, '');
- }
-
- if (prevLineStartOffset >= 0) {
- prevLine = str.slice(prevLineStartOffset, lineStartOffset)
- .replace(/\r?\n$/, '');
- }
-
- var line = str.slice(lineStartOffset, lineEndOffset).replace(/\r$/, '');
- return {
- lineNum: lineNum,
- colNum: colNum,
- line: line,
- prevLine: prevLine,
- nextLine: nextLine
- };
- };
- exports.getLineAndColumnMessage = function(str, offset /* ...ranges */) {
- var repeatStr = common.repeatStr;
- var lineAndCol = exports.getLineAndColumn(str, offset);
- var sb = new common.StringBuffer();
- sb.append('Line ' + lineAndCol.lineNum + ', col ' + lineAndCol.colNum + ':\n');
-
- var lineNumbers = padNumbersToEqualLength([
- lineAndCol.prevLine == null ? 0 : lineAndCol.lineNum - 1,
- lineAndCol.lineNum,
- lineAndCol.nextLine == null ? 0 : lineAndCol.lineNum + 1
- ]);
-
- function appendLine(num, content, prefix) {
- sb.append(prefix + lineNumbers[num] + ' | ' + content + '\n');
- }
-
- if (lineAndCol.prevLine != null) {
- appendLine(0, lineAndCol.prevLine, ' ');
- }
-
- appendLine(1, lineAndCol.line, '> ');
-
-
- var lineLen = lineAndCol.line.length;
- var indicationLine = repeatStr(' ', lineLen + 1);
- var ranges = Array.prototype.slice.call(arguments, 2);
- for (var i = 0; i < ranges.length; ++i) {
- var startIdx = ranges[i][0];
- var endIdx = ranges[i][1];
- common.assert(startIdx >= 0 && startIdx <= endIdx, 'range start must be >= 0 and <= end');
- var lineStartOffset = offset - lineAndCol.colNum + 1;
- startIdx = Math.max(0, startIdx - lineStartOffset);
- endIdx = Math.min(endIdx - lineStartOffset, lineLen);
- indicationLine = strcpy(indicationLine, repeatStr('~', endIdx - startIdx), startIdx);
- }
- var gutterWidth = 2 + lineNumbers[1].length + 3;
- sb.append(repeatStr(' ', gutterWidth));
- indicationLine = strcpy(indicationLine, '^', lineAndCol.colNum - 1);
- sb.append(indicationLine.replace(/ +$/, '') + '\n');
-
- if (lineAndCol.nextLine != null) {
- appendLine(2, lineAndCol.nextLine, ' ');
- }
- return sb.contents();
- };
- },{"./common":44}],66:[function(require,module,exports){
- (function (browserifyGlobalOhmVersion){
- 'use strict';
- module.exports = typeof browserifyGlobalOhmVersion === 'string'
- ? browserifyGlobalOhmVersion
- : require('../package.json').version;
- }).call(this,"0.14.0")
- },{"../package.json":undefined}],67:[function(require,module,exports){
- module.exports = {
-
- Lu: /[A-Z\xC0-\xD6\xD8-\xDE\u0100\u0102\u0104\u0106\u0108\u010A\u010C\u010E\u0110\u0112\u0114\u0116\u0118\u011A\u011C\u011E\u0120\u0122\u0124\u0126\u0128\u012A\u012C\u012E\u0130\u0132\u0134\u0136\u0139\u013B\u013D\u013F\u0141\u0143\u0145\u0147\u014A\u014C\u014E\u0150\u0152\u0154\u0156\u0158\u015A\u015C\u015E\u0160\u0162\u0164\u0166\u0168\u016A\u016C\u016E\u0170\u0172\u0174\u0176\u0178\u0179\u017B\u017D\u0181\u0182\u0184\u0186\u0187\u0189-\u018B\u018E-\u0191\u0193\u0194\u0196-\u0198\u019C\u019D\u019F\u01A0\u01A2\u01A4\u01A6\u01A7\u01A9\u01AC\u01AE\u01AF\u01B1-\u01B3\u01B5\u01B7\u01B8\u01BC\u01C4\u01C7\u01CA\u01CD\u01CF\u01D1\u01D3\u01D5\u01D7\u01D9\u01DB\u01DE\u01E0\u01E2\u01E4\u01E6\u01E8\u01EA\u01EC\u01EE\u01F1\u01F4\u01F6-\u01F8\u01FA\u01FC\u01FE\u0200\u0202\u0204\u0206\u0208\u020A\u020C\u020E\u0210\u0212\u0214\u0216\u0218\u021A\u021C\u021E\u0220\u0222\u0224\u0226\u0228\u022A\u022C\u022E\u0230\u0232\u023A\u023B\u023D\u023E\u0241\u0243-\u0246\u0248\u024A\u024C\u024E\u0370\u0372\u0376\u037F\u0386\u0388-\u038A\u038C\u038E\u038F\u0391-\u03A1\u03A3-\u03AB\u03CF\u03D2-\u03D4\u03D8\u03DA\u03DC\u03DE\u03E0\u03E2\u03E4\u03E6\u03E8\u03EA\u03EC\u03EE\u03F4\u03F7\u03F9\u03FA\u03FD-\u042F\u0460\u0462\u0464\u0466\u0468\u046A\u046C\u046E\u0470\u0472\u0474\u0476\u0478\u047A\u047C\u047E\u0480\u048A\u048C\u048E\u0490\u0492\u0494\u0496\u0498\u049A\u049C\u049E\u04A0\u04A2\u04A4\u04A6\u04A8\u04AA\u04AC\u04AE\u04B0\u04B2\u04B4\u04B6\u04B8\u04BA\u04BC\u04BE\u04C0\u04C1\u04C3\u04C5\u04C7\u04C9\u04CB\u04CD\u04D0\u04D2\u04D4\u04D6\u04D8\u04DA\u04DC\u04DE\u04E0\u04E2\u04E4\u04E6\u04E8\u04EA\u04EC\u04EE\u04F0\u04F2\u04F4\u04F6\u04F8\u04FA\u04FC\u04FE\u0500\u0502\u0504\u0506\u0508\u050A\u050C\u050E\u0510\u0512\u0514\u0516\u0518\u051A\u051C\u051E\u0520\u0522\u0524\u0526\u0528\u052A\u052C\u052E\u0531-\u0556\u10A0-\u10C5\u10C7\u10CD\u13A0-\u13F5\u1E00\u1E02\u1E04\u1E06\u1E08\u1E0A\u1E0C\u1E0E\u1E10\u1E12\u1E14\u1E16\u1E18\u1E1A\u1E1C\u1E1E\u1E20\u1E22\u1E24\u1E26\u1E28\u1E2A\u1E2C\u1E2E\u1E30\u1E32\u1E34\u1E36\u1E38\u1E3A\u1E3C\u1E3E\u1E40\u1E42\u1E44\u1E46\u1E48\u1E4A\u1E4C\u1E4E\u1E50\u1E52\u1E54\u1E56\u1E58\u1E5A\u1E5C\u1E5E\u1E60\u1E62\u1E64\u1E66\u1E68\u1E6A\u1E6C\u1E6E\u1E70\u1E72\u1E74\u1E76\u1E78\u1E7A\u1E7C\u1E7E\u1E80\u1E82\u1E84\u1E86\u1E88\u1E8A\u1E8C\u1E8E\u1E90\u1E92\u1E94\u1E9E\u1EA0\u1EA2\u1EA4\u1EA6\u1EA8\u1EAA\u1EAC\u1EAE\u1EB0\u1EB2\u1EB4\u1EB6\u1EB8\u1EBA\u1EBC\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6\u1EC8\u1ECA\u1ECC\u1ECE\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u1EDA\u1EDC\u1EDE\u1EE0\u1EE2\u1EE4\u1EE6\u1EE8\u1EEA\u1EEC\u1EEE\u1EF0\u1EF2\u1EF4\u1EF6\u1EF8\u1EFA\u1EFC\u1EFE\u1F08-\u1F0F\u1F18-\u1F1D\u1F28-\u1F2F\u1F38-\u1F3F\u1F48-\u1F4D\u1F59\u1F5B\u1F5D\u1F5F\u1F68-\u1F6F\u1FB8-\u1FBB\u1FC8-\u1FCB\u1FD8-\u1FDB\u1FE8-\u1FEC\u1FF8-\u1FFB\u2102\u2107\u210B-\u210D\u2110-\u2112\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u2130-\u2133\u213E\u213F\u2145\u2183\u2C00-\u2C2E\u2C60\u2C62-\u2C64\u2C67\u2C69\u2C6B\u2C6D-\u2C70\u2C72\u2C75\u2C7E-\u2C80\u2C82\u2C84\u2C86\u2C88\u2C8A\u2C8C\u2C8E\u2C90\u2C92\u2C94\u2C96\u2C98\u2C9A\u2C9C\u2C9E\u2CA0\u2CA2\u2CA4\u2CA6\u2CA8\u2CAA\u2CAC\u2CAE\u2CB0\u2CB2\u2CB4\u2CB6\u2CB8\u2CBA\u2CBC\u2CBE\u2CC0\u2CC2\u2CC4\u2CC6\u2CC8\u2CCA\u2CCC\u2CCE\u2CD0\u2CD2\u2CD4\u2CD6\u2CD8\u2CDA\u2CDC\u2CDE\u2CE0\u2CE2\u2CEB\u2CED\u2CF2\uA640\uA642\uA644\uA646\uA648\uA64A\uA64C\uA64E\uA650\uA652\uA654\uA656\uA658\uA65A\uA65C\uA65E\uA660\uA662\uA664\uA666\uA668\uA66A\uA66C\uA680\uA682\uA684\uA686\uA688\uA68A\uA68C\uA68E\uA690\uA692\uA694\uA696\uA698\uA69A\uA722\uA724\uA726\uA728\uA72A\uA72C\uA72E\uA732\uA734\uA736\uA738\uA73A\uA73C\uA73E\uA740\uA742\uA744\uA746\uA748\uA74A\uA74C\uA74E\uA750\uA752\uA754\uA756\uA758\uA75A\uA75C\uA75E\uA760\uA762\uA764\uA766\uA768\uA76A\uA76C\uA76E\uA779\uA77B\uA77D\uA77E\uA780\uA782\uA784\uA786\uA78B\uA78D\uA790\uA792\uA796\uA798\uA79A\uA79C\uA79E\uA7A0\uA7A2\uA7A4\uA7A6\uA7A8\uA7AA-\uA7AE\uA7B0-\uA7B4\uA7B6\uFF21-\uFF3A]|\uD801[\uDC00-\uDC27\uDCB0-\uDCD3]|\uD803[\uDC80-\uDCB2]|\uD806[\uDCA0-\uDCBF]|\uD835[\uDC00-\uDC19\uDC34-\uDC4D\uDC68-\uDC81\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB5\uDCD0-\uDCE9\uDD04\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD38\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD6C-\uDD85\uDDA0-\uDDB9\uDDD4-\uDDED\uDE08-\uDE21\uDE3C-\uDE55\uDE70-\uDE89\uDEA8-\uDEC0\uDEE2-\uDEFA\uDF1C-\uDF34\uDF56-\uDF6E\uDF90-\uDFA8\uDFCA]|\uD83A[\uDD00-\uDD21]/,
- Ll: /[a-z\xB5\xDF-\xF6\xF8-\xFF\u0101\u0103\u0105\u0107\u0109\u010B\u010D\u010F\u0111\u0113\u0115\u0117\u0119\u011B\u011D\u011F\u0121\u0123\u0125\u0127\u0129\u012B\u012D\u012F\u0131\u0133\u0135\u0137\u0138\u013A\u013C\u013E\u0140\u0142\u0144\u0146\u0148\u0149\u014B\u014D\u014F\u0151\u0153\u0155\u0157\u0159\u015B\u015D\u015F\u0161\u0163\u0165\u0167\u0169\u016B\u016D\u016F\u0171\u0173\u0175\u0177\u017A\u017C\u017E-\u0180\u0183\u0185\u0188\u018C\u018D\u0192\u0195\u0199-\u019B\u019E\u01A1\u01A3\u01A5\u01A8\u01AA\u01AB\u01AD\u01B0\u01B4\u01B6\u01B9\u01BA\u01BD-\u01BF\u01C6\u01C9\u01CC\u01CE\u01D0\u01D2\u01D4\u01D6\u01D8\u01DA\u01DC\u01DD\u01DF\u01E1\u01E3\u01E5\u01E7\u01E9\u01EB\u01ED\u01EF\u01F0\u01F3\u01F5\u01F9\u01FB\u01FD\u01FF\u0201\u0203\u0205\u0207\u0209\u020B\u020D\u020F\u0211\u0213\u0215\u0217\u0219\u021B\u021D\u021F\u0221\u0223\u0225\u0227\u0229\u022B\u022D\u022F\u0231\u0233-\u0239\u023C\u023F\u0240\u0242\u0247\u0249\u024B\u024D\u024F-\u0293\u0295-\u02AF\u0371\u0373\u0377\u037B-\u037D\u0390\u03AC-\u03CE\u03D0\u03D1\u03D5-\u03D7\u03D9\u03DB\u03DD\u03DF\u03E1\u03E3\u03E5\u03E7\u03E9\u03EB\u03ED\u03EF-\u03F3\u03F5\u03F8\u03FB\u03FC\u0430-\u045F\u0461\u0463\u0465\u0467\u0469\u046B\u046D\u046F\u0471\u0473\u0475\u0477\u0479\u047B\u047D\u047F\u0481\u048B\u048D\u048F\u0491\u0493\u0495\u0497\u0499\u049B\u049D\u049F\u04A1\u04A3\u04A5\u04A7\u04A9\u04AB\u04AD\u04AF\u04B1\u04B3\u04B5\u04B7\u04B9\u04BB\u04BD\u04BF\u04C2\u04C4\u04C6\u04C8\u04CA\u04CC\u04CE\u04CF\u04D1\u04D3\u04D5\u04D7\u04D9\u04DB\u04DD\u04DF\u04E1\u04E3\u04E5\u04E7\u04E9\u04EB\u04ED\u04EF\u04F1\u04F3\u04F5\u04F7\u04F9\u04FB\u04FD\u04FF\u0501\u0503\u0505\u0507\u0509\u050B\u050D\u050F\u0511\u0513\u0515\u0517\u0519\u051B\u051D\u051F\u0521\u0523\u0525\u0527\u0529\u052B\u052D\u052F\u0561-\u0587\u13F8-\u13FD\u1C80-\u1C88\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E01\u1E03\u1E05\u1E07\u1E09\u1E0B\u1E0D\u1E0F\u1E11\u1E13\u1E15\u1E17\u1E19\u1E1B\u1E1D\u1E1F\u1E21\u1E23\u1E25\u1E27\u1E29\u1E2B\u1E2D\u1E2F\u1E31\u1E33\u1E35\u1E37\u1E39\u1E3B\u1E3D\u1E3F\u1E41\u1E43\u1E45\u1E47\u1E49\u1E4B\u1E4D\u1E4F\u1E51\u1E53\u1E55\u1E57\u1E59\u1E5B\u1E5D\u1E5F\u1E61\u1E63\u1E65\u1E67\u1E69\u1E6B\u1E6D\u1E6F\u1E71\u1E73\u1E75\u1E77\u1E79\u1E7B\u1E7D\u1E7F\u1E81\u1E83\u1E85\u1E87\u1E89\u1E8B\u1E8D\u1E8F\u1E91\u1E93\u1E95-\u1E9D\u1E9F\u1EA1\u1EA3\u1EA5\u1EA7\u1EA9\u1EAB\u1EAD\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\u1EB9\u1EBB\u1EBD\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7\u1EC9\u1ECB\u1ECD\u1ECF\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3\u1EE5\u1EE7\u1EE9\u1EEB\u1EED\u1EEF\u1EF1\u1EF3\u1EF5\u1EF7\u1EF9\u1EFB\u1EFD\u1EFF-\u1F07\u1F10-\u1F15\u1F20-\u1F27\u1F30-\u1F37\u1F40-\u1F45\u1F50-\u1F57\u1F60-\u1F67\u1F70-\u1F7D\u1F80-\u1F87\u1F90-\u1F97\u1FA0-\u1FA7\u1FB0-\u1FB4\u1FB6\u1FB7\u1FBE\u1FC2-\u1FC4\u1FC6\u1FC7\u1FD0-\u1FD3\u1FD6\u1FD7\u1FE0-\u1FE7\u1FF2-\u1FF4\u1FF6\u1FF7\u210A\u210E\u210F\u2113\u212F\u2134\u2139\u213C\u213D\u2146-\u2149\u214E\u2184\u2C30-\u2C5E\u2C61\u2C65\u2C66\u2C68\u2C6A\u2C6C\u2C71\u2C73\u2C74\u2C76-\u2C7B\u2C81\u2C83\u2C85\u2C87\u2C89\u2C8B\u2C8D\u2C8F\u2C91\u2C93\u2C95\u2C97\u2C99\u2C9B\u2C9D\u2C9F\u2CA1\u2CA3\u2CA5\u2CA7\u2CA9\u2CAB\u2CAD\u2CAF\u2CB1\u2CB3\u2CB5\u2CB7\u2CB9\u2CBB\u2CBD\u2CBF\u2CC1\u2CC3\u2CC5\u2CC7\u2CC9\u2CCB\u2CCD\u2CCF\u2CD1\u2CD3\u2CD5\u2CD7\u2CD9\u2CDB\u2CDD\u2CDF\u2CE1\u2CE3\u2CE4\u2CEC\u2CEE\u2CF3\u2D00-\u2D25\u2D27\u2D2D\uA641\uA643\uA645\uA647\uA649\uA64B\uA64D\uA64F\uA651\uA653\uA655\uA657\uA659\uA65B\uA65D\uA65F\uA661\uA663\uA665\uA667\uA669\uA66B\uA66D\uA681\uA683\uA685\uA687\uA689\uA68B\uA68D\uA68F\uA691\uA693\uA695\uA697\uA699\uA69B\uA723\uA725\uA727\uA729\uA72B\uA72D\uA72F-\uA731\uA733\uA735\uA737\uA739\uA73B\uA73D\uA73F\uA741\uA743\uA745\uA747\uA749\uA74B\uA74D\uA74F\uA751\uA753\uA755\uA757\uA759\uA75B\uA75D\uA75F\uA761\uA763\uA765\uA767\uA769\uA76B\uA76D\uA76F\uA771-\uA778\uA77A\uA77C\uA77F\uA781\uA783\uA785\uA787\uA78C\uA78E\uA791\uA793-\uA795\uA797\uA799\uA79B\uA79D\uA79F\uA7A1\uA7A3\uA7A5\uA7A7\uA7A9\uA7B5\uA7B7\uA7FA\uAB30-\uAB5A\uAB60-\uAB65\uAB70-\uABBF\uFB00-\uFB06\uFB13-\uFB17\uFF41-\uFF5A]|\uD801[\uDC28-\uDC4F\uDCD8-\uDCFB]|\uD803[\uDCC0-\uDCF2]|\uD806[\uDCC0-\uDCDF]|\uD835[\uDC1A-\uDC33\uDC4E-\uDC54\uDC56-\uDC67\uDC82-\uDC9B\uDCB6-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDCCF\uDCEA-\uDD03\uDD1E-\uDD37\uDD52-\uDD6B\uDD86-\uDD9F\uDDBA-\uDDD3\uDDEE-\uDE07\uDE22-\uDE3B\uDE56-\uDE6F\uDE8A-\uDEA5\uDEC2-\uDEDA\uDEDC-\uDEE1\uDEFC-\uDF14\uDF16-\uDF1B\uDF36-\uDF4E\uDF50-\uDF55\uDF70-\uDF88\uDF8A-\uDF8F\uDFAA-\uDFC2\uDFC4-\uDFC9\uDFCB]|\uD83A[\uDD22-\uDD43]/,
- Lt: /[\u01C5\u01C8\u01CB\u01F2\u1F88-\u1F8F\u1F98-\u1F9F\u1FA8-\u1FAF\u1FBC\u1FCC\u1FFC]/,
- Lm: /[\u02B0-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0374\u037A\u0559\u0640\u06E5\u06E6\u07F4\u07F5\u07FA\u081A\u0824\u0828\u0971\u0E46\u0EC6\u10FC\u17D7\u1843\u1AA7\u1C78-\u1C7D\u1D2C-\u1D6A\u1D78\u1D9B-\u1DBF\u2071\u207F\u2090-\u209C\u2C7C\u2C7D\u2D6F\u2E2F\u3005\u3031-\u3035\u303B\u309D\u309E\u30FC-\u30FE\uA015\uA4F8-\uA4FD\uA60C\uA67F\uA69C\uA69D\uA717-\uA71F\uA770\uA788\uA7F8\uA7F9\uA9CF\uA9E6\uAA70\uAADD\uAAF3\uAAF4\uAB5C-\uAB5F\uFF70\uFF9E\uFF9F]|\uD81A[\uDF40-\uDF43]|\uD81B[\uDF93-\uDF9F\uDFE0]/,
- Lo: /[\xAA\xBA\u01BB\u01C0-\u01C3\u0294\u05D0-\u05EA\u05F0-\u05F2\u0620-\u063F\u0641-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u0800-\u0815\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0972-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E45\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10D0-\u10FA\u10FD-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17DC\u1820-\u1842\u1844-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C77\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u2135-\u2138\u2D30-\u2D67\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3006\u303C\u3041-\u3096\u309F\u30A1-\u30FA\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA014\uA016-\uA48C\uA4D0-\uA4F7\uA500-\uA60B\uA610-\uA61F\uA62A\uA62B\uA66E\uA6A0-\uA6E5\uA78F\uA7F7\uA7FB-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9E0-\uA9E4\uA9E7-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA6F\uAA71-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB\uAADC\uAAE0-\uAAEA\uAAF2\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF66-\uFF6F\uFF71-\uFF9D\uFFA0-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC50-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,
-
- Nl: /[\u16EE-\u16F0\u2160-\u2182\u2185-\u2188\u3007\u3021-\u3029\u3038-\u303A\uA6E6-\uA6EF]|\uD800[\uDD40-\uDD74\uDF41\uDF4A\uDFD1-\uDFD5]|\uD809[\uDC00-\uDC6E]/,
- Nd: /[0-9\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE6-\u0BEF\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29\u1040-\u1049\u1090-\u1099\u17E0-\u17E9\u1810-\u1819\u1946-\u194F\u19D0-\u19D9\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\uA620-\uA629\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD801[\uDCA0-\uDCA9]|\uD804[\uDC66-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDEF0-\uDEF9]|[\uD805\uD807][\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF39]|\uD806[\uDCE0-\uDCE9]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59]|\uD835[\uDFCE-\uDFFF]|\uD83A[\uDD50-\uDD59]/,
-
- Mn: /[\u0300-\u036F\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D4-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09C1-\u09C4\u09CD\u09E2\u09E3\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0B01\u0B3C\u0B3F\u0B41-\u0B44\u0B4D\u0B56\u0B62\u0B63\u0B82\u0BC0\u0BCD\u0C00\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC6\u0CCC\u0CCD\u0CE2\u0CE3\u0D01\u0D41-\u0D44\u0D4D\u0D62\u0D63\u0DCA\u0DD2-\u0DD4\u0DD6\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ABD\u1B00-\u1B03\u1B34\u1B36-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DF5\u1DFB-\u1DFF\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302D\u3099\u309A\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA8C4\uA8C5\uA8E0-\uA8F1\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD804[\uDC01\uDC38-\uDC46\uDC7F-\uDC81\uDCB3-\uDCB6\uDCB9\uDCBA\uDD00-\uDD02\uDD27-\uDD2B\uDD2D-\uDD34\uDD73\uDD80\uDD81\uDDB6-\uDDBE\uDDCA-\uDDCC\uDE2F-\uDE31\uDE34\uDE36\uDE37\uDE3E\uDEDF\uDEE3-\uDEEA\uDF00\uDF01\uDF3C\uDF40\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC38-\uDC3F\uDC42-\uDC44\uDC46\uDCB3-\uDCB8\uDCBA\uDCBF\uDCC0\uDCC2\uDCC3\uDDB2-\uDDB5\uDDBC\uDDBD\uDDBF\uDDC0\uDDDC\uDDDD\uDE33-\uDE3A\uDE3D\uDE3F\uDE40\uDEAB\uDEAD\uDEB0-\uDEB5\uDEB7\uDF1D-\uDF1F\uDF22-\uDF25\uDF27-\uDF2B]|\uD807[\uDC30-\uDC36\uDC38-\uDC3D\uDC3F\uDC92-\uDCA7\uDCAA-\uDCB0\uDCB2\uDCB3\uDCB5\uDCB6]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF8F-\uDF92]|\uD82F[\uDC9D\uDC9E]|\uD834[\uDD67-\uDD69\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uDB40[\uDD00-\uDDEF]/,
- Mc: /[\u0903-\u0903]|[\u093E-\u0940]|[\u0949-\u094C]|[\u0982-\u0983]|[\u09BE-\u09C0]|[\u09C7-\u09C8]|[\u09CB-\u09CC]|[\u09D7-\u09D7]|[\u0A3E-\u0A40]|[\u0A83-\u0A83]|[\u0ABE-\u0AC0]|[\u0AC9-\u0AC9]|[\u0ACB-\u0ACC]|[\u0B02-\u0B03]|[\u0B3E-\u0B3E]|[\u0B40-\u0B40]|[\u0B47-\u0B48]|[\u0B4B-\u0B4C]|[\u0B57-\u0B57]|[\u0B83-\u0B83]|[\u0BBE-\u0BBF]|[\u0BC1-\u0BC2]|[\u0BC6-\u0BC8]|[\u0BCA-\u0BCC]|[\u0BD7-\u0BD7]|[\u0C01-\u0C03]|[\u0C41-\u0C44]|[\u0C82-\u0C83]|[\u0CBE-\u0CBE]|[\u0CC0-\u0CC4]|[\u0CC7-\u0CC8]|[\u0CCA-\u0CCB]|[\u0CD5-\u0CD6]|[\u0D02-\u0D03]|[\u0D3E-\u0D40]|[\u0D46-\u0D48]|[\u0D4A-\u0D4C]|[\u0D57-\u0D57]|[\u0F3E-\u0F3F]|[\u0F7F-\u0F7F]/,
-
- Pc: /[_\u203F\u2040\u2054\uFE33\uFE34\uFE4D-\uFE4F\uFF3F]/,
-
- Zs: /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/,
-
-
-
- L: /[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,
- Ltmo: /[\u01C5\u01C8\u01CB\u01F2\u1F88-\u1F8F\u1F98-\u1F9F\u1FA8-\u1FAF\u1FBC\u1FCC\u1FFC]|[\u02B0-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0374\u037A\u0559\u0640\u06E5\u06E6\u07F4\u07F5\u07FA\u081A\u0824\u0828\u0971\u0E46\u0EC6\u10FC\u17D7\u1843\u1AA7\u1C78-\u1C7D\u1D2C-\u1D6A\u1D78\u1D9B-\u1DBF\u2071\u207F\u2090-\u209C\u2C7C\u2C7D\u2D6F\u2E2F\u3005\u3031-\u3035\u303B\u309D\u309E\u30FC-\u30FE\uA015\uA4F8-\uA4FD\uA60C\uA67F\uA69C\uA69D\uA717-\uA71F\uA770\uA788\uA7F8\uA7F9\uA9CF\uA9E6\uAA70\uAADD\uAAF3\uAAF4\uAB5C-\uAB5F\uFF70\uFF9E\uFF9F]|\uD81A[\uDF40-\uDF43]|\uD81B[\uDF93-\uDF9F\uDFE0]|[\xAA\xBA\u01BB\u01C0-\u01C3\u0294\u05D0-\u05EA\u05F0-\u05F2\u0620-\u063F\u0641-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u0800-\u0815\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0972-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E45\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10D0-\u10FA\u10FD-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17DC\u1820-\u1842\u1844-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C77\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u2135-\u2138\u2D30-\u2D67\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3006\u303C\u3041-\u3096\u309F\u30A1-\u30FA\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA014\uA016-\uA48C\uA4D0-\uA4F7\uA500-\uA60B\uA610-\uA61F\uA62A\uA62B\uA66E\uA6A0-\uA6E5\uA78F\uA7F7\uA7FB-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9E0-\uA9E4\uA9E7-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA6F\uAA71-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB\uAADC\uAAE0-\uAAEA\uAAF2\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF66-\uFF6F\uFF71-\uFF9D\uFFA0-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC50-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/
- };
- },{}]},{},[46])(46)
- });
|