acorn.js 225 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  3. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  4. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.acorn = {}));
  5. })(this, (function (exports) { 'use strict';
  6. // This file was generated. Do not modify manually!
  7. var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 81, 2, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 9, 5351, 0, 7, 14, 13835, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 983, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
  8. // This file was generated. Do not modify manually!
  9. var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 68, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 4026, 582, 8634, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 757, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 3104, 541, 1507, 4938, 6, 4191];
  10. // This file was generated. Do not modify manually!
  11. var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0898-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0cf3\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ece\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
  12. // This file was generated. Do not modify manually!
  13. var nonASCIIidentifierStartChars = "\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\u0560-\u0588\u05d0-\u05ea\u05ef-\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\u0860-\u086a\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\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\u09fc\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\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\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\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\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\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\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\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\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\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ca\ua7d0\ua7d1\ua7d3\ua7d5-\ua7d9\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\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-\uab69\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";
  14. // These are a run-length and offset encoded representation of the
  15. // >0xffff code points that are a valid part of identifiers. The
  16. // offset starts at 0x10000, and each pair of numbers represents an
  17. // offset to the next range, and then a size of the range.
  18. // Reserved word lists for various dialects of the language
  19. var reservedWords = {
  20. 3: "abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",
  21. 5: "class enum extends super const export import",
  22. 6: "enum",
  23. strict: "implements interface let package private protected public static yield",
  24. strictBind: "eval arguments"
  25. };
  26. // And the keywords
  27. var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this";
  28. var keywords$1 = {
  29. 5: ecma5AndLessKeywords,
  30. "5module": ecma5AndLessKeywords + " export import",
  31. 6: ecma5AndLessKeywords + " const class extends export import super"
  32. };
  33. var keywordRelationalOperator = /^in(stanceof)?$/;
  34. // ## Character categories
  35. var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  36. var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  37. // This has a complexity linear to the value of the code. The
  38. // assumption is that looking up astral identifier characters is
  39. // rare.
  40. function isInAstralSet(code, set) {
  41. var pos = 0x10000;
  42. for (var i = 0; i < set.length; i += 2) {
  43. pos += set[i];
  44. if (pos > code) { return false }
  45. pos += set[i + 1];
  46. if (pos >= code) { return true }
  47. }
  48. return false
  49. }
  50. // Test whether a given character code starts an identifier.
  51. function isIdentifierStart(code, astral) {
  52. if (code < 65) { return code === 36 }
  53. if (code < 91) { return true }
  54. if (code < 97) { return code === 95 }
  55. if (code < 123) { return true }
  56. if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)) }
  57. if (astral === false) { return false }
  58. return isInAstralSet(code, astralIdentifierStartCodes)
  59. }
  60. // Test whether a given character is part of an identifier.
  61. function isIdentifierChar(code, astral) {
  62. if (code < 48) { return code === 36 }
  63. if (code < 58) { return true }
  64. if (code < 65) { return false }
  65. if (code < 91) { return true }
  66. if (code < 97) { return code === 95 }
  67. if (code < 123) { return true }
  68. if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)) }
  69. if (astral === false) { return false }
  70. return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes)
  71. }
  72. // ## Token types
  73. // The assignment of fine-grained, information-carrying type objects
  74. // allows the tokenizer to store the information it has about a
  75. // token in a way that is very cheap for the parser to look up.
  76. // All token type variables start with an underscore, to make them
  77. // easy to recognize.
  78. // The `beforeExpr` property is used to disambiguate between regular
  79. // expressions and divisions. It is set on all token types that can
  80. // be followed by an expression (thus, a slash after them would be a
  81. // regular expression).
  82. //
  83. // The `startsExpr` property is used to check if the token ends a
  84. // `yield` expression. It is set on all token types that either can
  85. // directly start an expression (like a quotation mark) or can
  86. // continue an expression (like the body of a string).
  87. //
  88. // `isLoop` marks a keyword as starting a loop, which is important
  89. // to know when parsing a label, in order to allow or disallow
  90. // continue jumps to that label.
  91. var TokenType = function TokenType(label, conf) {
  92. if ( conf === void 0 ) conf = {};
  93. this.label = label;
  94. this.keyword = conf.keyword;
  95. this.beforeExpr = !!conf.beforeExpr;
  96. this.startsExpr = !!conf.startsExpr;
  97. this.isLoop = !!conf.isLoop;
  98. this.isAssign = !!conf.isAssign;
  99. this.prefix = !!conf.prefix;
  100. this.postfix = !!conf.postfix;
  101. this.binop = conf.binop || null;
  102. this.updateContext = null;
  103. };
  104. function binop(name, prec) {
  105. return new TokenType(name, {beforeExpr: true, binop: prec})
  106. }
  107. var beforeExpr = {beforeExpr: true}, startsExpr = {startsExpr: true};
  108. // Map keyword names to token types.
  109. var keywords = {};
  110. // Succinct definitions of keyword token types
  111. function kw(name, options) {
  112. if ( options === void 0 ) options = {};
  113. options.keyword = name;
  114. return keywords[name] = new TokenType(name, options)
  115. }
  116. var types$1 = {
  117. num: new TokenType("num", startsExpr),
  118. regexp: new TokenType("regexp", startsExpr),
  119. string: new TokenType("string", startsExpr),
  120. name: new TokenType("name", startsExpr),
  121. privateId: new TokenType("privateId", startsExpr),
  122. eof: new TokenType("eof"),
  123. // Punctuation token types.
  124. bracketL: new TokenType("[", {beforeExpr: true, startsExpr: true}),
  125. bracketR: new TokenType("]"),
  126. braceL: new TokenType("{", {beforeExpr: true, startsExpr: true}),
  127. braceR: new TokenType("}"),
  128. parenL: new TokenType("(", {beforeExpr: true, startsExpr: true}),
  129. parenR: new TokenType(")"),
  130. comma: new TokenType(",", beforeExpr),
  131. semi: new TokenType(";", beforeExpr),
  132. colon: new TokenType(":", beforeExpr),
  133. dot: new TokenType("."),
  134. question: new TokenType("?", beforeExpr),
  135. questionDot: new TokenType("?."),
  136. arrow: new TokenType("=>", beforeExpr),
  137. template: new TokenType("template"),
  138. invalidTemplate: new TokenType("invalidTemplate"),
  139. ellipsis: new TokenType("...", beforeExpr),
  140. backQuote: new TokenType("`", startsExpr),
  141. dollarBraceL: new TokenType("${", {beforeExpr: true, startsExpr: true}),
  142. // Operators. These carry several kinds of properties to help the
  143. // parser use them properly (the presence of these properties is
  144. // what categorizes them as operators).
  145. //
  146. // `binop`, when present, specifies that this operator is a binary
  147. // operator, and will refer to its precedence.
  148. //
  149. // `prefix` and `postfix` mark the operator as a prefix or postfix
  150. // unary operator.
  151. //
  152. // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as
  153. // binary operators with a very low precedence, that should result
  154. // in AssignmentExpression nodes.
  155. eq: new TokenType("=", {beforeExpr: true, isAssign: true}),
  156. assign: new TokenType("_=", {beforeExpr: true, isAssign: true}),
  157. incDec: new TokenType("++/--", {prefix: true, postfix: true, startsExpr: true}),
  158. prefix: new TokenType("!/~", {beforeExpr: true, prefix: true, startsExpr: true}),
  159. logicalOR: binop("||", 1),
  160. logicalAND: binop("&&", 2),
  161. bitwiseOR: binop("|", 3),
  162. bitwiseXOR: binop("^", 4),
  163. bitwiseAND: binop("&", 5),
  164. equality: binop("==/!=/===/!==", 6),
  165. relational: binop("</>/<=/>=", 7),
  166. bitShift: binop("<</>>/>>>", 8),
  167. plusMin: new TokenType("+/-", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}),
  168. modulo: binop("%", 10),
  169. star: binop("*", 10),
  170. slash: binop("/", 10),
  171. starstar: new TokenType("**", {beforeExpr: true}),
  172. coalesce: binop("??", 1),
  173. // Keyword token types.
  174. _break: kw("break"),
  175. _case: kw("case", beforeExpr),
  176. _catch: kw("catch"),
  177. _continue: kw("continue"),
  178. _debugger: kw("debugger"),
  179. _default: kw("default", beforeExpr),
  180. _do: kw("do", {isLoop: true, beforeExpr: true}),
  181. _else: kw("else", beforeExpr),
  182. _finally: kw("finally"),
  183. _for: kw("for", {isLoop: true}),
  184. _function: kw("function", startsExpr),
  185. _if: kw("if"),
  186. _return: kw("return", beforeExpr),
  187. _switch: kw("switch"),
  188. _throw: kw("throw", beforeExpr),
  189. _try: kw("try"),
  190. _var: kw("var"),
  191. _const: kw("const"),
  192. _while: kw("while", {isLoop: true}),
  193. _with: kw("with"),
  194. _new: kw("new", {beforeExpr: true, startsExpr: true}),
  195. _this: kw("this", startsExpr),
  196. _super: kw("super", startsExpr),
  197. _class: kw("class", startsExpr),
  198. _extends: kw("extends", beforeExpr),
  199. _export: kw("export"),
  200. _import: kw("import", startsExpr),
  201. _null: kw("null", startsExpr),
  202. _true: kw("true", startsExpr),
  203. _false: kw("false", startsExpr),
  204. _in: kw("in", {beforeExpr: true, binop: 7}),
  205. _instanceof: kw("instanceof", {beforeExpr: true, binop: 7}),
  206. _typeof: kw("typeof", {beforeExpr: true, prefix: true, startsExpr: true}),
  207. _void: kw("void", {beforeExpr: true, prefix: true, startsExpr: true}),
  208. _delete: kw("delete", {beforeExpr: true, prefix: true, startsExpr: true})
  209. };
  210. // Matches a whole line break (where CRLF is considered a single
  211. // line break). Used to count lines.
  212. var lineBreak = /\r\n?|\n|\u2028|\u2029/;
  213. var lineBreakG = new RegExp(lineBreak.source, "g");
  214. function isNewLine(code) {
  215. return code === 10 || code === 13 || code === 0x2028 || code === 0x2029
  216. }
  217. function nextLineBreak(code, from, end) {
  218. if ( end === void 0 ) end = code.length;
  219. for (var i = from; i < end; i++) {
  220. var next = code.charCodeAt(i);
  221. if (isNewLine(next))
  222. { return i < end - 1 && next === 13 && code.charCodeAt(i + 1) === 10 ? i + 2 : i + 1 }
  223. }
  224. return -1
  225. }
  226. var nonASCIIwhitespace = /[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
  227. var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
  228. var ref = Object.prototype;
  229. var hasOwnProperty = ref.hasOwnProperty;
  230. var toString = ref.toString;
  231. var hasOwn = Object.hasOwn || (function (obj, propName) { return (
  232. hasOwnProperty.call(obj, propName)
  233. ); });
  234. var isArray = Array.isArray || (function (obj) { return (
  235. toString.call(obj) === "[object Array]"
  236. ); });
  237. function wordsRegexp(words) {
  238. return new RegExp("^(?:" + words.replace(/ /g, "|") + ")$")
  239. }
  240. function codePointToString(code) {
  241. // UTF-16 Decoding
  242. if (code <= 0xFFFF) { return String.fromCharCode(code) }
  243. code -= 0x10000;
  244. return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00)
  245. }
  246. var loneSurrogate = /(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/;
  247. // These are used when `options.locations` is on, for the
  248. // `startLoc` and `endLoc` properties.
  249. var Position = function Position(line, col) {
  250. this.line = line;
  251. this.column = col;
  252. };
  253. Position.prototype.offset = function offset (n) {
  254. return new Position(this.line, this.column + n)
  255. };
  256. var SourceLocation = function SourceLocation(p, start, end) {
  257. this.start = start;
  258. this.end = end;
  259. if (p.sourceFile !== null) { this.source = p.sourceFile; }
  260. };
  261. // The `getLineInfo` function is mostly useful when the
  262. // `locations` option is off (for performance reasons) and you
  263. // want to find the line/column position for a given character
  264. // offset. `input` should be the code string that the offset refers
  265. // into.
  266. function getLineInfo(input, offset) {
  267. for (var line = 1, cur = 0;;) {
  268. var nextBreak = nextLineBreak(input, cur, offset);
  269. if (nextBreak < 0) { return new Position(line, offset - cur) }
  270. ++line;
  271. cur = nextBreak;
  272. }
  273. }
  274. // A second argument must be given to configure the parser process.
  275. // These options are recognized (only `ecmaVersion` is required):
  276. var defaultOptions = {
  277. // `ecmaVersion` indicates the ECMAScript version to parse. Must be
  278. // either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10
  279. // (2019), 11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"`
  280. // (the latest version the library supports). This influences
  281. // support for strict mode, the set of reserved words, and support
  282. // for new syntax features.
  283. ecmaVersion: null,
  284. // `sourceType` indicates the mode the code should be parsed in.
  285. // Can be either `"script"` or `"module"`. This influences global
  286. // strict mode and parsing of `import` and `export` declarations.
  287. sourceType: "script",
  288. // `onInsertedSemicolon` can be a callback that will be called
  289. // when a semicolon is automatically inserted. It will be passed
  290. // the position of the comma as an offset, and if `locations` is
  291. // enabled, it is given the location as a `{line, column}` object
  292. // as second argument.
  293. onInsertedSemicolon: null,
  294. // `onTrailingComma` is similar to `onInsertedSemicolon`, but for
  295. // trailing commas.
  296. onTrailingComma: null,
  297. // By default, reserved words are only enforced if ecmaVersion >= 5.
  298. // Set `allowReserved` to a boolean value to explicitly turn this on
  299. // an off. When this option has the value "never", reserved words
  300. // and keywords can also not be used as property names.
  301. allowReserved: null,
  302. // When enabled, a return at the top level is not considered an
  303. // error.
  304. allowReturnOutsideFunction: false,
  305. // When enabled, import/export statements are not constrained to
  306. // appearing at the top of the program, and an import.meta expression
  307. // in a script isn't considered an error.
  308. allowImportExportEverywhere: false,
  309. // By default, await identifiers are allowed to appear at the top-level scope only if ecmaVersion >= 2022.
  310. // When enabled, await identifiers are allowed to appear at the top-level scope,
  311. // but they are still not allowed in non-async functions.
  312. allowAwaitOutsideFunction: null,
  313. // When enabled, super identifiers are not constrained to
  314. // appearing in methods and do not raise an error when they appear elsewhere.
  315. allowSuperOutsideMethod: null,
  316. // When enabled, hashbang directive in the beginning of file is
  317. // allowed and treated as a line comment. Enabled by default when
  318. // `ecmaVersion` >= 2023.
  319. allowHashBang: false,
  320. // By default, the parser will verify that private properties are
  321. // only used in places where they are valid and have been declared.
  322. // Set this to false to turn such checks off.
  323. checkPrivateFields: true,
  324. // When `locations` is on, `loc` properties holding objects with
  325. // `start` and `end` properties in `{line, column}` form (with
  326. // line being 1-based and column 0-based) will be attached to the
  327. // nodes.
  328. locations: false,
  329. // A function can be passed as `onToken` option, which will
  330. // cause Acorn to call that function with object in the same
  331. // format as tokens returned from `tokenizer().getToken()`. Note
  332. // that you are not allowed to call the parser from the
  333. // callback—that will corrupt its internal state.
  334. onToken: null,
  335. // A function can be passed as `onComment` option, which will
  336. // cause Acorn to call that function with `(block, text, start,
  337. // end)` parameters whenever a comment is skipped. `block` is a
  338. // boolean indicating whether this is a block (`/* */`) comment,
  339. // `text` is the content of the comment, and `start` and `end` are
  340. // character offsets that denote the start and end of the comment.
  341. // When the `locations` option is on, two more parameters are
  342. // passed, the full `{line, column}` locations of the start and
  343. // end of the comments. Note that you are not allowed to call the
  344. // parser from the callback—that will corrupt its internal state.
  345. onComment: null,
  346. // Nodes have their start and end characters offsets recorded in
  347. // `start` and `end` properties (directly on the node, rather than
  348. // the `loc` object, which holds line/column data. To also add a
  349. // [semi-standardized][range] `range` property holding a `[start,
  350. // end]` array with the same numbers, set the `ranges` option to
  351. // `true`.
  352. //
  353. // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
  354. ranges: false,
  355. // It is possible to parse multiple files into a single AST by
  356. // passing the tree produced by parsing the first file as
  357. // `program` option in subsequent parses. This will add the
  358. // toplevel forms of the parsed file to the `Program` (top) node
  359. // of an existing parse tree.
  360. program: null,
  361. // When `locations` is on, you can pass this to record the source
  362. // file in every node's `loc` object.
  363. sourceFile: null,
  364. // This value, if given, is stored in every node, whether
  365. // `locations` is on or off.
  366. directSourceFile: null,
  367. // When enabled, parenthesized expressions are represented by
  368. // (non-standard) ParenthesizedExpression nodes
  369. preserveParens: false
  370. };
  371. // Interpret and default an options object
  372. var warnedAboutEcmaVersion = false;
  373. function getOptions(opts) {
  374. var options = {};
  375. for (var opt in defaultOptions)
  376. { options[opt] = opts && hasOwn(opts, opt) ? opts[opt] : defaultOptions[opt]; }
  377. if (options.ecmaVersion === "latest") {
  378. options.ecmaVersion = 1e8;
  379. } else if (options.ecmaVersion == null) {
  380. if (!warnedAboutEcmaVersion && typeof console === "object" && console.warn) {
  381. warnedAboutEcmaVersion = true;
  382. console.warn("Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future.");
  383. }
  384. options.ecmaVersion = 11;
  385. } else if (options.ecmaVersion >= 2015) {
  386. options.ecmaVersion -= 2009;
  387. }
  388. if (options.allowReserved == null)
  389. { options.allowReserved = options.ecmaVersion < 5; }
  390. if (!opts || opts.allowHashBang == null)
  391. { options.allowHashBang = options.ecmaVersion >= 14; }
  392. if (isArray(options.onToken)) {
  393. var tokens = options.onToken;
  394. options.onToken = function (token) { return tokens.push(token); };
  395. }
  396. if (isArray(options.onComment))
  397. { options.onComment = pushComment(options, options.onComment); }
  398. return options
  399. }
  400. function pushComment(options, array) {
  401. return function(block, text, start, end, startLoc, endLoc) {
  402. var comment = {
  403. type: block ? "Block" : "Line",
  404. value: text,
  405. start: start,
  406. end: end
  407. };
  408. if (options.locations)
  409. { comment.loc = new SourceLocation(this, startLoc, endLoc); }
  410. if (options.ranges)
  411. { comment.range = [start, end]; }
  412. array.push(comment);
  413. }
  414. }
  415. // Each scope gets a bitset that may contain these flags
  416. var
  417. SCOPE_TOP = 1,
  418. SCOPE_FUNCTION = 2,
  419. SCOPE_ASYNC = 4,
  420. SCOPE_GENERATOR = 8,
  421. SCOPE_ARROW = 16,
  422. SCOPE_SIMPLE_CATCH = 32,
  423. SCOPE_SUPER = 64,
  424. SCOPE_DIRECT_SUPER = 128,
  425. SCOPE_CLASS_STATIC_BLOCK = 256,
  426. SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK;
  427. function functionFlags(async, generator) {
  428. return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0)
  429. }
  430. // Used in checkLVal* and declareName to determine the type of a binding
  431. var
  432. BIND_NONE = 0, // Not a binding
  433. BIND_VAR = 1, // Var-style binding
  434. BIND_LEXICAL = 2, // Let- or const-style binding
  435. BIND_FUNCTION = 3, // Function declaration
  436. BIND_SIMPLE_CATCH = 4, // Simple (identifier pattern) catch binding
  437. BIND_OUTSIDE = 5; // Special case for function names as bound inside the function
  438. var Parser = function Parser(options, input, startPos) {
  439. this.options = options = getOptions(options);
  440. this.sourceFile = options.sourceFile;
  441. this.keywords = wordsRegexp(keywords$1[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]);
  442. var reserved = "";
  443. if (options.allowReserved !== true) {
  444. reserved = reservedWords[options.ecmaVersion >= 6 ? 6 : options.ecmaVersion === 5 ? 5 : 3];
  445. if (options.sourceType === "module") { reserved += " await"; }
  446. }
  447. this.reservedWords = wordsRegexp(reserved);
  448. var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict;
  449. this.reservedWordsStrict = wordsRegexp(reservedStrict);
  450. this.reservedWordsStrictBind = wordsRegexp(reservedStrict + " " + reservedWords.strictBind);
  451. this.input = String(input);
  452. // Used to signal to callers of `readWord1` whether the word
  453. // contained any escape sequences. This is needed because words with
  454. // escape sequences must not be interpreted as keywords.
  455. this.containsEsc = false;
  456. // Set up token state
  457. // The current position of the tokenizer in the input.
  458. if (startPos) {
  459. this.pos = startPos;
  460. this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
  461. this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
  462. } else {
  463. this.pos = this.lineStart = 0;
  464. this.curLine = 1;
  465. }
  466. // Properties of the current token:
  467. // Its type
  468. this.type = types$1.eof;
  469. // For tokens that include more information than their type, the value
  470. this.value = null;
  471. // Its start and end offset
  472. this.start = this.end = this.pos;
  473. // And, if locations are used, the {line, column} object
  474. // corresponding to those offsets
  475. this.startLoc = this.endLoc = this.curPosition();
  476. // Position information for the previous token
  477. this.lastTokEndLoc = this.lastTokStartLoc = null;
  478. this.lastTokStart = this.lastTokEnd = this.pos;
  479. // The context stack is used to superficially track syntactic
  480. // context to predict whether a regular expression is allowed in a
  481. // given position.
  482. this.context = this.initialContext();
  483. this.exprAllowed = true;
  484. // Figure out if it's a module code.
  485. this.inModule = options.sourceType === "module";
  486. this.strict = this.inModule || this.strictDirective(this.pos);
  487. // Used to signify the start of a potential arrow function
  488. this.potentialArrowAt = -1;
  489. this.potentialArrowInForAwait = false;
  490. // Positions to delayed-check that yield/await does not exist in default parameters.
  491. this.yieldPos = this.awaitPos = this.awaitIdentPos = 0;
  492. // Labels in scope.
  493. this.labels = [];
  494. // Thus-far undefined exports.
  495. this.undefinedExports = Object.create(null);
  496. // If enabled, skip leading hashbang line.
  497. if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!")
  498. { this.skipLineComment(2); }
  499. // Scope tracking for duplicate variable names (see scope.js)
  500. this.scopeStack = [];
  501. this.enterScope(SCOPE_TOP);
  502. // For RegExp validation
  503. this.regexpState = null;
  504. // The stack of private names.
  505. // Each element has two properties: 'declared' and 'used'.
  506. // When it exited from the outermost class definition, all used private names must be declared.
  507. this.privateNameStack = [];
  508. };
  509. var prototypeAccessors = { inFunction: { configurable: true },inGenerator: { configurable: true },inAsync: { configurable: true },canAwait: { configurable: true },allowSuper: { configurable: true },allowDirectSuper: { configurable: true },treatFunctionsAsVar: { configurable: true },allowNewDotTarget: { configurable: true },inClassStaticBlock: { configurable: true } };
  510. Parser.prototype.parse = function parse () {
  511. var node = this.options.program || this.startNode();
  512. this.nextToken();
  513. return this.parseTopLevel(node)
  514. };
  515. prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 };
  516. prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 && !this.currentVarScope().inClassFieldInit };
  517. prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 && !this.currentVarScope().inClassFieldInit };
  518. prototypeAccessors.canAwait.get = function () {
  519. for (var i = this.scopeStack.length - 1; i >= 0; i--) {
  520. var scope = this.scopeStack[i];
  521. if (scope.inClassFieldInit || scope.flags & SCOPE_CLASS_STATIC_BLOCK) { return false }
  522. if (scope.flags & SCOPE_FUNCTION) { return (scope.flags & SCOPE_ASYNC) > 0 }
  523. }
  524. return (this.inModule && this.options.ecmaVersion >= 13) || this.options.allowAwaitOutsideFunction
  525. };
  526. prototypeAccessors.allowSuper.get = function () {
  527. var ref = this.currentThisScope();
  528. var flags = ref.flags;
  529. var inClassFieldInit = ref.inClassFieldInit;
  530. return (flags & SCOPE_SUPER) > 0 || inClassFieldInit || this.options.allowSuperOutsideMethod
  531. };
  532. prototypeAccessors.allowDirectSuper.get = function () { return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0 };
  533. prototypeAccessors.treatFunctionsAsVar.get = function () { return this.treatFunctionsAsVarInScope(this.currentScope()) };
  534. prototypeAccessors.allowNewDotTarget.get = function () {
  535. var ref = this.currentThisScope();
  536. var flags = ref.flags;
  537. var inClassFieldInit = ref.inClassFieldInit;
  538. return (flags & (SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK)) > 0 || inClassFieldInit
  539. };
  540. prototypeAccessors.inClassStaticBlock.get = function () {
  541. return (this.currentVarScope().flags & SCOPE_CLASS_STATIC_BLOCK) > 0
  542. };
  543. Parser.extend = function extend () {
  544. var plugins = [], len = arguments.length;
  545. while ( len-- ) plugins[ len ] = arguments[ len ];
  546. var cls = this;
  547. for (var i = 0; i < plugins.length; i++) { cls = plugins[i](cls); }
  548. return cls
  549. };
  550. Parser.parse = function parse (input, options) {
  551. return new this(options, input).parse()
  552. };
  553. Parser.parseExpressionAt = function parseExpressionAt (input, pos, options) {
  554. var parser = new this(options, input, pos);
  555. parser.nextToken();
  556. return parser.parseExpression()
  557. };
  558. Parser.tokenizer = function tokenizer (input, options) {
  559. return new this(options, input)
  560. };
  561. Object.defineProperties( Parser.prototype, prototypeAccessors );
  562. var pp$9 = Parser.prototype;
  563. // ## Parser utilities
  564. var literal = /^(?:'((?:\\.|[^'\\])*?)'|"((?:\\.|[^"\\])*?)")/;
  565. pp$9.strictDirective = function(start) {
  566. if (this.options.ecmaVersion < 5) { return false }
  567. for (;;) {
  568. // Try to find string literal.
  569. skipWhiteSpace.lastIndex = start;
  570. start += skipWhiteSpace.exec(this.input)[0].length;
  571. var match = literal.exec(this.input.slice(start));
  572. if (!match) { return false }
  573. if ((match[1] || match[2]) === "use strict") {
  574. skipWhiteSpace.lastIndex = start + match[0].length;
  575. var spaceAfter = skipWhiteSpace.exec(this.input), end = spaceAfter.index + spaceAfter[0].length;
  576. var next = this.input.charAt(end);
  577. return next === ";" || next === "}" ||
  578. (lineBreak.test(spaceAfter[0]) &&
  579. !(/[(`.[+\-/*%<>=,?^&]/.test(next) || next === "!" && this.input.charAt(end + 1) === "="))
  580. }
  581. start += match[0].length;
  582. // Skip semicolon, if any.
  583. skipWhiteSpace.lastIndex = start;
  584. start += skipWhiteSpace.exec(this.input)[0].length;
  585. if (this.input[start] === ";")
  586. { start++; }
  587. }
  588. };
  589. // Predicate that tests whether the next token is of the given
  590. // type, and if yes, consumes it as a side effect.
  591. pp$9.eat = function(type) {
  592. if (this.type === type) {
  593. this.next();
  594. return true
  595. } else {
  596. return false
  597. }
  598. };
  599. // Tests whether parsed token is a contextual keyword.
  600. pp$9.isContextual = function(name) {
  601. return this.type === types$1.name && this.value === name && !this.containsEsc
  602. };
  603. // Consumes contextual keyword if possible.
  604. pp$9.eatContextual = function(name) {
  605. if (!this.isContextual(name)) { return false }
  606. this.next();
  607. return true
  608. };
  609. // Asserts that following token is given contextual keyword.
  610. pp$9.expectContextual = function(name) {
  611. if (!this.eatContextual(name)) { this.unexpected(); }
  612. };
  613. // Test whether a semicolon can be inserted at the current position.
  614. pp$9.canInsertSemicolon = function() {
  615. return this.type === types$1.eof ||
  616. this.type === types$1.braceR ||
  617. lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
  618. };
  619. pp$9.insertSemicolon = function() {
  620. if (this.canInsertSemicolon()) {
  621. if (this.options.onInsertedSemicolon)
  622. { this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc); }
  623. return true
  624. }
  625. };
  626. // Consume a semicolon, or, failing that, see if we are allowed to
  627. // pretend that there is a semicolon at this position.
  628. pp$9.semicolon = function() {
  629. if (!this.eat(types$1.semi) && !this.insertSemicolon()) { this.unexpected(); }
  630. };
  631. pp$9.afterTrailingComma = function(tokType, notNext) {
  632. if (this.type === tokType) {
  633. if (this.options.onTrailingComma)
  634. { this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc); }
  635. if (!notNext)
  636. { this.next(); }
  637. return true
  638. }
  639. };
  640. // Expect a token of a given type. If found, consume it, otherwise,
  641. // raise an unexpected token error.
  642. pp$9.expect = function(type) {
  643. this.eat(type) || this.unexpected();
  644. };
  645. // Raise an unexpected token error.
  646. pp$9.unexpected = function(pos) {
  647. this.raise(pos != null ? pos : this.start, "Unexpected token");
  648. };
  649. var DestructuringErrors = function DestructuringErrors() {
  650. this.shorthandAssign =
  651. this.trailingComma =
  652. this.parenthesizedAssign =
  653. this.parenthesizedBind =
  654. this.doubleProto =
  655. -1;
  656. };
  657. pp$9.checkPatternErrors = function(refDestructuringErrors, isAssign) {
  658. if (!refDestructuringErrors) { return }
  659. if (refDestructuringErrors.trailingComma > -1)
  660. { this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); }
  661. var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
  662. if (parens > -1) { this.raiseRecoverable(parens, isAssign ? "Assigning to rvalue" : "Parenthesized pattern"); }
  663. };
  664. pp$9.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
  665. if (!refDestructuringErrors) { return false }
  666. var shorthandAssign = refDestructuringErrors.shorthandAssign;
  667. var doubleProto = refDestructuringErrors.doubleProto;
  668. if (!andThrow) { return shorthandAssign >= 0 || doubleProto >= 0 }
  669. if (shorthandAssign >= 0)
  670. { this.raise(shorthandAssign, "Shorthand property assignments are valid only in destructuring patterns"); }
  671. if (doubleProto >= 0)
  672. { this.raiseRecoverable(doubleProto, "Redefinition of __proto__ property"); }
  673. };
  674. pp$9.checkYieldAwaitInDefaultParams = function() {
  675. if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos))
  676. { this.raise(this.yieldPos, "Yield expression cannot be a default value"); }
  677. if (this.awaitPos)
  678. { this.raise(this.awaitPos, "Await expression cannot be a default value"); }
  679. };
  680. pp$9.isSimpleAssignTarget = function(expr) {
  681. if (expr.type === "ParenthesizedExpression")
  682. { return this.isSimpleAssignTarget(expr.expression) }
  683. return expr.type === "Identifier" || expr.type === "MemberExpression"
  684. };
  685. var pp$8 = Parser.prototype;
  686. // ### Statement parsing
  687. // Parse a program. Initializes the parser, reads any number of
  688. // statements, and wraps them in a Program node. Optionally takes a
  689. // `program` argument. If present, the statements will be appended
  690. // to its body instead of creating a new node.
  691. pp$8.parseTopLevel = function(node) {
  692. var exports = Object.create(null);
  693. if (!node.body) { node.body = []; }
  694. while (this.type !== types$1.eof) {
  695. var stmt = this.parseStatement(null, true, exports);
  696. node.body.push(stmt);
  697. }
  698. if (this.inModule)
  699. { for (var i = 0, list = Object.keys(this.undefinedExports); i < list.length; i += 1)
  700. {
  701. var name = list[i];
  702. this.raiseRecoverable(this.undefinedExports[name].start, ("Export '" + name + "' is not defined"));
  703. } }
  704. this.adaptDirectivePrologue(node.body);
  705. this.next();
  706. node.sourceType = this.options.sourceType;
  707. return this.finishNode(node, "Program")
  708. };
  709. var loopLabel = {kind: "loop"}, switchLabel = {kind: "switch"};
  710. pp$8.isLet = function(context) {
  711. if (this.options.ecmaVersion < 6 || !this.isContextual("let")) { return false }
  712. skipWhiteSpace.lastIndex = this.pos;
  713. var skip = skipWhiteSpace.exec(this.input);
  714. var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
  715. // For ambiguous cases, determine if a LexicalDeclaration (or only a
  716. // Statement) is allowed here. If context is not empty then only a Statement
  717. // is allowed. However, `let [` is an explicit negative lookahead for
  718. // ExpressionStatement, so special-case it first.
  719. if (nextCh === 91 || nextCh === 92) { return true } // '[', '/'
  720. if (context) { return false }
  721. if (nextCh === 123 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true } // '{', astral
  722. if (isIdentifierStart(nextCh, true)) {
  723. var pos = next + 1;
  724. while (isIdentifierChar(nextCh = this.input.charCodeAt(pos), true)) { ++pos; }
  725. if (nextCh === 92 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true }
  726. var ident = this.input.slice(next, pos);
  727. if (!keywordRelationalOperator.test(ident)) { return true }
  728. }
  729. return false
  730. };
  731. // check 'async [no LineTerminator here] function'
  732. // - 'async /*foo*/ function' is OK.
  733. // - 'async /*\n*/ function' is invalid.
  734. pp$8.isAsyncFunction = function() {
  735. if (this.options.ecmaVersion < 8 || !this.isContextual("async"))
  736. { return false }
  737. skipWhiteSpace.lastIndex = this.pos;
  738. var skip = skipWhiteSpace.exec(this.input);
  739. var next = this.pos + skip[0].length, after;
  740. return !lineBreak.test(this.input.slice(this.pos, next)) &&
  741. this.input.slice(next, next + 8) === "function" &&
  742. (next + 8 === this.input.length ||
  743. !(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 0xd7ff && after < 0xdc00))
  744. };
  745. // Parse a single statement.
  746. //
  747. // If expecting a statement and finding a slash operator, parse a
  748. // regular expression literal. This is to handle cases like
  749. // `if (foo) /blah/.exec(foo)`, where looking at the previous token
  750. // does not help.
  751. pp$8.parseStatement = function(context, topLevel, exports) {
  752. var starttype = this.type, node = this.startNode(), kind;
  753. if (this.isLet(context)) {
  754. starttype = types$1._var;
  755. kind = "let";
  756. }
  757. // Most types of statements are recognized by the keyword they
  758. // start with. Many are trivial to parse, some require a bit of
  759. // complexity.
  760. switch (starttype) {
  761. case types$1._break: case types$1._continue: return this.parseBreakContinueStatement(node, starttype.keyword)
  762. case types$1._debugger: return this.parseDebuggerStatement(node)
  763. case types$1._do: return this.parseDoStatement(node)
  764. case types$1._for: return this.parseForStatement(node)
  765. case types$1._function:
  766. // Function as sole body of either an if statement or a labeled statement
  767. // works, but not when it is part of a labeled statement that is the sole
  768. // body of an if statement.
  769. if ((context && (this.strict || context !== "if" && context !== "label")) && this.options.ecmaVersion >= 6) { this.unexpected(); }
  770. return this.parseFunctionStatement(node, false, !context)
  771. case types$1._class:
  772. if (context) { this.unexpected(); }
  773. return this.parseClass(node, true)
  774. case types$1._if: return this.parseIfStatement(node)
  775. case types$1._return: return this.parseReturnStatement(node)
  776. case types$1._switch: return this.parseSwitchStatement(node)
  777. case types$1._throw: return this.parseThrowStatement(node)
  778. case types$1._try: return this.parseTryStatement(node)
  779. case types$1._const: case types$1._var:
  780. kind = kind || this.value;
  781. if (context && kind !== "var") { this.unexpected(); }
  782. return this.parseVarStatement(node, kind)
  783. case types$1._while: return this.parseWhileStatement(node)
  784. case types$1._with: return this.parseWithStatement(node)
  785. case types$1.braceL: return this.parseBlock(true, node)
  786. case types$1.semi: return this.parseEmptyStatement(node)
  787. case types$1._export:
  788. case types$1._import:
  789. if (this.options.ecmaVersion > 10 && starttype === types$1._import) {
  790. skipWhiteSpace.lastIndex = this.pos;
  791. var skip = skipWhiteSpace.exec(this.input);
  792. var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
  793. if (nextCh === 40 || nextCh === 46) // '(' or '.'
  794. { return this.parseExpressionStatement(node, this.parseExpression()) }
  795. }
  796. if (!this.options.allowImportExportEverywhere) {
  797. if (!topLevel)
  798. { this.raise(this.start, "'import' and 'export' may only appear at the top level"); }
  799. if (!this.inModule)
  800. { this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'"); }
  801. }
  802. return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports)
  803. // If the statement does not start with a statement keyword or a
  804. // brace, it's an ExpressionStatement or LabeledStatement. We
  805. // simply start parsing an expression, and afterwards, if the
  806. // next token is a colon and the expression was a simple
  807. // Identifier node, we switch to interpreting it as a label.
  808. default:
  809. if (this.isAsyncFunction()) {
  810. if (context) { this.unexpected(); }
  811. this.next();
  812. return this.parseFunctionStatement(node, true, !context)
  813. }
  814. var maybeName = this.value, expr = this.parseExpression();
  815. if (starttype === types$1.name && expr.type === "Identifier" && this.eat(types$1.colon))
  816. { return this.parseLabeledStatement(node, maybeName, expr, context) }
  817. else { return this.parseExpressionStatement(node, expr) }
  818. }
  819. };
  820. pp$8.parseBreakContinueStatement = function(node, keyword) {
  821. var isBreak = keyword === "break";
  822. this.next();
  823. if (this.eat(types$1.semi) || this.insertSemicolon()) { node.label = null; }
  824. else if (this.type !== types$1.name) { this.unexpected(); }
  825. else {
  826. node.label = this.parseIdent();
  827. this.semicolon();
  828. }
  829. // Verify that there is an actual destination to break or
  830. // continue to.
  831. var i = 0;
  832. for (; i < this.labels.length; ++i) {
  833. var lab = this.labels[i];
  834. if (node.label == null || lab.name === node.label.name) {
  835. if (lab.kind != null && (isBreak || lab.kind === "loop")) { break }
  836. if (node.label && isBreak) { break }
  837. }
  838. }
  839. if (i === this.labels.length) { this.raise(node.start, "Unsyntactic " + keyword); }
  840. return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement")
  841. };
  842. pp$8.parseDebuggerStatement = function(node) {
  843. this.next();
  844. this.semicolon();
  845. return this.finishNode(node, "DebuggerStatement")
  846. };
  847. pp$8.parseDoStatement = function(node) {
  848. this.next();
  849. this.labels.push(loopLabel);
  850. node.body = this.parseStatement("do");
  851. this.labels.pop();
  852. this.expect(types$1._while);
  853. node.test = this.parseParenExpression();
  854. if (this.options.ecmaVersion >= 6)
  855. { this.eat(types$1.semi); }
  856. else
  857. { this.semicolon(); }
  858. return this.finishNode(node, "DoWhileStatement")
  859. };
  860. // Disambiguating between a `for` and a `for`/`in` or `for`/`of`
  861. // loop is non-trivial. Basically, we have to parse the init `var`
  862. // statement or expression, disallowing the `in` operator (see
  863. // the second parameter to `parseExpression`), and then check
  864. // whether the next token is `in` or `of`. When there is no init
  865. // part (semicolon immediately after the opening parenthesis), it
  866. // is a regular `for` loop.
  867. pp$8.parseForStatement = function(node) {
  868. this.next();
  869. var awaitAt = (this.options.ecmaVersion >= 9 && this.canAwait && this.eatContextual("await")) ? this.lastTokStart : -1;
  870. this.labels.push(loopLabel);
  871. this.enterScope(0);
  872. this.expect(types$1.parenL);
  873. if (this.type === types$1.semi) {
  874. if (awaitAt > -1) { this.unexpected(awaitAt); }
  875. return this.parseFor(node, null)
  876. }
  877. var isLet = this.isLet();
  878. if (this.type === types$1._var || this.type === types$1._const || isLet) {
  879. var init$1 = this.startNode(), kind = isLet ? "let" : this.value;
  880. this.next();
  881. this.parseVar(init$1, true, kind);
  882. this.finishNode(init$1, "VariableDeclaration");
  883. if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1) {
  884. if (this.options.ecmaVersion >= 9) {
  885. if (this.type === types$1._in) {
  886. if (awaitAt > -1) { this.unexpected(awaitAt); }
  887. } else { node.await = awaitAt > -1; }
  888. }
  889. return this.parseForIn(node, init$1)
  890. }
  891. if (awaitAt > -1) { this.unexpected(awaitAt); }
  892. return this.parseFor(node, init$1)
  893. }
  894. var startsWithLet = this.isContextual("let"), isForOf = false;
  895. var refDestructuringErrors = new DestructuringErrors;
  896. var init = this.parseExpression(awaitAt > -1 ? "await" : true, refDestructuringErrors);
  897. if (this.type === types$1._in || (isForOf = this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
  898. if (this.options.ecmaVersion >= 9) {
  899. if (this.type === types$1._in) {
  900. if (awaitAt > -1) { this.unexpected(awaitAt); }
  901. } else { node.await = awaitAt > -1; }
  902. }
  903. if (startsWithLet && isForOf) { this.raise(init.start, "The left-hand side of a for-of loop may not start with 'let'."); }
  904. this.toAssignable(init, false, refDestructuringErrors);
  905. this.checkLValPattern(init);
  906. return this.parseForIn(node, init)
  907. } else {
  908. this.checkExpressionErrors(refDestructuringErrors, true);
  909. }
  910. if (awaitAt > -1) { this.unexpected(awaitAt); }
  911. return this.parseFor(node, init)
  912. };
  913. pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) {
  914. this.next();
  915. return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)
  916. };
  917. pp$8.parseIfStatement = function(node) {
  918. this.next();
  919. node.test = this.parseParenExpression();
  920. // allow function declarations in branches, but only in non-strict mode
  921. node.consequent = this.parseStatement("if");
  922. node.alternate = this.eat(types$1._else) ? this.parseStatement("if") : null;
  923. return this.finishNode(node, "IfStatement")
  924. };
  925. pp$8.parseReturnStatement = function(node) {
  926. if (!this.inFunction && !this.options.allowReturnOutsideFunction)
  927. { this.raise(this.start, "'return' outside of function"); }
  928. this.next();
  929. // In `return` (and `break`/`continue`), the keywords with
  930. // optional arguments, we eagerly look for a semicolon or the
  931. // possibility to insert one.
  932. if (this.eat(types$1.semi) || this.insertSemicolon()) { node.argument = null; }
  933. else { node.argument = this.parseExpression(); this.semicolon(); }
  934. return this.finishNode(node, "ReturnStatement")
  935. };
  936. pp$8.parseSwitchStatement = function(node) {
  937. this.next();
  938. node.discriminant = this.parseParenExpression();
  939. node.cases = [];
  940. this.expect(types$1.braceL);
  941. this.labels.push(switchLabel);
  942. this.enterScope(0);
  943. // Statements under must be grouped (by label) in SwitchCase
  944. // nodes. `cur` is used to keep the node that we are currently
  945. // adding statements to.
  946. var cur;
  947. for (var sawDefault = false; this.type !== types$1.braceR;) {
  948. if (this.type === types$1._case || this.type === types$1._default) {
  949. var isCase = this.type === types$1._case;
  950. if (cur) { this.finishNode(cur, "SwitchCase"); }
  951. node.cases.push(cur = this.startNode());
  952. cur.consequent = [];
  953. this.next();
  954. if (isCase) {
  955. cur.test = this.parseExpression();
  956. } else {
  957. if (sawDefault) { this.raiseRecoverable(this.lastTokStart, "Multiple default clauses"); }
  958. sawDefault = true;
  959. cur.test = null;
  960. }
  961. this.expect(types$1.colon);
  962. } else {
  963. if (!cur) { this.unexpected(); }
  964. cur.consequent.push(this.parseStatement(null));
  965. }
  966. }
  967. this.exitScope();
  968. if (cur) { this.finishNode(cur, "SwitchCase"); }
  969. this.next(); // Closing brace
  970. this.labels.pop();
  971. return this.finishNode(node, "SwitchStatement")
  972. };
  973. pp$8.parseThrowStatement = function(node) {
  974. this.next();
  975. if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start)))
  976. { this.raise(this.lastTokEnd, "Illegal newline after throw"); }
  977. node.argument = this.parseExpression();
  978. this.semicolon();
  979. return this.finishNode(node, "ThrowStatement")
  980. };
  981. // Reused empty array added for node fields that are always empty.
  982. var empty$1 = [];
  983. pp$8.parseCatchClauseParam = function() {
  984. var param = this.parseBindingAtom();
  985. var simple = param.type === "Identifier";
  986. this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
  987. this.checkLValPattern(param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
  988. this.expect(types$1.parenR);
  989. return param
  990. };
  991. pp$8.parseTryStatement = function(node) {
  992. this.next();
  993. node.block = this.parseBlock();
  994. node.handler = null;
  995. if (this.type === types$1._catch) {
  996. var clause = this.startNode();
  997. this.next();
  998. if (this.eat(types$1.parenL)) {
  999. clause.param = this.parseCatchClauseParam();
  1000. } else {
  1001. if (this.options.ecmaVersion < 10) { this.unexpected(); }
  1002. clause.param = null;
  1003. this.enterScope(0);
  1004. }
  1005. clause.body = this.parseBlock(false);
  1006. this.exitScope();
  1007. node.handler = this.finishNode(clause, "CatchClause");
  1008. }
  1009. node.finalizer = this.eat(types$1._finally) ? this.parseBlock() : null;
  1010. if (!node.handler && !node.finalizer)
  1011. { this.raise(node.start, "Missing catch or finally clause"); }
  1012. return this.finishNode(node, "TryStatement")
  1013. };
  1014. pp$8.parseVarStatement = function(node, kind, allowMissingInitializer) {
  1015. this.next();
  1016. this.parseVar(node, false, kind, allowMissingInitializer);
  1017. this.semicolon();
  1018. return this.finishNode(node, "VariableDeclaration")
  1019. };
  1020. pp$8.parseWhileStatement = function(node) {
  1021. this.next();
  1022. node.test = this.parseParenExpression();
  1023. this.labels.push(loopLabel);
  1024. node.body = this.parseStatement("while");
  1025. this.labels.pop();
  1026. return this.finishNode(node, "WhileStatement")
  1027. };
  1028. pp$8.parseWithStatement = function(node) {
  1029. if (this.strict) { this.raise(this.start, "'with' in strict mode"); }
  1030. this.next();
  1031. node.object = this.parseParenExpression();
  1032. node.body = this.parseStatement("with");
  1033. return this.finishNode(node, "WithStatement")
  1034. };
  1035. pp$8.parseEmptyStatement = function(node) {
  1036. this.next();
  1037. return this.finishNode(node, "EmptyStatement")
  1038. };
  1039. pp$8.parseLabeledStatement = function(node, maybeName, expr, context) {
  1040. for (var i$1 = 0, list = this.labels; i$1 < list.length; i$1 += 1)
  1041. {
  1042. var label = list[i$1];
  1043. if (label.name === maybeName)
  1044. { this.raise(expr.start, "Label '" + maybeName + "' is already declared");
  1045. } }
  1046. var kind = this.type.isLoop ? "loop" : this.type === types$1._switch ? "switch" : null;
  1047. for (var i = this.labels.length - 1; i >= 0; i--) {
  1048. var label$1 = this.labels[i];
  1049. if (label$1.statementStart === node.start) {
  1050. // Update information about previous labels on this node
  1051. label$1.statementStart = this.start;
  1052. label$1.kind = kind;
  1053. } else { break }
  1054. }
  1055. this.labels.push({name: maybeName, kind: kind, statementStart: this.start});
  1056. node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label");
  1057. this.labels.pop();
  1058. node.label = expr;
  1059. return this.finishNode(node, "LabeledStatement")
  1060. };
  1061. pp$8.parseExpressionStatement = function(node, expr) {
  1062. node.expression = expr;
  1063. this.semicolon();
  1064. return this.finishNode(node, "ExpressionStatement")
  1065. };
  1066. // Parse a semicolon-enclosed block of statements, handling `"use
  1067. // strict"` declarations when `allowStrict` is true (used for
  1068. // function bodies).
  1069. pp$8.parseBlock = function(createNewLexicalScope, node, exitStrict) {
  1070. if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true;
  1071. if ( node === void 0 ) node = this.startNode();
  1072. node.body = [];
  1073. this.expect(types$1.braceL);
  1074. if (createNewLexicalScope) { this.enterScope(0); }
  1075. while (this.type !== types$1.braceR) {
  1076. var stmt = this.parseStatement(null);
  1077. node.body.push(stmt);
  1078. }
  1079. if (exitStrict) { this.strict = false; }
  1080. this.next();
  1081. if (createNewLexicalScope) { this.exitScope(); }
  1082. return this.finishNode(node, "BlockStatement")
  1083. };
  1084. // Parse a regular `for` loop. The disambiguation code in
  1085. // `parseStatement` will already have parsed the init statement or
  1086. // expression.
  1087. pp$8.parseFor = function(node, init) {
  1088. node.init = init;
  1089. this.expect(types$1.semi);
  1090. node.test = this.type === types$1.semi ? null : this.parseExpression();
  1091. this.expect(types$1.semi);
  1092. node.update = this.type === types$1.parenR ? null : this.parseExpression();
  1093. this.expect(types$1.parenR);
  1094. node.body = this.parseStatement("for");
  1095. this.exitScope();
  1096. this.labels.pop();
  1097. return this.finishNode(node, "ForStatement")
  1098. };
  1099. // Parse a `for`/`in` and `for`/`of` loop, which are almost
  1100. // same from parser's perspective.
  1101. pp$8.parseForIn = function(node, init) {
  1102. var isForIn = this.type === types$1._in;
  1103. this.next();
  1104. if (
  1105. init.type === "VariableDeclaration" &&
  1106. init.declarations[0].init != null &&
  1107. (
  1108. !isForIn ||
  1109. this.options.ecmaVersion < 8 ||
  1110. this.strict ||
  1111. init.kind !== "var" ||
  1112. init.declarations[0].id.type !== "Identifier"
  1113. )
  1114. ) {
  1115. this.raise(
  1116. init.start,
  1117. ((isForIn ? "for-in" : "for-of") + " loop variable declaration may not have an initializer")
  1118. );
  1119. }
  1120. node.left = init;
  1121. node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign();
  1122. this.expect(types$1.parenR);
  1123. node.body = this.parseStatement("for");
  1124. this.exitScope();
  1125. this.labels.pop();
  1126. return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement")
  1127. };
  1128. // Parse a list of variable declarations.
  1129. pp$8.parseVar = function(node, isFor, kind, allowMissingInitializer) {
  1130. node.declarations = [];
  1131. node.kind = kind;
  1132. for (;;) {
  1133. var decl = this.startNode();
  1134. this.parseVarId(decl, kind);
  1135. if (this.eat(types$1.eq)) {
  1136. decl.init = this.parseMaybeAssign(isFor);
  1137. } else if (!allowMissingInitializer && kind === "const" && !(this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) {
  1138. this.unexpected();
  1139. } else if (!allowMissingInitializer && decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) {
  1140. this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
  1141. } else {
  1142. decl.init = null;
  1143. }
  1144. node.declarations.push(this.finishNode(decl, "VariableDeclarator"));
  1145. if (!this.eat(types$1.comma)) { break }
  1146. }
  1147. return node
  1148. };
  1149. pp$8.parseVarId = function(decl, kind) {
  1150. decl.id = this.parseBindingAtom();
  1151. this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
  1152. };
  1153. var FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4;
  1154. // Parse a function declaration or literal (depending on the
  1155. // `statement & FUNC_STATEMENT`).
  1156. // Remove `allowExpressionBody` for 7.0.0, as it is only called with false
  1157. pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, forInit) {
  1158. this.initFunction(node);
  1159. if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) {
  1160. if (this.type === types$1.star && (statement & FUNC_HANGING_STATEMENT))
  1161. { this.unexpected(); }
  1162. node.generator = this.eat(types$1.star);
  1163. }
  1164. if (this.options.ecmaVersion >= 8)
  1165. { node.async = !!isAsync; }
  1166. if (statement & FUNC_STATEMENT) {
  1167. node.id = (statement & FUNC_NULLABLE_ID) && this.type !== types$1.name ? null : this.parseIdent();
  1168. if (node.id && !(statement & FUNC_HANGING_STATEMENT))
  1169. // If it is a regular function declaration in sloppy mode, then it is
  1170. // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
  1171. // mode depends on properties of the current scope (see
  1172. // treatFunctionsAsVar).
  1173. { this.checkLValSimple(node.id, (this.strict || node.generator || node.async) ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION); }
  1174. }
  1175. var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
  1176. this.yieldPos = 0;
  1177. this.awaitPos = 0;
  1178. this.awaitIdentPos = 0;
  1179. this.enterScope(functionFlags(node.async, node.generator));
  1180. if (!(statement & FUNC_STATEMENT))
  1181. { node.id = this.type === types$1.name ? this.parseIdent() : null; }
  1182. this.parseFunctionParams(node);
  1183. this.parseFunctionBody(node, allowExpressionBody, false, forInit);
  1184. this.yieldPos = oldYieldPos;
  1185. this.awaitPos = oldAwaitPos;
  1186. this.awaitIdentPos = oldAwaitIdentPos;
  1187. return this.finishNode(node, (statement & FUNC_STATEMENT) ? "FunctionDeclaration" : "FunctionExpression")
  1188. };
  1189. pp$8.parseFunctionParams = function(node) {
  1190. this.expect(types$1.parenL);
  1191. node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8);
  1192. this.checkYieldAwaitInDefaultParams();
  1193. };
  1194. // Parse a class declaration or literal (depending on the
  1195. // `isStatement` parameter).
  1196. pp$8.parseClass = function(node, isStatement) {
  1197. this.next();
  1198. // ecma-262 14.6 Class Definitions
  1199. // A class definition is always strict mode code.
  1200. var oldStrict = this.strict;
  1201. this.strict = true;
  1202. this.parseClassId(node, isStatement);
  1203. this.parseClassSuper(node);
  1204. var privateNameMap = this.enterClassBody();
  1205. var classBody = this.startNode();
  1206. var hadConstructor = false;
  1207. classBody.body = [];
  1208. this.expect(types$1.braceL);
  1209. while (this.type !== types$1.braceR) {
  1210. var element = this.parseClassElement(node.superClass !== null);
  1211. if (element) {
  1212. classBody.body.push(element);
  1213. if (element.type === "MethodDefinition" && element.kind === "constructor") {
  1214. if (hadConstructor) { this.raiseRecoverable(element.start, "Duplicate constructor in the same class"); }
  1215. hadConstructor = true;
  1216. } else if (element.key && element.key.type === "PrivateIdentifier" && isPrivateNameConflicted(privateNameMap, element)) {
  1217. this.raiseRecoverable(element.key.start, ("Identifier '#" + (element.key.name) + "' has already been declared"));
  1218. }
  1219. }
  1220. }
  1221. this.strict = oldStrict;
  1222. this.next();
  1223. node.body = this.finishNode(classBody, "ClassBody");
  1224. this.exitClassBody();
  1225. return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression")
  1226. };
  1227. pp$8.parseClassElement = function(constructorAllowsSuper) {
  1228. if (this.eat(types$1.semi)) { return null }
  1229. var ecmaVersion = this.options.ecmaVersion;
  1230. var node = this.startNode();
  1231. var keyName = "";
  1232. var isGenerator = false;
  1233. var isAsync = false;
  1234. var kind = "method";
  1235. var isStatic = false;
  1236. if (this.eatContextual("static")) {
  1237. // Parse static init block
  1238. if (ecmaVersion >= 13 && this.eat(types$1.braceL)) {
  1239. this.parseClassStaticBlock(node);
  1240. return node
  1241. }
  1242. if (this.isClassElementNameStart() || this.type === types$1.star) {
  1243. isStatic = true;
  1244. } else {
  1245. keyName = "static";
  1246. }
  1247. }
  1248. node.static = isStatic;
  1249. if (!keyName && ecmaVersion >= 8 && this.eatContextual("async")) {
  1250. if ((this.isClassElementNameStart() || this.type === types$1.star) && !this.canInsertSemicolon()) {
  1251. isAsync = true;
  1252. } else {
  1253. keyName = "async";
  1254. }
  1255. }
  1256. if (!keyName && (ecmaVersion >= 9 || !isAsync) && this.eat(types$1.star)) {
  1257. isGenerator = true;
  1258. }
  1259. if (!keyName && !isAsync && !isGenerator) {
  1260. var lastValue = this.value;
  1261. if (this.eatContextual("get") || this.eatContextual("set")) {
  1262. if (this.isClassElementNameStart()) {
  1263. kind = lastValue;
  1264. } else {
  1265. keyName = lastValue;
  1266. }
  1267. }
  1268. }
  1269. // Parse element name
  1270. if (keyName) {
  1271. // 'async', 'get', 'set', or 'static' were not a keyword contextually.
  1272. // The last token is any of those. Make it the element name.
  1273. node.computed = false;
  1274. node.key = this.startNodeAt(this.lastTokStart, this.lastTokStartLoc);
  1275. node.key.name = keyName;
  1276. this.finishNode(node.key, "Identifier");
  1277. } else {
  1278. this.parseClassElementName(node);
  1279. }
  1280. // Parse element value
  1281. if (ecmaVersion < 13 || this.type === types$1.parenL || kind !== "method" || isGenerator || isAsync) {
  1282. var isConstructor = !node.static && checkKeyName(node, "constructor");
  1283. var allowsDirectSuper = isConstructor && constructorAllowsSuper;
  1284. // Couldn't move this check into the 'parseClassMethod' method for backward compatibility.
  1285. if (isConstructor && kind !== "method") { this.raise(node.key.start, "Constructor can't have get/set modifier"); }
  1286. node.kind = isConstructor ? "constructor" : kind;
  1287. this.parseClassMethod(node, isGenerator, isAsync, allowsDirectSuper);
  1288. } else {
  1289. this.parseClassField(node);
  1290. }
  1291. return node
  1292. };
  1293. pp$8.isClassElementNameStart = function() {
  1294. return (
  1295. this.type === types$1.name ||
  1296. this.type === types$1.privateId ||
  1297. this.type === types$1.num ||
  1298. this.type === types$1.string ||
  1299. this.type === types$1.bracketL ||
  1300. this.type.keyword
  1301. )
  1302. };
  1303. pp$8.parseClassElementName = function(element) {
  1304. if (this.type === types$1.privateId) {
  1305. if (this.value === "constructor") {
  1306. this.raise(this.start, "Classes can't have an element named '#constructor'");
  1307. }
  1308. element.computed = false;
  1309. element.key = this.parsePrivateIdent();
  1310. } else {
  1311. this.parsePropertyName(element);
  1312. }
  1313. };
  1314. pp$8.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper) {
  1315. // Check key and flags
  1316. var key = method.key;
  1317. if (method.kind === "constructor") {
  1318. if (isGenerator) { this.raise(key.start, "Constructor can't be a generator"); }
  1319. if (isAsync) { this.raise(key.start, "Constructor can't be an async method"); }
  1320. } else if (method.static && checkKeyName(method, "prototype")) {
  1321. this.raise(key.start, "Classes may not have a static property named prototype");
  1322. }
  1323. // Parse value
  1324. var value = method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper);
  1325. // Check value
  1326. if (method.kind === "get" && value.params.length !== 0)
  1327. { this.raiseRecoverable(value.start, "getter should have no params"); }
  1328. if (method.kind === "set" && value.params.length !== 1)
  1329. { this.raiseRecoverable(value.start, "setter should have exactly one param"); }
  1330. if (method.kind === "set" && value.params[0].type === "RestElement")
  1331. { this.raiseRecoverable(value.params[0].start, "Setter cannot use rest params"); }
  1332. return this.finishNode(method, "MethodDefinition")
  1333. };
  1334. pp$8.parseClassField = function(field) {
  1335. if (checkKeyName(field, "constructor")) {
  1336. this.raise(field.key.start, "Classes can't have a field named 'constructor'");
  1337. } else if (field.static && checkKeyName(field, "prototype")) {
  1338. this.raise(field.key.start, "Classes can't have a static field named 'prototype'");
  1339. }
  1340. if (this.eat(types$1.eq)) {
  1341. // To raise SyntaxError if 'arguments' exists in the initializer.
  1342. var scope = this.currentThisScope();
  1343. var inClassFieldInit = scope.inClassFieldInit;
  1344. scope.inClassFieldInit = true;
  1345. field.value = this.parseMaybeAssign();
  1346. scope.inClassFieldInit = inClassFieldInit;
  1347. } else {
  1348. field.value = null;
  1349. }
  1350. this.semicolon();
  1351. return this.finishNode(field, "PropertyDefinition")
  1352. };
  1353. pp$8.parseClassStaticBlock = function(node) {
  1354. node.body = [];
  1355. var oldLabels = this.labels;
  1356. this.labels = [];
  1357. this.enterScope(SCOPE_CLASS_STATIC_BLOCK | SCOPE_SUPER);
  1358. while (this.type !== types$1.braceR) {
  1359. var stmt = this.parseStatement(null);
  1360. node.body.push(stmt);
  1361. }
  1362. this.next();
  1363. this.exitScope();
  1364. this.labels = oldLabels;
  1365. return this.finishNode(node, "StaticBlock")
  1366. };
  1367. pp$8.parseClassId = function(node, isStatement) {
  1368. if (this.type === types$1.name) {
  1369. node.id = this.parseIdent();
  1370. if (isStatement)
  1371. { this.checkLValSimple(node.id, BIND_LEXICAL, false); }
  1372. } else {
  1373. if (isStatement === true)
  1374. { this.unexpected(); }
  1375. node.id = null;
  1376. }
  1377. };
  1378. pp$8.parseClassSuper = function(node) {
  1379. node.superClass = this.eat(types$1._extends) ? this.parseExprSubscripts(null, false) : null;
  1380. };
  1381. pp$8.enterClassBody = function() {
  1382. var element = {declared: Object.create(null), used: []};
  1383. this.privateNameStack.push(element);
  1384. return element.declared
  1385. };
  1386. pp$8.exitClassBody = function() {
  1387. var ref = this.privateNameStack.pop();
  1388. var declared = ref.declared;
  1389. var used = ref.used;
  1390. if (!this.options.checkPrivateFields) { return }
  1391. var len = this.privateNameStack.length;
  1392. var parent = len === 0 ? null : this.privateNameStack[len - 1];
  1393. for (var i = 0; i < used.length; ++i) {
  1394. var id = used[i];
  1395. if (!hasOwn(declared, id.name)) {
  1396. if (parent) {
  1397. parent.used.push(id);
  1398. } else {
  1399. this.raiseRecoverable(id.start, ("Private field '#" + (id.name) + "' must be declared in an enclosing class"));
  1400. }
  1401. }
  1402. }
  1403. };
  1404. function isPrivateNameConflicted(privateNameMap, element) {
  1405. var name = element.key.name;
  1406. var curr = privateNameMap[name];
  1407. var next = "true";
  1408. if (element.type === "MethodDefinition" && (element.kind === "get" || element.kind === "set")) {
  1409. next = (element.static ? "s" : "i") + element.kind;
  1410. }
  1411. // `class { get #a(){}; static set #a(_){} }` is also conflict.
  1412. if (
  1413. curr === "iget" && next === "iset" ||
  1414. curr === "iset" && next === "iget" ||
  1415. curr === "sget" && next === "sset" ||
  1416. curr === "sset" && next === "sget"
  1417. ) {
  1418. privateNameMap[name] = "true";
  1419. return false
  1420. } else if (!curr) {
  1421. privateNameMap[name] = next;
  1422. return false
  1423. } else {
  1424. return true
  1425. }
  1426. }
  1427. function checkKeyName(node, name) {
  1428. var computed = node.computed;
  1429. var key = node.key;
  1430. return !computed && (
  1431. key.type === "Identifier" && key.name === name ||
  1432. key.type === "Literal" && key.value === name
  1433. )
  1434. }
  1435. // Parses module export declaration.
  1436. pp$8.parseExportAllDeclaration = function(node, exports) {
  1437. if (this.options.ecmaVersion >= 11) {
  1438. if (this.eatContextual("as")) {
  1439. node.exported = this.parseModuleExportName();
  1440. this.checkExport(exports, node.exported, this.lastTokStart);
  1441. } else {
  1442. node.exported = null;
  1443. }
  1444. }
  1445. this.expectContextual("from");
  1446. if (this.type !== types$1.string) { this.unexpected(); }
  1447. node.source = this.parseExprAtom();
  1448. this.semicolon();
  1449. return this.finishNode(node, "ExportAllDeclaration")
  1450. };
  1451. pp$8.parseExport = function(node, exports) {
  1452. this.next();
  1453. // export * from '...'
  1454. if (this.eat(types$1.star)) {
  1455. return this.parseExportAllDeclaration(node, exports)
  1456. }
  1457. if (this.eat(types$1._default)) { // export default ...
  1458. this.checkExport(exports, "default", this.lastTokStart);
  1459. node.declaration = this.parseExportDefaultDeclaration();
  1460. return this.finishNode(node, "ExportDefaultDeclaration")
  1461. }
  1462. // export var|const|let|function|class ...
  1463. if (this.shouldParseExportStatement()) {
  1464. node.declaration = this.parseExportDeclaration(node);
  1465. if (node.declaration.type === "VariableDeclaration")
  1466. { this.checkVariableExport(exports, node.declaration.declarations); }
  1467. else
  1468. { this.checkExport(exports, node.declaration.id, node.declaration.id.start); }
  1469. node.specifiers = [];
  1470. node.source = null;
  1471. } else { // export { x, y as z } [from '...']
  1472. node.declaration = null;
  1473. node.specifiers = this.parseExportSpecifiers(exports);
  1474. if (this.eatContextual("from")) {
  1475. if (this.type !== types$1.string) { this.unexpected(); }
  1476. node.source = this.parseExprAtom();
  1477. } else {
  1478. for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
  1479. // check for keywords used as local names
  1480. var spec = list[i];
  1481. this.checkUnreserved(spec.local);
  1482. // check if export is defined
  1483. this.checkLocalExport(spec.local);
  1484. if (spec.local.type === "Literal") {
  1485. this.raise(spec.local.start, "A string literal cannot be used as an exported binding without `from`.");
  1486. }
  1487. }
  1488. node.source = null;
  1489. }
  1490. this.semicolon();
  1491. }
  1492. return this.finishNode(node, "ExportNamedDeclaration")
  1493. };
  1494. pp$8.parseExportDeclaration = function(node) {
  1495. return this.parseStatement(null)
  1496. };
  1497. pp$8.parseExportDefaultDeclaration = function() {
  1498. var isAsync;
  1499. if (this.type === types$1._function || (isAsync = this.isAsyncFunction())) {
  1500. var fNode = this.startNode();
  1501. this.next();
  1502. if (isAsync) { this.next(); }
  1503. return this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync)
  1504. } else if (this.type === types$1._class) {
  1505. var cNode = this.startNode();
  1506. return this.parseClass(cNode, "nullableID")
  1507. } else {
  1508. var declaration = this.parseMaybeAssign();
  1509. this.semicolon();
  1510. return declaration
  1511. }
  1512. };
  1513. pp$8.checkExport = function(exports, name, pos) {
  1514. if (!exports) { return }
  1515. if (typeof name !== "string")
  1516. { name = name.type === "Identifier" ? name.name : name.value; }
  1517. if (hasOwn(exports, name))
  1518. { this.raiseRecoverable(pos, "Duplicate export '" + name + "'"); }
  1519. exports[name] = true;
  1520. };
  1521. pp$8.checkPatternExport = function(exports, pat) {
  1522. var type = pat.type;
  1523. if (type === "Identifier")
  1524. { this.checkExport(exports, pat, pat.start); }
  1525. else if (type === "ObjectPattern")
  1526. { for (var i = 0, list = pat.properties; i < list.length; i += 1)
  1527. {
  1528. var prop = list[i];
  1529. this.checkPatternExport(exports, prop);
  1530. } }
  1531. else if (type === "ArrayPattern")
  1532. { for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
  1533. var elt = list$1[i$1];
  1534. if (elt) { this.checkPatternExport(exports, elt); }
  1535. } }
  1536. else if (type === "Property")
  1537. { this.checkPatternExport(exports, pat.value); }
  1538. else if (type === "AssignmentPattern")
  1539. { this.checkPatternExport(exports, pat.left); }
  1540. else if (type === "RestElement")
  1541. { this.checkPatternExport(exports, pat.argument); }
  1542. else if (type === "ParenthesizedExpression")
  1543. { this.checkPatternExport(exports, pat.expression); }
  1544. };
  1545. pp$8.checkVariableExport = function(exports, decls) {
  1546. if (!exports) { return }
  1547. for (var i = 0, list = decls; i < list.length; i += 1)
  1548. {
  1549. var decl = list[i];
  1550. this.checkPatternExport(exports, decl.id);
  1551. }
  1552. };
  1553. pp$8.shouldParseExportStatement = function() {
  1554. return this.type.keyword === "var" ||
  1555. this.type.keyword === "const" ||
  1556. this.type.keyword === "class" ||
  1557. this.type.keyword === "function" ||
  1558. this.isLet() ||
  1559. this.isAsyncFunction()
  1560. };
  1561. // Parses a comma-separated list of module exports.
  1562. pp$8.parseExportSpecifier = function(exports) {
  1563. var node = this.startNode();
  1564. node.local = this.parseModuleExportName();
  1565. node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
  1566. this.checkExport(
  1567. exports,
  1568. node.exported,
  1569. node.exported.start
  1570. );
  1571. return this.finishNode(node, "ExportSpecifier")
  1572. };
  1573. pp$8.parseExportSpecifiers = function(exports) {
  1574. var nodes = [], first = true;
  1575. // export { x, y as z } [from '...']
  1576. this.expect(types$1.braceL);
  1577. while (!this.eat(types$1.braceR)) {
  1578. if (!first) {
  1579. this.expect(types$1.comma);
  1580. if (this.afterTrailingComma(types$1.braceR)) { break }
  1581. } else { first = false; }
  1582. nodes.push(this.parseExportSpecifier(exports));
  1583. }
  1584. return nodes
  1585. };
  1586. // Parses import declaration.
  1587. pp$8.parseImport = function(node) {
  1588. this.next();
  1589. // import '...'
  1590. if (this.type === types$1.string) {
  1591. node.specifiers = empty$1;
  1592. node.source = this.parseExprAtom();
  1593. } else {
  1594. node.specifiers = this.parseImportSpecifiers();
  1595. this.expectContextual("from");
  1596. node.source = this.type === types$1.string ? this.parseExprAtom() : this.unexpected();
  1597. }
  1598. this.semicolon();
  1599. return this.finishNode(node, "ImportDeclaration")
  1600. };
  1601. // Parses a comma-separated list of module imports.
  1602. pp$8.parseImportSpecifier = function() {
  1603. var node = this.startNode();
  1604. node.imported = this.parseModuleExportName();
  1605. if (this.eatContextual("as")) {
  1606. node.local = this.parseIdent();
  1607. } else {
  1608. this.checkUnreserved(node.imported);
  1609. node.local = node.imported;
  1610. }
  1611. this.checkLValSimple(node.local, BIND_LEXICAL);
  1612. return this.finishNode(node, "ImportSpecifier")
  1613. };
  1614. pp$8.parseImportDefaultSpecifier = function() {
  1615. // import defaultObj, { x, y as z } from '...'
  1616. var node = this.startNode();
  1617. node.local = this.parseIdent();
  1618. this.checkLValSimple(node.local, BIND_LEXICAL);
  1619. return this.finishNode(node, "ImportDefaultSpecifier")
  1620. };
  1621. pp$8.parseImportNamespaceSpecifier = function() {
  1622. var node = this.startNode();
  1623. this.next();
  1624. this.expectContextual("as");
  1625. node.local = this.parseIdent();
  1626. this.checkLValSimple(node.local, BIND_LEXICAL);
  1627. return this.finishNode(node, "ImportNamespaceSpecifier")
  1628. };
  1629. pp$8.parseImportSpecifiers = function() {
  1630. var nodes = [], first = true;
  1631. if (this.type === types$1.name) {
  1632. nodes.push(this.parseImportDefaultSpecifier());
  1633. if (!this.eat(types$1.comma)) { return nodes }
  1634. }
  1635. if (this.type === types$1.star) {
  1636. nodes.push(this.parseImportNamespaceSpecifier());
  1637. return nodes
  1638. }
  1639. this.expect(types$1.braceL);
  1640. while (!this.eat(types$1.braceR)) {
  1641. if (!first) {
  1642. this.expect(types$1.comma);
  1643. if (this.afterTrailingComma(types$1.braceR)) { break }
  1644. } else { first = false; }
  1645. nodes.push(this.parseImportSpecifier());
  1646. }
  1647. return nodes
  1648. };
  1649. pp$8.parseModuleExportName = function() {
  1650. if (this.options.ecmaVersion >= 13 && this.type === types$1.string) {
  1651. var stringLiteral = this.parseLiteral(this.value);
  1652. if (loneSurrogate.test(stringLiteral.value)) {
  1653. this.raise(stringLiteral.start, "An export name cannot include a lone surrogate.");
  1654. }
  1655. return stringLiteral
  1656. }
  1657. return this.parseIdent(true)
  1658. };
  1659. // Set `ExpressionStatement#directive` property for directive prologues.
  1660. pp$8.adaptDirectivePrologue = function(statements) {
  1661. for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {
  1662. statements[i].directive = statements[i].expression.raw.slice(1, -1);
  1663. }
  1664. };
  1665. pp$8.isDirectiveCandidate = function(statement) {
  1666. return (
  1667. this.options.ecmaVersion >= 5 &&
  1668. statement.type === "ExpressionStatement" &&
  1669. statement.expression.type === "Literal" &&
  1670. typeof statement.expression.value === "string" &&
  1671. // Reject parenthesized strings.
  1672. (this.input[statement.start] === "\"" || this.input[statement.start] === "'")
  1673. )
  1674. };
  1675. var pp$7 = Parser.prototype;
  1676. // Convert existing expression atom to assignable pattern
  1677. // if possible.
  1678. pp$7.toAssignable = function(node, isBinding, refDestructuringErrors) {
  1679. if (this.options.ecmaVersion >= 6 && node) {
  1680. switch (node.type) {
  1681. case "Identifier":
  1682. if (this.inAsync && node.name === "await")
  1683. { this.raise(node.start, "Cannot use 'await' as identifier inside an async function"); }
  1684. break
  1685. case "ObjectPattern":
  1686. case "ArrayPattern":
  1687. case "AssignmentPattern":
  1688. case "RestElement":
  1689. break
  1690. case "ObjectExpression":
  1691. node.type = "ObjectPattern";
  1692. if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
  1693. for (var i = 0, list = node.properties; i < list.length; i += 1) {
  1694. var prop = list[i];
  1695. this.toAssignable(prop, isBinding);
  1696. // Early error:
  1697. // AssignmentRestProperty[Yield, Await] :
  1698. // `...` DestructuringAssignmentTarget[Yield, Await]
  1699. //
  1700. // It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|.
  1701. if (
  1702. prop.type === "RestElement" &&
  1703. (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern")
  1704. ) {
  1705. this.raise(prop.argument.start, "Unexpected token");
  1706. }
  1707. }
  1708. break
  1709. case "Property":
  1710. // AssignmentProperty has type === "Property"
  1711. if (node.kind !== "init") { this.raise(node.key.start, "Object pattern can't contain getter or setter"); }
  1712. this.toAssignable(node.value, isBinding);
  1713. break
  1714. case "ArrayExpression":
  1715. node.type = "ArrayPattern";
  1716. if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
  1717. this.toAssignableList(node.elements, isBinding);
  1718. break
  1719. case "SpreadElement":
  1720. node.type = "RestElement";
  1721. this.toAssignable(node.argument, isBinding);
  1722. if (node.argument.type === "AssignmentPattern")
  1723. { this.raise(node.argument.start, "Rest elements cannot have a default value"); }
  1724. break
  1725. case "AssignmentExpression":
  1726. if (node.operator !== "=") { this.raise(node.left.end, "Only '=' operator can be used for specifying default value."); }
  1727. node.type = "AssignmentPattern";
  1728. delete node.operator;
  1729. this.toAssignable(node.left, isBinding);
  1730. break
  1731. case "ParenthesizedExpression":
  1732. this.toAssignable(node.expression, isBinding, refDestructuringErrors);
  1733. break
  1734. case "ChainExpression":
  1735. this.raiseRecoverable(node.start, "Optional chaining cannot appear in left-hand side");
  1736. break
  1737. case "MemberExpression":
  1738. if (!isBinding) { break }
  1739. default:
  1740. this.raise(node.start, "Assigning to rvalue");
  1741. }
  1742. } else if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
  1743. return node
  1744. };
  1745. // Convert list of expression atoms to binding list.
  1746. pp$7.toAssignableList = function(exprList, isBinding) {
  1747. var end = exprList.length;
  1748. for (var i = 0; i < end; i++) {
  1749. var elt = exprList[i];
  1750. if (elt) { this.toAssignable(elt, isBinding); }
  1751. }
  1752. if (end) {
  1753. var last = exprList[end - 1];
  1754. if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier")
  1755. { this.unexpected(last.argument.start); }
  1756. }
  1757. return exprList
  1758. };
  1759. // Parses spread element.
  1760. pp$7.parseSpread = function(refDestructuringErrors) {
  1761. var node = this.startNode();
  1762. this.next();
  1763. node.argument = this.parseMaybeAssign(false, refDestructuringErrors);
  1764. return this.finishNode(node, "SpreadElement")
  1765. };
  1766. pp$7.parseRestBinding = function() {
  1767. var node = this.startNode();
  1768. this.next();
  1769. // RestElement inside of a function parameter must be an identifier
  1770. if (this.options.ecmaVersion === 6 && this.type !== types$1.name)
  1771. { this.unexpected(); }
  1772. node.argument = this.parseBindingAtom();
  1773. return this.finishNode(node, "RestElement")
  1774. };
  1775. // Parses lvalue (assignable) atom.
  1776. pp$7.parseBindingAtom = function() {
  1777. if (this.options.ecmaVersion >= 6) {
  1778. switch (this.type) {
  1779. case types$1.bracketL:
  1780. var node = this.startNode();
  1781. this.next();
  1782. node.elements = this.parseBindingList(types$1.bracketR, true, true);
  1783. return this.finishNode(node, "ArrayPattern")
  1784. case types$1.braceL:
  1785. return this.parseObj(true)
  1786. }
  1787. }
  1788. return this.parseIdent()
  1789. };
  1790. pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowModifiers) {
  1791. var elts = [], first = true;
  1792. while (!this.eat(close)) {
  1793. if (first) { first = false; }
  1794. else { this.expect(types$1.comma); }
  1795. if (allowEmpty && this.type === types$1.comma) {
  1796. elts.push(null);
  1797. } else if (allowTrailingComma && this.afterTrailingComma(close)) {
  1798. break
  1799. } else if (this.type === types$1.ellipsis) {
  1800. var rest = this.parseRestBinding();
  1801. this.parseBindingListItem(rest);
  1802. elts.push(rest);
  1803. if (this.type === types$1.comma) { this.raiseRecoverable(this.start, "Comma is not permitted after the rest element"); }
  1804. this.expect(close);
  1805. break
  1806. } else {
  1807. elts.push(this.parseAssignableListItem(allowModifiers));
  1808. }
  1809. }
  1810. return elts
  1811. };
  1812. pp$7.parseAssignableListItem = function(allowModifiers) {
  1813. var elem = this.parseMaybeDefault(this.start, this.startLoc);
  1814. this.parseBindingListItem(elem);
  1815. return elem
  1816. };
  1817. pp$7.parseBindingListItem = function(param) {
  1818. return param
  1819. };
  1820. // Parses assignment pattern around given atom if possible.
  1821. pp$7.parseMaybeDefault = function(startPos, startLoc, left) {
  1822. left = left || this.parseBindingAtom();
  1823. if (this.options.ecmaVersion < 6 || !this.eat(types$1.eq)) { return left }
  1824. var node = this.startNodeAt(startPos, startLoc);
  1825. node.left = left;
  1826. node.right = this.parseMaybeAssign();
  1827. return this.finishNode(node, "AssignmentPattern")
  1828. };
  1829. // The following three functions all verify that a node is an lvalue —
  1830. // something that can be bound, or assigned to. In order to do so, they perform
  1831. // a variety of checks:
  1832. //
  1833. // - Check that none of the bound/assigned-to identifiers are reserved words.
  1834. // - Record name declarations for bindings in the appropriate scope.
  1835. // - Check duplicate argument names, if checkClashes is set.
  1836. //
  1837. // If a complex binding pattern is encountered (e.g., object and array
  1838. // destructuring), the entire pattern is recursively checked.
  1839. //
  1840. // There are three versions of checkLVal*() appropriate for different
  1841. // circumstances:
  1842. //
  1843. // - checkLValSimple() shall be used if the syntactic construct supports
  1844. // nothing other than identifiers and member expressions. Parenthesized
  1845. // expressions are also correctly handled. This is generally appropriate for
  1846. // constructs for which the spec says
  1847. //
  1848. // > It is a Syntax Error if AssignmentTargetType of [the production] is not
  1849. // > simple.
  1850. //
  1851. // It is also appropriate for checking if an identifier is valid and not
  1852. // defined elsewhere, like import declarations or function/class identifiers.
  1853. //
  1854. // Examples where this is used include:
  1855. // a += …;
  1856. // import a from '…';
  1857. // where a is the node to be checked.
  1858. //
  1859. // - checkLValPattern() shall be used if the syntactic construct supports
  1860. // anything checkLValSimple() supports, as well as object and array
  1861. // destructuring patterns. This is generally appropriate for constructs for
  1862. // which the spec says
  1863. //
  1864. // > It is a Syntax Error if [the production] is neither an ObjectLiteral nor
  1865. // > an ArrayLiteral and AssignmentTargetType of [the production] is not
  1866. // > simple.
  1867. //
  1868. // Examples where this is used include:
  1869. // (a = …);
  1870. // const a = …;
  1871. // try { … } catch (a) { … }
  1872. // where a is the node to be checked.
  1873. //
  1874. // - checkLValInnerPattern() shall be used if the syntactic construct supports
  1875. // anything checkLValPattern() supports, as well as default assignment
  1876. // patterns, rest elements, and other constructs that may appear within an
  1877. // object or array destructuring pattern.
  1878. //
  1879. // As a special case, function parameters also use checkLValInnerPattern(),
  1880. // as they also support defaults and rest constructs.
  1881. //
  1882. // These functions deliberately support both assignment and binding constructs,
  1883. // as the logic for both is exceedingly similar. If the node is the target of
  1884. // an assignment, then bindingType should be set to BIND_NONE. Otherwise, it
  1885. // should be set to the appropriate BIND_* constant, like BIND_VAR or
  1886. // BIND_LEXICAL.
  1887. //
  1888. // If the function is called with a non-BIND_NONE bindingType, then
  1889. // additionally a checkClashes object may be specified to allow checking for
  1890. // duplicate argument names. checkClashes is ignored if the provided construct
  1891. // is an assignment (i.e., bindingType is BIND_NONE).
  1892. pp$7.checkLValSimple = function(expr, bindingType, checkClashes) {
  1893. if ( bindingType === void 0 ) bindingType = BIND_NONE;
  1894. var isBind = bindingType !== BIND_NONE;
  1895. switch (expr.type) {
  1896. case "Identifier":
  1897. if (this.strict && this.reservedWordsStrictBind.test(expr.name))
  1898. { this.raiseRecoverable(expr.start, (isBind ? "Binding " : "Assigning to ") + expr.name + " in strict mode"); }
  1899. if (isBind) {
  1900. if (bindingType === BIND_LEXICAL && expr.name === "let")
  1901. { this.raiseRecoverable(expr.start, "let is disallowed as a lexically bound name"); }
  1902. if (checkClashes) {
  1903. if (hasOwn(checkClashes, expr.name))
  1904. { this.raiseRecoverable(expr.start, "Argument name clash"); }
  1905. checkClashes[expr.name] = true;
  1906. }
  1907. if (bindingType !== BIND_OUTSIDE) { this.declareName(expr.name, bindingType, expr.start); }
  1908. }
  1909. break
  1910. case "ChainExpression":
  1911. this.raiseRecoverable(expr.start, "Optional chaining cannot appear in left-hand side");
  1912. break
  1913. case "MemberExpression":
  1914. if (isBind) { this.raiseRecoverable(expr.start, "Binding member expression"); }
  1915. break
  1916. case "ParenthesizedExpression":
  1917. if (isBind) { this.raiseRecoverable(expr.start, "Binding parenthesized expression"); }
  1918. return this.checkLValSimple(expr.expression, bindingType, checkClashes)
  1919. default:
  1920. this.raise(expr.start, (isBind ? "Binding" : "Assigning to") + " rvalue");
  1921. }
  1922. };
  1923. pp$7.checkLValPattern = function(expr, bindingType, checkClashes) {
  1924. if ( bindingType === void 0 ) bindingType = BIND_NONE;
  1925. switch (expr.type) {
  1926. case "ObjectPattern":
  1927. for (var i = 0, list = expr.properties; i < list.length; i += 1) {
  1928. var prop = list[i];
  1929. this.checkLValInnerPattern(prop, bindingType, checkClashes);
  1930. }
  1931. break
  1932. case "ArrayPattern":
  1933. for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) {
  1934. var elem = list$1[i$1];
  1935. if (elem) { this.checkLValInnerPattern(elem, bindingType, checkClashes); }
  1936. }
  1937. break
  1938. default:
  1939. this.checkLValSimple(expr, bindingType, checkClashes);
  1940. }
  1941. };
  1942. pp$7.checkLValInnerPattern = function(expr, bindingType, checkClashes) {
  1943. if ( bindingType === void 0 ) bindingType = BIND_NONE;
  1944. switch (expr.type) {
  1945. case "Property":
  1946. // AssignmentProperty has type === "Property"
  1947. this.checkLValInnerPattern(expr.value, bindingType, checkClashes);
  1948. break
  1949. case "AssignmentPattern":
  1950. this.checkLValPattern(expr.left, bindingType, checkClashes);
  1951. break
  1952. case "RestElement":
  1953. this.checkLValPattern(expr.argument, bindingType, checkClashes);
  1954. break
  1955. default:
  1956. this.checkLValPattern(expr, bindingType, checkClashes);
  1957. }
  1958. };
  1959. // The algorithm used to determine whether a regexp can appear at a
  1960. // given point in the program is loosely based on sweet.js' approach.
  1961. // See https://github.com/mozilla/sweet.js/wiki/design
  1962. var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) {
  1963. this.token = token;
  1964. this.isExpr = !!isExpr;
  1965. this.preserveSpace = !!preserveSpace;
  1966. this.override = override;
  1967. this.generator = !!generator;
  1968. };
  1969. var types = {
  1970. b_stat: new TokContext("{", false),
  1971. b_expr: new TokContext("{", true),
  1972. b_tmpl: new TokContext("${", false),
  1973. p_stat: new TokContext("(", false),
  1974. p_expr: new TokContext("(", true),
  1975. q_tmpl: new TokContext("`", true, true, function (p) { return p.tryReadTemplateToken(); }),
  1976. f_stat: new TokContext("function", false),
  1977. f_expr: new TokContext("function", true),
  1978. f_expr_gen: new TokContext("function", true, false, null, true),
  1979. f_gen: new TokContext("function", false, false, null, true)
  1980. };
  1981. var pp$6 = Parser.prototype;
  1982. pp$6.initialContext = function() {
  1983. return [types.b_stat]
  1984. };
  1985. pp$6.curContext = function() {
  1986. return this.context[this.context.length - 1]
  1987. };
  1988. pp$6.braceIsBlock = function(prevType) {
  1989. var parent = this.curContext();
  1990. if (parent === types.f_expr || parent === types.f_stat)
  1991. { return true }
  1992. if (prevType === types$1.colon && (parent === types.b_stat || parent === types.b_expr))
  1993. { return !parent.isExpr }
  1994. // The check for `tt.name && exprAllowed` detects whether we are
  1995. // after a `yield` or `of` construct. See the `updateContext` for
  1996. // `tt.name`.
  1997. if (prevType === types$1._return || prevType === types$1.name && this.exprAllowed)
  1998. { return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) }
  1999. if (prevType === types$1._else || prevType === types$1.semi || prevType === types$1.eof || prevType === types$1.parenR || prevType === types$1.arrow)
  2000. { return true }
  2001. if (prevType === types$1.braceL)
  2002. { return parent === types.b_stat }
  2003. if (prevType === types$1._var || prevType === types$1._const || prevType === types$1.name)
  2004. { return false }
  2005. return !this.exprAllowed
  2006. };
  2007. pp$6.inGeneratorContext = function() {
  2008. for (var i = this.context.length - 1; i >= 1; i--) {
  2009. var context = this.context[i];
  2010. if (context.token === "function")
  2011. { return context.generator }
  2012. }
  2013. return false
  2014. };
  2015. pp$6.updateContext = function(prevType) {
  2016. var update, type = this.type;
  2017. if (type.keyword && prevType === types$1.dot)
  2018. { this.exprAllowed = false; }
  2019. else if (update = type.updateContext)
  2020. { update.call(this, prevType); }
  2021. else
  2022. { this.exprAllowed = type.beforeExpr; }
  2023. };
  2024. // Used to handle egde cases when token context could not be inferred correctly during tokenization phase
  2025. pp$6.overrideContext = function(tokenCtx) {
  2026. if (this.curContext() !== tokenCtx) {
  2027. this.context[this.context.length - 1] = tokenCtx;
  2028. }
  2029. };
  2030. // Token-specific context update code
  2031. types$1.parenR.updateContext = types$1.braceR.updateContext = function() {
  2032. if (this.context.length === 1) {
  2033. this.exprAllowed = true;
  2034. return
  2035. }
  2036. var out = this.context.pop();
  2037. if (out === types.b_stat && this.curContext().token === "function") {
  2038. out = this.context.pop();
  2039. }
  2040. this.exprAllowed = !out.isExpr;
  2041. };
  2042. types$1.braceL.updateContext = function(prevType) {
  2043. this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr);
  2044. this.exprAllowed = true;
  2045. };
  2046. types$1.dollarBraceL.updateContext = function() {
  2047. this.context.push(types.b_tmpl);
  2048. this.exprAllowed = true;
  2049. };
  2050. types$1.parenL.updateContext = function(prevType) {
  2051. var statementParens = prevType === types$1._if || prevType === types$1._for || prevType === types$1._with || prevType === types$1._while;
  2052. this.context.push(statementParens ? types.p_stat : types.p_expr);
  2053. this.exprAllowed = true;
  2054. };
  2055. types$1.incDec.updateContext = function() {
  2056. // tokExprAllowed stays unchanged
  2057. };
  2058. types$1._function.updateContext = types$1._class.updateContext = function(prevType) {
  2059. if (prevType.beforeExpr && prevType !== types$1._else &&
  2060. !(prevType === types$1.semi && this.curContext() !== types.p_stat) &&
  2061. !(prevType === types$1._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) &&
  2062. !((prevType === types$1.colon || prevType === types$1.braceL) && this.curContext() === types.b_stat))
  2063. { this.context.push(types.f_expr); }
  2064. else
  2065. { this.context.push(types.f_stat); }
  2066. this.exprAllowed = false;
  2067. };
  2068. types$1.backQuote.updateContext = function() {
  2069. if (this.curContext() === types.q_tmpl)
  2070. { this.context.pop(); }
  2071. else
  2072. { this.context.push(types.q_tmpl); }
  2073. this.exprAllowed = false;
  2074. };
  2075. types$1.star.updateContext = function(prevType) {
  2076. if (prevType === types$1._function) {
  2077. var index = this.context.length - 1;
  2078. if (this.context[index] === types.f_expr)
  2079. { this.context[index] = types.f_expr_gen; }
  2080. else
  2081. { this.context[index] = types.f_gen; }
  2082. }
  2083. this.exprAllowed = true;
  2084. };
  2085. types$1.name.updateContext = function(prevType) {
  2086. var allowed = false;
  2087. if (this.options.ecmaVersion >= 6 && prevType !== types$1.dot) {
  2088. if (this.value === "of" && !this.exprAllowed ||
  2089. this.value === "yield" && this.inGeneratorContext())
  2090. { allowed = true; }
  2091. }
  2092. this.exprAllowed = allowed;
  2093. };
  2094. // A recursive descent parser operates by defining functions for all
  2095. // syntactic elements, and recursively calling those, each function
  2096. // advancing the input stream and returning an AST node. Precedence
  2097. // of constructs (for example, the fact that `!x[1]` means `!(x[1])`
  2098. // instead of `(!x)[1]` is handled by the fact that the parser
  2099. // function that parses unary prefix operators is called first, and
  2100. // in turn calls the function that parses `[]` subscripts — that
  2101. // way, it'll receive the node for `x[1]` already parsed, and wraps
  2102. // *that* in the unary operator node.
  2103. //
  2104. // Acorn uses an [operator precedence parser][opp] to handle binary
  2105. // operator precedence, because it is much more compact than using
  2106. // the technique outlined above, which uses different, nesting
  2107. // functions to specify precedence, for all of the ten binary
  2108. // precedence levels that JavaScript defines.
  2109. //
  2110. // [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser
  2111. var pp$5 = Parser.prototype;
  2112. // Check if property name clashes with already added.
  2113. // Object/class getters and setters are not allowed to clash —
  2114. // either with each other or with an init property — and in
  2115. // strict mode, init properties are also not allowed to be repeated.
  2116. pp$5.checkPropClash = function(prop, propHash, refDestructuringErrors) {
  2117. if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement")
  2118. { return }
  2119. if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand))
  2120. { return }
  2121. var key = prop.key;
  2122. var name;
  2123. switch (key.type) {
  2124. case "Identifier": name = key.name; break
  2125. case "Literal": name = String(key.value); break
  2126. default: return
  2127. }
  2128. var kind = prop.kind;
  2129. if (this.options.ecmaVersion >= 6) {
  2130. if (name === "__proto__" && kind === "init") {
  2131. if (propHash.proto) {
  2132. if (refDestructuringErrors) {
  2133. if (refDestructuringErrors.doubleProto < 0) {
  2134. refDestructuringErrors.doubleProto = key.start;
  2135. }
  2136. } else {
  2137. this.raiseRecoverable(key.start, "Redefinition of __proto__ property");
  2138. }
  2139. }
  2140. propHash.proto = true;
  2141. }
  2142. return
  2143. }
  2144. name = "$" + name;
  2145. var other = propHash[name];
  2146. if (other) {
  2147. var redefinition;
  2148. if (kind === "init") {
  2149. redefinition = this.strict && other.init || other.get || other.set;
  2150. } else {
  2151. redefinition = other.init || other[kind];
  2152. }
  2153. if (redefinition)
  2154. { this.raiseRecoverable(key.start, "Redefinition of property"); }
  2155. } else {
  2156. other = propHash[name] = {
  2157. init: false,
  2158. get: false,
  2159. set: false
  2160. };
  2161. }
  2162. other[kind] = true;
  2163. };
  2164. // ### Expression parsing
  2165. // These nest, from the most general expression type at the top to
  2166. // 'atomic', nondivisible expression types at the bottom. Most of
  2167. // the functions will simply let the function(s) below them parse,
  2168. // and, *if* the syntactic construct they handle is present, wrap
  2169. // the AST node that the inner parser gave them in another node.
  2170. // Parse a full expression. The optional arguments are used to
  2171. // forbid the `in` operator (in for loops initalization expressions)
  2172. // and provide reference for storing '=' operator inside shorthand
  2173. // property assignment in contexts where both object expression
  2174. // and object pattern might appear (so it's possible to raise
  2175. // delayed syntax error at correct position).
  2176. pp$5.parseExpression = function(forInit, refDestructuringErrors) {
  2177. var startPos = this.start, startLoc = this.startLoc;
  2178. var expr = this.parseMaybeAssign(forInit, refDestructuringErrors);
  2179. if (this.type === types$1.comma) {
  2180. var node = this.startNodeAt(startPos, startLoc);
  2181. node.expressions = [expr];
  2182. while (this.eat(types$1.comma)) { node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors)); }
  2183. return this.finishNode(node, "SequenceExpression")
  2184. }
  2185. return expr
  2186. };
  2187. // Parse an assignment expression. This includes applications of
  2188. // operators like `+=`.
  2189. pp$5.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) {
  2190. if (this.isContextual("yield")) {
  2191. if (this.inGenerator) { return this.parseYield(forInit) }
  2192. // The tokenizer will assume an expression is allowed after
  2193. // `yield`, but this isn't that kind of yield
  2194. else { this.exprAllowed = false; }
  2195. }
  2196. var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1, oldDoubleProto = -1;
  2197. if (refDestructuringErrors) {
  2198. oldParenAssign = refDestructuringErrors.parenthesizedAssign;
  2199. oldTrailingComma = refDestructuringErrors.trailingComma;
  2200. oldDoubleProto = refDestructuringErrors.doubleProto;
  2201. refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1;
  2202. } else {
  2203. refDestructuringErrors = new DestructuringErrors;
  2204. ownDestructuringErrors = true;
  2205. }
  2206. var startPos = this.start, startLoc = this.startLoc;
  2207. if (this.type === types$1.parenL || this.type === types$1.name) {
  2208. this.potentialArrowAt = this.start;
  2209. this.potentialArrowInForAwait = forInit === "await";
  2210. }
  2211. var left = this.parseMaybeConditional(forInit, refDestructuringErrors);
  2212. if (afterLeftParse) { left = afterLeftParse.call(this, left, startPos, startLoc); }
  2213. if (this.type.isAssign) {
  2214. var node = this.startNodeAt(startPos, startLoc);
  2215. node.operator = this.value;
  2216. if (this.type === types$1.eq)
  2217. { left = this.toAssignable(left, false, refDestructuringErrors); }
  2218. if (!ownDestructuringErrors) {
  2219. refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1;
  2220. }
  2221. if (refDestructuringErrors.shorthandAssign >= left.start)
  2222. { refDestructuringErrors.shorthandAssign = -1; } // reset because shorthand default was used correctly
  2223. if (this.type === types$1.eq)
  2224. { this.checkLValPattern(left); }
  2225. else
  2226. { this.checkLValSimple(left); }
  2227. node.left = left;
  2228. this.next();
  2229. node.right = this.parseMaybeAssign(forInit);
  2230. if (oldDoubleProto > -1) { refDestructuringErrors.doubleProto = oldDoubleProto; }
  2231. return this.finishNode(node, "AssignmentExpression")
  2232. } else {
  2233. if (ownDestructuringErrors) { this.checkExpressionErrors(refDestructuringErrors, true); }
  2234. }
  2235. if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; }
  2236. if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; }
  2237. return left
  2238. };
  2239. // Parse a ternary conditional (`?:`) operator.
  2240. pp$5.parseMaybeConditional = function(forInit, refDestructuringErrors) {
  2241. var startPos = this.start, startLoc = this.startLoc;
  2242. var expr = this.parseExprOps(forInit, refDestructuringErrors);
  2243. if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
  2244. if (this.eat(types$1.question)) {
  2245. var node = this.startNodeAt(startPos, startLoc);
  2246. node.test = expr;
  2247. node.consequent = this.parseMaybeAssign();
  2248. this.expect(types$1.colon);
  2249. node.alternate = this.parseMaybeAssign(forInit);
  2250. return this.finishNode(node, "ConditionalExpression")
  2251. }
  2252. return expr
  2253. };
  2254. // Start the precedence parser.
  2255. pp$5.parseExprOps = function(forInit, refDestructuringErrors) {
  2256. var startPos = this.start, startLoc = this.startLoc;
  2257. var expr = this.parseMaybeUnary(refDestructuringErrors, false, false, forInit);
  2258. if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
  2259. return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, forInit)
  2260. };
  2261. // Parse binary operators with the operator precedence parsing
  2262. // algorithm. `left` is the left-hand side of the operator.
  2263. // `minPrec` provides context that allows the function to stop and
  2264. // defer further parser to one of its callers when it encounters an
  2265. // operator that has a lower precedence than the set it is parsing.
  2266. pp$5.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, forInit) {
  2267. var prec = this.type.binop;
  2268. if (prec != null && (!forInit || this.type !== types$1._in)) {
  2269. if (prec > minPrec) {
  2270. var logical = this.type === types$1.logicalOR || this.type === types$1.logicalAND;
  2271. var coalesce = this.type === types$1.coalesce;
  2272. if (coalesce) {
  2273. // Handle the precedence of `tt.coalesce` as equal to the range of logical expressions.
  2274. // In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error.
  2275. prec = types$1.logicalAND.binop;
  2276. }
  2277. var op = this.value;
  2278. this.next();
  2279. var startPos = this.start, startLoc = this.startLoc;
  2280. var right = this.parseExprOp(this.parseMaybeUnary(null, false, false, forInit), startPos, startLoc, prec, forInit);
  2281. var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce);
  2282. if ((logical && this.type === types$1.coalesce) || (coalesce && (this.type === types$1.logicalOR || this.type === types$1.logicalAND))) {
  2283. this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");
  2284. }
  2285. return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, forInit)
  2286. }
  2287. }
  2288. return left
  2289. };
  2290. pp$5.buildBinary = function(startPos, startLoc, left, right, op, logical) {
  2291. if (right.type === "PrivateIdentifier") { this.raise(right.start, "Private identifier can only be left side of binary expression"); }
  2292. var node = this.startNodeAt(startPos, startLoc);
  2293. node.left = left;
  2294. node.operator = op;
  2295. node.right = right;
  2296. return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression")
  2297. };
  2298. // Parse unary operators, both prefix and postfix.
  2299. pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forInit) {
  2300. var startPos = this.start, startLoc = this.startLoc, expr;
  2301. if (this.isContextual("await") && this.canAwait) {
  2302. expr = this.parseAwait(forInit);
  2303. sawUnary = true;
  2304. } else if (this.type.prefix) {
  2305. var node = this.startNode(), update = this.type === types$1.incDec;
  2306. node.operator = this.value;
  2307. node.prefix = true;
  2308. this.next();
  2309. node.argument = this.parseMaybeUnary(null, true, update, forInit);
  2310. this.checkExpressionErrors(refDestructuringErrors, true);
  2311. if (update) { this.checkLValSimple(node.argument); }
  2312. else if (this.strict && node.operator === "delete" &&
  2313. node.argument.type === "Identifier")
  2314. { this.raiseRecoverable(node.start, "Deleting local variable in strict mode"); }
  2315. else if (node.operator === "delete" && isPrivateFieldAccess(node.argument))
  2316. { this.raiseRecoverable(node.start, "Private fields can not be deleted"); }
  2317. else { sawUnary = true; }
  2318. expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
  2319. } else if (!sawUnary && this.type === types$1.privateId) {
  2320. if ((forInit || this.privateNameStack.length === 0) && this.options.checkPrivateFields) { this.unexpected(); }
  2321. expr = this.parsePrivateIdent();
  2322. // only could be private fields in 'in', such as #x in obj
  2323. if (this.type !== types$1._in) { this.unexpected(); }
  2324. } else {
  2325. expr = this.parseExprSubscripts(refDestructuringErrors, forInit);
  2326. if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
  2327. while (this.type.postfix && !this.canInsertSemicolon()) {
  2328. var node$1 = this.startNodeAt(startPos, startLoc);
  2329. node$1.operator = this.value;
  2330. node$1.prefix = false;
  2331. node$1.argument = expr;
  2332. this.checkLValSimple(expr);
  2333. this.next();
  2334. expr = this.finishNode(node$1, "UpdateExpression");
  2335. }
  2336. }
  2337. if (!incDec && this.eat(types$1.starstar)) {
  2338. if (sawUnary)
  2339. { this.unexpected(this.lastTokStart); }
  2340. else
  2341. { return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false, false, forInit), "**", false) }
  2342. } else {
  2343. return expr
  2344. }
  2345. };
  2346. function isPrivateFieldAccess(node) {
  2347. return (
  2348. node.type === "MemberExpression" && node.property.type === "PrivateIdentifier" ||
  2349. node.type === "ChainExpression" && isPrivateFieldAccess(node.expression)
  2350. )
  2351. }
  2352. // Parse call, dot, and `[]`-subscript expressions.
  2353. pp$5.parseExprSubscripts = function(refDestructuringErrors, forInit) {
  2354. var startPos = this.start, startLoc = this.startLoc;
  2355. var expr = this.parseExprAtom(refDestructuringErrors, forInit);
  2356. if (expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")")
  2357. { return expr }
  2358. var result = this.parseSubscripts(expr, startPos, startLoc, false, forInit);
  2359. if (refDestructuringErrors && result.type === "MemberExpression") {
  2360. if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; }
  2361. if (refDestructuringErrors.parenthesizedBind >= result.start) { refDestructuringErrors.parenthesizedBind = -1; }
  2362. if (refDestructuringErrors.trailingComma >= result.start) { refDestructuringErrors.trailingComma = -1; }
  2363. }
  2364. return result
  2365. };
  2366. pp$5.parseSubscripts = function(base, startPos, startLoc, noCalls, forInit) {
  2367. var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" &&
  2368. this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 &&
  2369. this.potentialArrowAt === base.start;
  2370. var optionalChained = false;
  2371. while (true) {
  2372. var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit);
  2373. if (element.optional) { optionalChained = true; }
  2374. if (element === base || element.type === "ArrowFunctionExpression") {
  2375. if (optionalChained) {
  2376. var chainNode = this.startNodeAt(startPos, startLoc);
  2377. chainNode.expression = element;
  2378. element = this.finishNode(chainNode, "ChainExpression");
  2379. }
  2380. return element
  2381. }
  2382. base = element;
  2383. }
  2384. };
  2385. pp$5.shouldParseAsyncArrow = function() {
  2386. return !this.canInsertSemicolon() && this.eat(types$1.arrow)
  2387. };
  2388. pp$5.parseSubscriptAsyncArrow = function(startPos, startLoc, exprList, forInit) {
  2389. return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true, forInit)
  2390. };
  2391. pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit) {
  2392. var optionalSupported = this.options.ecmaVersion >= 11;
  2393. var optional = optionalSupported && this.eat(types$1.questionDot);
  2394. if (noCalls && optional) { this.raise(this.lastTokStart, "Optional chaining cannot appear in the callee of new expressions"); }
  2395. var computed = this.eat(types$1.bracketL);
  2396. if (computed || (optional && this.type !== types$1.parenL && this.type !== types$1.backQuote) || this.eat(types$1.dot)) {
  2397. var node = this.startNodeAt(startPos, startLoc);
  2398. node.object = base;
  2399. if (computed) {
  2400. node.property = this.parseExpression();
  2401. this.expect(types$1.bracketR);
  2402. } else if (this.type === types$1.privateId && base.type !== "Super") {
  2403. node.property = this.parsePrivateIdent();
  2404. } else {
  2405. node.property = this.parseIdent(this.options.allowReserved !== "never");
  2406. }
  2407. node.computed = !!computed;
  2408. if (optionalSupported) {
  2409. node.optional = optional;
  2410. }
  2411. base = this.finishNode(node, "MemberExpression");
  2412. } else if (!noCalls && this.eat(types$1.parenL)) {
  2413. var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
  2414. this.yieldPos = 0;
  2415. this.awaitPos = 0;
  2416. this.awaitIdentPos = 0;
  2417. var exprList = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors);
  2418. if (maybeAsyncArrow && !optional && this.shouldParseAsyncArrow()) {
  2419. this.checkPatternErrors(refDestructuringErrors, false);
  2420. this.checkYieldAwaitInDefaultParams();
  2421. if (this.awaitIdentPos > 0)
  2422. { this.raise(this.awaitIdentPos, "Cannot use 'await' as identifier inside an async function"); }
  2423. this.yieldPos = oldYieldPos;
  2424. this.awaitPos = oldAwaitPos;
  2425. this.awaitIdentPos = oldAwaitIdentPos;
  2426. return this.parseSubscriptAsyncArrow(startPos, startLoc, exprList, forInit)
  2427. }
  2428. this.checkExpressionErrors(refDestructuringErrors, true);
  2429. this.yieldPos = oldYieldPos || this.yieldPos;
  2430. this.awaitPos = oldAwaitPos || this.awaitPos;
  2431. this.awaitIdentPos = oldAwaitIdentPos || this.awaitIdentPos;
  2432. var node$1 = this.startNodeAt(startPos, startLoc);
  2433. node$1.callee = base;
  2434. node$1.arguments = exprList;
  2435. if (optionalSupported) {
  2436. node$1.optional = optional;
  2437. }
  2438. base = this.finishNode(node$1, "CallExpression");
  2439. } else if (this.type === types$1.backQuote) {
  2440. if (optional || optionalChained) {
  2441. this.raise(this.start, "Optional chaining cannot appear in the tag of tagged template expressions");
  2442. }
  2443. var node$2 = this.startNodeAt(startPos, startLoc);
  2444. node$2.tag = base;
  2445. node$2.quasi = this.parseTemplate({isTagged: true});
  2446. base = this.finishNode(node$2, "TaggedTemplateExpression");
  2447. }
  2448. return base
  2449. };
  2450. // Parse an atomic expression — either a single token that is an
  2451. // expression, an expression started by a keyword like `function` or
  2452. // `new`, or an expression wrapped in punctuation like `()`, `[]`,
  2453. // or `{}`.
  2454. pp$5.parseExprAtom = function(refDestructuringErrors, forInit, forNew) {
  2455. // If a division operator appears in an expression position, the
  2456. // tokenizer got confused, and we force it to read a regexp instead.
  2457. if (this.type === types$1.slash) { this.readRegexp(); }
  2458. var node, canBeArrow = this.potentialArrowAt === this.start;
  2459. switch (this.type) {
  2460. case types$1._super:
  2461. if (!this.allowSuper)
  2462. { this.raise(this.start, "'super' keyword outside a method"); }
  2463. node = this.startNode();
  2464. this.next();
  2465. if (this.type === types$1.parenL && !this.allowDirectSuper)
  2466. { this.raise(node.start, "super() call outside constructor of a subclass"); }
  2467. // The `super` keyword can appear at below:
  2468. // SuperProperty:
  2469. // super [ Expression ]
  2470. // super . IdentifierName
  2471. // SuperCall:
  2472. // super ( Arguments )
  2473. if (this.type !== types$1.dot && this.type !== types$1.bracketL && this.type !== types$1.parenL)
  2474. { this.unexpected(); }
  2475. return this.finishNode(node, "Super")
  2476. case types$1._this:
  2477. node = this.startNode();
  2478. this.next();
  2479. return this.finishNode(node, "ThisExpression")
  2480. case types$1.name:
  2481. var startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc;
  2482. var id = this.parseIdent(false);
  2483. if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types$1._function)) {
  2484. this.overrideContext(types.f_expr);
  2485. return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true, forInit)
  2486. }
  2487. if (canBeArrow && !this.canInsertSemicolon()) {
  2488. if (this.eat(types$1.arrow))
  2489. { return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false, forInit) }
  2490. if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types$1.name && !containsEsc &&
  2491. (!this.potentialArrowInForAwait || this.value !== "of" || this.containsEsc)) {
  2492. id = this.parseIdent(false);
  2493. if (this.canInsertSemicolon() || !this.eat(types$1.arrow))
  2494. { this.unexpected(); }
  2495. return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true, forInit)
  2496. }
  2497. }
  2498. return id
  2499. case types$1.regexp:
  2500. var value = this.value;
  2501. node = this.parseLiteral(value.value);
  2502. node.regex = {pattern: value.pattern, flags: value.flags};
  2503. return node
  2504. case types$1.num: case types$1.string:
  2505. return this.parseLiteral(this.value)
  2506. case types$1._null: case types$1._true: case types$1._false:
  2507. node = this.startNode();
  2508. node.value = this.type === types$1._null ? null : this.type === types$1._true;
  2509. node.raw = this.type.keyword;
  2510. this.next();
  2511. return this.finishNode(node, "Literal")
  2512. case types$1.parenL:
  2513. var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow, forInit);
  2514. if (refDestructuringErrors) {
  2515. if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr))
  2516. { refDestructuringErrors.parenthesizedAssign = start; }
  2517. if (refDestructuringErrors.parenthesizedBind < 0)
  2518. { refDestructuringErrors.parenthesizedBind = start; }
  2519. }
  2520. return expr
  2521. case types$1.bracketL:
  2522. node = this.startNode();
  2523. this.next();
  2524. node.elements = this.parseExprList(types$1.bracketR, true, true, refDestructuringErrors);
  2525. return this.finishNode(node, "ArrayExpression")
  2526. case types$1.braceL:
  2527. this.overrideContext(types.b_expr);
  2528. return this.parseObj(false, refDestructuringErrors)
  2529. case types$1._function:
  2530. node = this.startNode();
  2531. this.next();
  2532. return this.parseFunction(node, 0)
  2533. case types$1._class:
  2534. return this.parseClass(this.startNode(), false)
  2535. case types$1._new:
  2536. return this.parseNew()
  2537. case types$1.backQuote:
  2538. return this.parseTemplate()
  2539. case types$1._import:
  2540. if (this.options.ecmaVersion >= 11) {
  2541. return this.parseExprImport(forNew)
  2542. } else {
  2543. return this.unexpected()
  2544. }
  2545. default:
  2546. return this.parseExprAtomDefault()
  2547. }
  2548. };
  2549. pp$5.parseExprAtomDefault = function() {
  2550. this.unexpected();
  2551. };
  2552. pp$5.parseExprImport = function(forNew) {
  2553. var node = this.startNode();
  2554. // Consume `import` as an identifier for `import.meta`.
  2555. // Because `this.parseIdent(true)` doesn't check escape sequences, it needs the check of `this.containsEsc`.
  2556. if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword import"); }
  2557. var meta = this.parseIdent(true);
  2558. if (this.type === types$1.parenL && !forNew) {
  2559. return this.parseDynamicImport(node)
  2560. } else if (this.type === types$1.dot) {
  2561. node.meta = meta;
  2562. return this.parseImportMeta(node)
  2563. } else {
  2564. this.unexpected();
  2565. }
  2566. };
  2567. pp$5.parseDynamicImport = function(node) {
  2568. this.next(); // skip `(`
  2569. // Parse node.source.
  2570. node.source = this.parseMaybeAssign();
  2571. // Verify ending.
  2572. if (!this.eat(types$1.parenR)) {
  2573. var errorPos = this.start;
  2574. if (this.eat(types$1.comma) && this.eat(types$1.parenR)) {
  2575. this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()");
  2576. } else {
  2577. this.unexpected(errorPos);
  2578. }
  2579. }
  2580. return this.finishNode(node, "ImportExpression")
  2581. };
  2582. pp$5.parseImportMeta = function(node) {
  2583. this.next(); // skip `.`
  2584. var containsEsc = this.containsEsc;
  2585. node.property = this.parseIdent(true);
  2586. if (node.property.name !== "meta")
  2587. { this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'"); }
  2588. if (containsEsc)
  2589. { this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters"); }
  2590. if (this.options.sourceType !== "module" && !this.options.allowImportExportEverywhere)
  2591. { this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module"); }
  2592. return this.finishNode(node, "MetaProperty")
  2593. };
  2594. pp$5.parseLiteral = function(value) {
  2595. var node = this.startNode();
  2596. node.value = value;
  2597. node.raw = this.input.slice(this.start, this.end);
  2598. if (node.raw.charCodeAt(node.raw.length - 1) === 110) { node.bigint = node.raw.slice(0, -1).replace(/_/g, ""); }
  2599. this.next();
  2600. return this.finishNode(node, "Literal")
  2601. };
  2602. pp$5.parseParenExpression = function() {
  2603. this.expect(types$1.parenL);
  2604. var val = this.parseExpression();
  2605. this.expect(types$1.parenR);
  2606. return val
  2607. };
  2608. pp$5.shouldParseArrow = function(exprList) {
  2609. return !this.canInsertSemicolon()
  2610. };
  2611. pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) {
  2612. var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8;
  2613. if (this.options.ecmaVersion >= 6) {
  2614. this.next();
  2615. var innerStartPos = this.start, innerStartLoc = this.startLoc;
  2616. var exprList = [], first = true, lastIsComma = false;
  2617. var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart;
  2618. this.yieldPos = 0;
  2619. this.awaitPos = 0;
  2620. // Do not save awaitIdentPos to allow checking awaits nested in parameters
  2621. while (this.type !== types$1.parenR) {
  2622. first ? first = false : this.expect(types$1.comma);
  2623. if (allowTrailingComma && this.afterTrailingComma(types$1.parenR, true)) {
  2624. lastIsComma = true;
  2625. break
  2626. } else if (this.type === types$1.ellipsis) {
  2627. spreadStart = this.start;
  2628. exprList.push(this.parseParenItem(this.parseRestBinding()));
  2629. if (this.type === types$1.comma) {
  2630. this.raiseRecoverable(
  2631. this.start,
  2632. "Comma is not permitted after the rest element"
  2633. );
  2634. }
  2635. break
  2636. } else {
  2637. exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem));
  2638. }
  2639. }
  2640. var innerEndPos = this.lastTokEnd, innerEndLoc = this.lastTokEndLoc;
  2641. this.expect(types$1.parenR);
  2642. if (canBeArrow && this.shouldParseArrow(exprList) && this.eat(types$1.arrow)) {
  2643. this.checkPatternErrors(refDestructuringErrors, false);
  2644. this.checkYieldAwaitInDefaultParams();
  2645. this.yieldPos = oldYieldPos;
  2646. this.awaitPos = oldAwaitPos;
  2647. return this.parseParenArrowList(startPos, startLoc, exprList, forInit)
  2648. }
  2649. if (!exprList.length || lastIsComma) { this.unexpected(this.lastTokStart); }
  2650. if (spreadStart) { this.unexpected(spreadStart); }
  2651. this.checkExpressionErrors(refDestructuringErrors, true);
  2652. this.yieldPos = oldYieldPos || this.yieldPos;
  2653. this.awaitPos = oldAwaitPos || this.awaitPos;
  2654. if (exprList.length > 1) {
  2655. val = this.startNodeAt(innerStartPos, innerStartLoc);
  2656. val.expressions = exprList;
  2657. this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);
  2658. } else {
  2659. val = exprList[0];
  2660. }
  2661. } else {
  2662. val = this.parseParenExpression();
  2663. }
  2664. if (this.options.preserveParens) {
  2665. var par = this.startNodeAt(startPos, startLoc);
  2666. par.expression = val;
  2667. return this.finishNode(par, "ParenthesizedExpression")
  2668. } else {
  2669. return val
  2670. }
  2671. };
  2672. pp$5.parseParenItem = function(item) {
  2673. return item
  2674. };
  2675. pp$5.parseParenArrowList = function(startPos, startLoc, exprList, forInit) {
  2676. return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, false, forInit)
  2677. };
  2678. // New's precedence is slightly tricky. It must allow its argument to
  2679. // be a `[]` or dot subscript expression, but not a call — at least,
  2680. // not without wrapping it in parentheses. Thus, it uses the noCalls
  2681. // argument to parseSubscripts to prevent it from consuming the
  2682. // argument list.
  2683. var empty = [];
  2684. pp$5.parseNew = function() {
  2685. if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword new"); }
  2686. var node = this.startNode();
  2687. var meta = this.parseIdent(true);
  2688. if (this.options.ecmaVersion >= 6 && this.eat(types$1.dot)) {
  2689. node.meta = meta;
  2690. var containsEsc = this.containsEsc;
  2691. node.property = this.parseIdent(true);
  2692. if (node.property.name !== "target")
  2693. { this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'"); }
  2694. if (containsEsc)
  2695. { this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters"); }
  2696. if (!this.allowNewDotTarget)
  2697. { this.raiseRecoverable(node.start, "'new.target' can only be used in functions and class static block"); }
  2698. return this.finishNode(node, "MetaProperty")
  2699. }
  2700. var startPos = this.start, startLoc = this.startLoc;
  2701. node.callee = this.parseSubscripts(this.parseExprAtom(null, false, true), startPos, startLoc, true, false);
  2702. if (this.eat(types$1.parenL)) { node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false); }
  2703. else { node.arguments = empty; }
  2704. return this.finishNode(node, "NewExpression")
  2705. };
  2706. // Parse template expression.
  2707. pp$5.parseTemplateElement = function(ref) {
  2708. var isTagged = ref.isTagged;
  2709. var elem = this.startNode();
  2710. if (this.type === types$1.invalidTemplate) {
  2711. if (!isTagged) {
  2712. this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
  2713. }
  2714. elem.value = {
  2715. raw: this.value,
  2716. cooked: null
  2717. };
  2718. } else {
  2719. elem.value = {
  2720. raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"),
  2721. cooked: this.value
  2722. };
  2723. }
  2724. this.next();
  2725. elem.tail = this.type === types$1.backQuote;
  2726. return this.finishNode(elem, "TemplateElement")
  2727. };
  2728. pp$5.parseTemplate = function(ref) {
  2729. if ( ref === void 0 ) ref = {};
  2730. var isTagged = ref.isTagged; if ( isTagged === void 0 ) isTagged = false;
  2731. var node = this.startNode();
  2732. this.next();
  2733. node.expressions = [];
  2734. var curElt = this.parseTemplateElement({isTagged: isTagged});
  2735. node.quasis = [curElt];
  2736. while (!curElt.tail) {
  2737. if (this.type === types$1.eof) { this.raise(this.pos, "Unterminated template literal"); }
  2738. this.expect(types$1.dollarBraceL);
  2739. node.expressions.push(this.parseExpression());
  2740. this.expect(types$1.braceR);
  2741. node.quasis.push(curElt = this.parseTemplateElement({isTagged: isTagged}));
  2742. }
  2743. this.next();
  2744. return this.finishNode(node, "TemplateLiteral")
  2745. };
  2746. pp$5.isAsyncProp = function(prop) {
  2747. return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" &&
  2748. (this.type === types$1.name || this.type === types$1.num || this.type === types$1.string || this.type === types$1.bracketL || this.type.keyword || (this.options.ecmaVersion >= 9 && this.type === types$1.star)) &&
  2749. !lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
  2750. };
  2751. // Parse an object literal or binding pattern.
  2752. pp$5.parseObj = function(isPattern, refDestructuringErrors) {
  2753. var node = this.startNode(), first = true, propHash = {};
  2754. node.properties = [];
  2755. this.next();
  2756. while (!this.eat(types$1.braceR)) {
  2757. if (!first) {
  2758. this.expect(types$1.comma);
  2759. if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types$1.braceR)) { break }
  2760. } else { first = false; }
  2761. var prop = this.parseProperty(isPattern, refDestructuringErrors);
  2762. if (!isPattern) { this.checkPropClash(prop, propHash, refDestructuringErrors); }
  2763. node.properties.push(prop);
  2764. }
  2765. return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression")
  2766. };
  2767. pp$5.parseProperty = function(isPattern, refDestructuringErrors) {
  2768. var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc;
  2769. if (this.options.ecmaVersion >= 9 && this.eat(types$1.ellipsis)) {
  2770. if (isPattern) {
  2771. prop.argument = this.parseIdent(false);
  2772. if (this.type === types$1.comma) {
  2773. this.raiseRecoverable(this.start, "Comma is not permitted after the rest element");
  2774. }
  2775. return this.finishNode(prop, "RestElement")
  2776. }
  2777. // Parse argument.
  2778. prop.argument = this.parseMaybeAssign(false, refDestructuringErrors);
  2779. // To disallow trailing comma via `this.toAssignable()`.
  2780. if (this.type === types$1.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) {
  2781. refDestructuringErrors.trailingComma = this.start;
  2782. }
  2783. // Finish
  2784. return this.finishNode(prop, "SpreadElement")
  2785. }
  2786. if (this.options.ecmaVersion >= 6) {
  2787. prop.method = false;
  2788. prop.shorthand = false;
  2789. if (isPattern || refDestructuringErrors) {
  2790. startPos = this.start;
  2791. startLoc = this.startLoc;
  2792. }
  2793. if (!isPattern)
  2794. { isGenerator = this.eat(types$1.star); }
  2795. }
  2796. var containsEsc = this.containsEsc;
  2797. this.parsePropertyName(prop);
  2798. if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {
  2799. isAsync = true;
  2800. isGenerator = this.options.ecmaVersion >= 9 && this.eat(types$1.star);
  2801. this.parsePropertyName(prop);
  2802. } else {
  2803. isAsync = false;
  2804. }
  2805. this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc);
  2806. return this.finishNode(prop, "Property")
  2807. };
  2808. pp$5.parseGetterSetter = function(prop) {
  2809. prop.kind = prop.key.name;
  2810. this.parsePropertyName(prop);
  2811. prop.value = this.parseMethod(false);
  2812. var paramCount = prop.kind === "get" ? 0 : 1;
  2813. if (prop.value.params.length !== paramCount) {
  2814. var start = prop.value.start;
  2815. if (prop.kind === "get")
  2816. { this.raiseRecoverable(start, "getter should have no params"); }
  2817. else
  2818. { this.raiseRecoverable(start, "setter should have exactly one param"); }
  2819. } else {
  2820. if (prop.kind === "set" && prop.value.params[0].type === "RestElement")
  2821. { this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params"); }
  2822. }
  2823. };
  2824. pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {
  2825. if ((isGenerator || isAsync) && this.type === types$1.colon)
  2826. { this.unexpected(); }
  2827. if (this.eat(types$1.colon)) {
  2828. prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors);
  2829. prop.kind = "init";
  2830. } else if (this.options.ecmaVersion >= 6 && this.type === types$1.parenL) {
  2831. if (isPattern) { this.unexpected(); }
  2832. prop.kind = "init";
  2833. prop.method = true;
  2834. prop.value = this.parseMethod(isGenerator, isAsync);
  2835. } else if (!isPattern && !containsEsc &&
  2836. this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
  2837. (prop.key.name === "get" || prop.key.name === "set") &&
  2838. (this.type !== types$1.comma && this.type !== types$1.braceR && this.type !== types$1.eq)) {
  2839. if (isGenerator || isAsync) { this.unexpected(); }
  2840. this.parseGetterSetter(prop);
  2841. } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
  2842. if (isGenerator || isAsync) { this.unexpected(); }
  2843. this.checkUnreserved(prop.key);
  2844. if (prop.key.name === "await" && !this.awaitIdentPos)
  2845. { this.awaitIdentPos = startPos; }
  2846. prop.kind = "init";
  2847. if (isPattern) {
  2848. prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));
  2849. } else if (this.type === types$1.eq && refDestructuringErrors) {
  2850. if (refDestructuringErrors.shorthandAssign < 0)
  2851. { refDestructuringErrors.shorthandAssign = this.start; }
  2852. prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));
  2853. } else {
  2854. prop.value = this.copyNode(prop.key);
  2855. }
  2856. prop.shorthand = true;
  2857. } else { this.unexpected(); }
  2858. };
  2859. pp$5.parsePropertyName = function(prop) {
  2860. if (this.options.ecmaVersion >= 6) {
  2861. if (this.eat(types$1.bracketL)) {
  2862. prop.computed = true;
  2863. prop.key = this.parseMaybeAssign();
  2864. this.expect(types$1.bracketR);
  2865. return prop.key
  2866. } else {
  2867. prop.computed = false;
  2868. }
  2869. }
  2870. return prop.key = this.type === types$1.num || this.type === types$1.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never")
  2871. };
  2872. // Initialize empty function node.
  2873. pp$5.initFunction = function(node) {
  2874. node.id = null;
  2875. if (this.options.ecmaVersion >= 6) { node.generator = node.expression = false; }
  2876. if (this.options.ecmaVersion >= 8) { node.async = false; }
  2877. };
  2878. // Parse object or class method.
  2879. pp$5.parseMethod = function(isGenerator, isAsync, allowDirectSuper) {
  2880. var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
  2881. this.initFunction(node);
  2882. if (this.options.ecmaVersion >= 6)
  2883. { node.generator = isGenerator; }
  2884. if (this.options.ecmaVersion >= 8)
  2885. { node.async = !!isAsync; }
  2886. this.yieldPos = 0;
  2887. this.awaitPos = 0;
  2888. this.awaitIdentPos = 0;
  2889. this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));
  2890. this.expect(types$1.parenL);
  2891. node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8);
  2892. this.checkYieldAwaitInDefaultParams();
  2893. this.parseFunctionBody(node, false, true, false);
  2894. this.yieldPos = oldYieldPos;
  2895. this.awaitPos = oldAwaitPos;
  2896. this.awaitIdentPos = oldAwaitIdentPos;
  2897. return this.finishNode(node, "FunctionExpression")
  2898. };
  2899. // Parse arrow function expression with given parameters.
  2900. pp$5.parseArrowExpression = function(node, params, isAsync, forInit) {
  2901. var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
  2902. this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW);
  2903. this.initFunction(node);
  2904. if (this.options.ecmaVersion >= 8) { node.async = !!isAsync; }
  2905. this.yieldPos = 0;
  2906. this.awaitPos = 0;
  2907. this.awaitIdentPos = 0;
  2908. node.params = this.toAssignableList(params, true);
  2909. this.parseFunctionBody(node, true, false, forInit);
  2910. this.yieldPos = oldYieldPos;
  2911. this.awaitPos = oldAwaitPos;
  2912. this.awaitIdentPos = oldAwaitIdentPos;
  2913. return this.finishNode(node, "ArrowFunctionExpression")
  2914. };
  2915. // Parse function body and check parameters.
  2916. pp$5.parseFunctionBody = function(node, isArrowFunction, isMethod, forInit) {
  2917. var isExpression = isArrowFunction && this.type !== types$1.braceL;
  2918. var oldStrict = this.strict, useStrict = false;
  2919. if (isExpression) {
  2920. node.body = this.parseMaybeAssign(forInit);
  2921. node.expression = true;
  2922. this.checkParams(node, false);
  2923. } else {
  2924. var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params);
  2925. if (!oldStrict || nonSimple) {
  2926. useStrict = this.strictDirective(this.end);
  2927. // If this is a strict mode function, verify that argument names
  2928. // are not repeated, and it does not try to bind the words `eval`
  2929. // or `arguments`.
  2930. if (useStrict && nonSimple)
  2931. { this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list"); }
  2932. }
  2933. // Start a new scope with regard to labels and the `inFunction`
  2934. // flag (restore them to their old value afterwards).
  2935. var oldLabels = this.labels;
  2936. this.labels = [];
  2937. if (useStrict) { this.strict = true; }
  2938. // Add the params to varDeclaredNames to ensure that an error is thrown
  2939. // if a let/const declaration in the function clashes with one of the params.
  2940. this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params));
  2941. // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'
  2942. if (this.strict && node.id) { this.checkLValSimple(node.id, BIND_OUTSIDE); }
  2943. node.body = this.parseBlock(false, undefined, useStrict && !oldStrict);
  2944. node.expression = false;
  2945. this.adaptDirectivePrologue(node.body.body);
  2946. this.labels = oldLabels;
  2947. }
  2948. this.exitScope();
  2949. };
  2950. pp$5.isSimpleParamList = function(params) {
  2951. for (var i = 0, list = params; i < list.length; i += 1)
  2952. {
  2953. var param = list[i];
  2954. if (param.type !== "Identifier") { return false
  2955. } }
  2956. return true
  2957. };
  2958. // Checks function params for various disallowed patterns such as using "eval"
  2959. // or "arguments" and duplicate parameters.
  2960. pp$5.checkParams = function(node, allowDuplicates) {
  2961. var nameHash = Object.create(null);
  2962. for (var i = 0, list = node.params; i < list.length; i += 1)
  2963. {
  2964. var param = list[i];
  2965. this.checkLValInnerPattern(param, BIND_VAR, allowDuplicates ? null : nameHash);
  2966. }
  2967. };
  2968. // Parses a comma-separated list of expressions, and returns them as
  2969. // an array. `close` is the token type that ends the list, and
  2970. // `allowEmpty` can be turned on to allow subsequent commas with
  2971. // nothing in between them to be parsed as `null` (which is needed
  2972. // for array literals).
  2973. pp$5.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) {
  2974. var elts = [], first = true;
  2975. while (!this.eat(close)) {
  2976. if (!first) {
  2977. this.expect(types$1.comma);
  2978. if (allowTrailingComma && this.afterTrailingComma(close)) { break }
  2979. } else { first = false; }
  2980. var elt = (void 0);
  2981. if (allowEmpty && this.type === types$1.comma)
  2982. { elt = null; }
  2983. else if (this.type === types$1.ellipsis) {
  2984. elt = this.parseSpread(refDestructuringErrors);
  2985. if (refDestructuringErrors && this.type === types$1.comma && refDestructuringErrors.trailingComma < 0)
  2986. { refDestructuringErrors.trailingComma = this.start; }
  2987. } else {
  2988. elt = this.parseMaybeAssign(false, refDestructuringErrors);
  2989. }
  2990. elts.push(elt);
  2991. }
  2992. return elts
  2993. };
  2994. pp$5.checkUnreserved = function(ref) {
  2995. var start = ref.start;
  2996. var end = ref.end;
  2997. var name = ref.name;
  2998. if (this.inGenerator && name === "yield")
  2999. { this.raiseRecoverable(start, "Cannot use 'yield' as identifier inside a generator"); }
  3000. if (this.inAsync && name === "await")
  3001. { this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function"); }
  3002. if (this.currentThisScope().inClassFieldInit && name === "arguments")
  3003. { this.raiseRecoverable(start, "Cannot use 'arguments' in class field initializer"); }
  3004. if (this.inClassStaticBlock && (name === "arguments" || name === "await"))
  3005. { this.raise(start, ("Cannot use " + name + " in class static initialization block")); }
  3006. if (this.keywords.test(name))
  3007. { this.raise(start, ("Unexpected keyword '" + name + "'")); }
  3008. if (this.options.ecmaVersion < 6 &&
  3009. this.input.slice(start, end).indexOf("\\") !== -1) { return }
  3010. var re = this.strict ? this.reservedWordsStrict : this.reservedWords;
  3011. if (re.test(name)) {
  3012. if (!this.inAsync && name === "await")
  3013. { this.raiseRecoverable(start, "Cannot use keyword 'await' outside an async function"); }
  3014. this.raiseRecoverable(start, ("The keyword '" + name + "' is reserved"));
  3015. }
  3016. };
  3017. // Parse the next token as an identifier. If `liberal` is true (used
  3018. // when parsing properties), it will also convert keywords into
  3019. // identifiers.
  3020. pp$5.parseIdent = function(liberal) {
  3021. var node = this.parseIdentNode();
  3022. this.next(!!liberal);
  3023. this.finishNode(node, "Identifier");
  3024. if (!liberal) {
  3025. this.checkUnreserved(node);
  3026. if (node.name === "await" && !this.awaitIdentPos)
  3027. { this.awaitIdentPos = node.start; }
  3028. }
  3029. return node
  3030. };
  3031. pp$5.parseIdentNode = function() {
  3032. var node = this.startNode();
  3033. if (this.type === types$1.name) {
  3034. node.name = this.value;
  3035. } else if (this.type.keyword) {
  3036. node.name = this.type.keyword;
  3037. // To fix https://github.com/acornjs/acorn/issues/575
  3038. // `class` and `function` keywords push new context into this.context.
  3039. // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.
  3040. // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword
  3041. if ((node.name === "class" || node.name === "function") &&
  3042. (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
  3043. this.context.pop();
  3044. }
  3045. } else {
  3046. this.unexpected();
  3047. }
  3048. return node
  3049. };
  3050. pp$5.parsePrivateIdent = function() {
  3051. var node = this.startNode();
  3052. if (this.type === types$1.privateId) {
  3053. node.name = this.value;
  3054. } else {
  3055. this.unexpected();
  3056. }
  3057. this.next();
  3058. this.finishNode(node, "PrivateIdentifier");
  3059. // For validating existence
  3060. if (this.options.checkPrivateFields) {
  3061. if (this.privateNameStack.length === 0) {
  3062. this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class"));
  3063. } else {
  3064. this.privateNameStack[this.privateNameStack.length - 1].used.push(node);
  3065. }
  3066. }
  3067. return node
  3068. };
  3069. // Parses yield expression inside generator.
  3070. pp$5.parseYield = function(forInit) {
  3071. if (!this.yieldPos) { this.yieldPos = this.start; }
  3072. var node = this.startNode();
  3073. this.next();
  3074. if (this.type === types$1.semi || this.canInsertSemicolon() || (this.type !== types$1.star && !this.type.startsExpr)) {
  3075. node.delegate = false;
  3076. node.argument = null;
  3077. } else {
  3078. node.delegate = this.eat(types$1.star);
  3079. node.argument = this.parseMaybeAssign(forInit);
  3080. }
  3081. return this.finishNode(node, "YieldExpression")
  3082. };
  3083. pp$5.parseAwait = function(forInit) {
  3084. if (!this.awaitPos) { this.awaitPos = this.start; }
  3085. var node = this.startNode();
  3086. this.next();
  3087. node.argument = this.parseMaybeUnary(null, true, false, forInit);
  3088. return this.finishNode(node, "AwaitExpression")
  3089. };
  3090. var pp$4 = Parser.prototype;
  3091. // This function is used to raise exceptions on parse errors. It
  3092. // takes an offset integer (into the current `input`) to indicate
  3093. // the location of the error, attaches the position to the end
  3094. // of the error message, and then raises a `SyntaxError` with that
  3095. // message.
  3096. pp$4.raise = function(pos, message) {
  3097. var loc = getLineInfo(this.input, pos);
  3098. message += " (" + loc.line + ":" + loc.column + ")";
  3099. var err = new SyntaxError(message);
  3100. err.pos = pos; err.loc = loc; err.raisedAt = this.pos;
  3101. throw err
  3102. };
  3103. pp$4.raiseRecoverable = pp$4.raise;
  3104. pp$4.curPosition = function() {
  3105. if (this.options.locations) {
  3106. return new Position(this.curLine, this.pos - this.lineStart)
  3107. }
  3108. };
  3109. var pp$3 = Parser.prototype;
  3110. var Scope = function Scope(flags) {
  3111. this.flags = flags;
  3112. // A list of var-declared names in the current lexical scope
  3113. this.var = [];
  3114. // A list of lexically-declared names in the current lexical scope
  3115. this.lexical = [];
  3116. // A list of lexically-declared FunctionDeclaration names in the current lexical scope
  3117. this.functions = [];
  3118. // A switch to disallow the identifier reference 'arguments'
  3119. this.inClassFieldInit = false;
  3120. };
  3121. // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names.
  3122. pp$3.enterScope = function(flags) {
  3123. this.scopeStack.push(new Scope(flags));
  3124. };
  3125. pp$3.exitScope = function() {
  3126. this.scopeStack.pop();
  3127. };
  3128. // The spec says:
  3129. // > At the top level of a function, or script, function declarations are
  3130. // > treated like var declarations rather than like lexical declarations.
  3131. pp$3.treatFunctionsAsVarInScope = function(scope) {
  3132. return (scope.flags & SCOPE_FUNCTION) || !this.inModule && (scope.flags & SCOPE_TOP)
  3133. };
  3134. pp$3.declareName = function(name, bindingType, pos) {
  3135. var redeclared = false;
  3136. if (bindingType === BIND_LEXICAL) {
  3137. var scope = this.currentScope();
  3138. redeclared = scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1;
  3139. scope.lexical.push(name);
  3140. if (this.inModule && (scope.flags & SCOPE_TOP))
  3141. { delete this.undefinedExports[name]; }
  3142. } else if (bindingType === BIND_SIMPLE_CATCH) {
  3143. var scope$1 = this.currentScope();
  3144. scope$1.lexical.push(name);
  3145. } else if (bindingType === BIND_FUNCTION) {
  3146. var scope$2 = this.currentScope();
  3147. if (this.treatFunctionsAsVar)
  3148. { redeclared = scope$2.lexical.indexOf(name) > -1; }
  3149. else
  3150. { redeclared = scope$2.lexical.indexOf(name) > -1 || scope$2.var.indexOf(name) > -1; }
  3151. scope$2.functions.push(name);
  3152. } else {
  3153. for (var i = this.scopeStack.length - 1; i >= 0; --i) {
  3154. var scope$3 = this.scopeStack[i];
  3155. if (scope$3.lexical.indexOf(name) > -1 && !((scope$3.flags & SCOPE_SIMPLE_CATCH) && scope$3.lexical[0] === name) ||
  3156. !this.treatFunctionsAsVarInScope(scope$3) && scope$3.functions.indexOf(name) > -1) {
  3157. redeclared = true;
  3158. break
  3159. }
  3160. scope$3.var.push(name);
  3161. if (this.inModule && (scope$3.flags & SCOPE_TOP))
  3162. { delete this.undefinedExports[name]; }
  3163. if (scope$3.flags & SCOPE_VAR) { break }
  3164. }
  3165. }
  3166. if (redeclared) { this.raiseRecoverable(pos, ("Identifier '" + name + "' has already been declared")); }
  3167. };
  3168. pp$3.checkLocalExport = function(id) {
  3169. // scope.functions must be empty as Module code is always strict.
  3170. if (this.scopeStack[0].lexical.indexOf(id.name) === -1 &&
  3171. this.scopeStack[0].var.indexOf(id.name) === -1) {
  3172. this.undefinedExports[id.name] = id;
  3173. }
  3174. };
  3175. pp$3.currentScope = function() {
  3176. return this.scopeStack[this.scopeStack.length - 1]
  3177. };
  3178. pp$3.currentVarScope = function() {
  3179. for (var i = this.scopeStack.length - 1;; i--) {
  3180. var scope = this.scopeStack[i];
  3181. if (scope.flags & SCOPE_VAR) { return scope }
  3182. }
  3183. };
  3184. // Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`.
  3185. pp$3.currentThisScope = function() {
  3186. for (var i = this.scopeStack.length - 1;; i--) {
  3187. var scope = this.scopeStack[i];
  3188. if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) { return scope }
  3189. }
  3190. };
  3191. var Node = function Node(parser, pos, loc) {
  3192. this.type = "";
  3193. this.start = pos;
  3194. this.end = 0;
  3195. if (parser.options.locations)
  3196. { this.loc = new SourceLocation(parser, loc); }
  3197. if (parser.options.directSourceFile)
  3198. { this.sourceFile = parser.options.directSourceFile; }
  3199. if (parser.options.ranges)
  3200. { this.range = [pos, 0]; }
  3201. };
  3202. // Start an AST node, attaching a start offset.
  3203. var pp$2 = Parser.prototype;
  3204. pp$2.startNode = function() {
  3205. return new Node(this, this.start, this.startLoc)
  3206. };
  3207. pp$2.startNodeAt = function(pos, loc) {
  3208. return new Node(this, pos, loc)
  3209. };
  3210. // Finish an AST node, adding `type` and `end` properties.
  3211. function finishNodeAt(node, type, pos, loc) {
  3212. node.type = type;
  3213. node.end = pos;
  3214. if (this.options.locations)
  3215. { node.loc.end = loc; }
  3216. if (this.options.ranges)
  3217. { node.range[1] = pos; }
  3218. return node
  3219. }
  3220. pp$2.finishNode = function(node, type) {
  3221. return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc)
  3222. };
  3223. // Finish node at given position
  3224. pp$2.finishNodeAt = function(node, type, pos, loc) {
  3225. return finishNodeAt.call(this, node, type, pos, loc)
  3226. };
  3227. pp$2.copyNode = function(node) {
  3228. var newNode = new Node(this, node.start, this.startLoc);
  3229. for (var prop in node) { newNode[prop] = node[prop]; }
  3230. return newNode
  3231. };
  3232. // This file contains Unicode properties extracted from the ECMAScript specification.
  3233. // The lists are extracted like so:
  3234. // $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText)
  3235. // #table-binary-unicode-properties
  3236. var ecma9BinaryProperties = "ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS";
  3237. var ecma10BinaryProperties = ecma9BinaryProperties + " Extended_Pictographic";
  3238. var ecma11BinaryProperties = ecma10BinaryProperties;
  3239. var ecma12BinaryProperties = ecma11BinaryProperties + " EBase EComp EMod EPres ExtPict";
  3240. var ecma13BinaryProperties = ecma12BinaryProperties;
  3241. var ecma14BinaryProperties = ecma13BinaryProperties;
  3242. var unicodeBinaryProperties = {
  3243. 9: ecma9BinaryProperties,
  3244. 10: ecma10BinaryProperties,
  3245. 11: ecma11BinaryProperties,
  3246. 12: ecma12BinaryProperties,
  3247. 13: ecma13BinaryProperties,
  3248. 14: ecma14BinaryProperties
  3249. };
  3250. // #table-binary-unicode-properties-of-strings
  3251. var ecma14BinaryPropertiesOfStrings = "Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji";
  3252. var unicodeBinaryPropertiesOfStrings = {
  3253. 9: "",
  3254. 10: "",
  3255. 11: "",
  3256. 12: "",
  3257. 13: "",
  3258. 14: ecma14BinaryPropertiesOfStrings
  3259. };
  3260. // #table-unicode-general-category-values
  3261. var unicodeGeneralCategoryValues = "Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu";
  3262. // #table-unicode-script-values
  3263. var ecma9ScriptValues = "Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb";
  3264. var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd";
  3265. var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho";
  3266. var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi";
  3267. var ecma13ScriptValues = ecma12ScriptValues + " Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith";
  3268. var ecma14ScriptValues = ecma13ScriptValues + " Hrkt Katakana_Or_Hiragana Kawi Nag_Mundari Nagm Unknown Zzzz";
  3269. var unicodeScriptValues = {
  3270. 9: ecma9ScriptValues,
  3271. 10: ecma10ScriptValues,
  3272. 11: ecma11ScriptValues,
  3273. 12: ecma12ScriptValues,
  3274. 13: ecma13ScriptValues,
  3275. 14: ecma14ScriptValues
  3276. };
  3277. var data = {};
  3278. function buildUnicodeData(ecmaVersion) {
  3279. var d = data[ecmaVersion] = {
  3280. binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues),
  3281. binaryOfStrings: wordsRegexp(unicodeBinaryPropertiesOfStrings[ecmaVersion]),
  3282. nonBinary: {
  3283. General_Category: wordsRegexp(unicodeGeneralCategoryValues),
  3284. Script: wordsRegexp(unicodeScriptValues[ecmaVersion])
  3285. }
  3286. };
  3287. d.nonBinary.Script_Extensions = d.nonBinary.Script;
  3288. d.nonBinary.gc = d.nonBinary.General_Category;
  3289. d.nonBinary.sc = d.nonBinary.Script;
  3290. d.nonBinary.scx = d.nonBinary.Script_Extensions;
  3291. }
  3292. for (var i = 0, list = [9, 10, 11, 12, 13, 14]; i < list.length; i += 1) {
  3293. var ecmaVersion = list[i];
  3294. buildUnicodeData(ecmaVersion);
  3295. }
  3296. var pp$1 = Parser.prototype;
  3297. var RegExpValidationState = function RegExpValidationState(parser) {
  3298. this.parser = parser;
  3299. this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "") + (parser.options.ecmaVersion >= 15 ? "v" : "");
  3300. this.unicodeProperties = data[parser.options.ecmaVersion >= 14 ? 14 : parser.options.ecmaVersion];
  3301. this.source = "";
  3302. this.flags = "";
  3303. this.start = 0;
  3304. this.switchU = false;
  3305. this.switchV = false;
  3306. this.switchN = false;
  3307. this.pos = 0;
  3308. this.lastIntValue = 0;
  3309. this.lastStringValue = "";
  3310. this.lastAssertionIsQuantifiable = false;
  3311. this.numCapturingParens = 0;
  3312. this.maxBackReference = 0;
  3313. this.groupNames = [];
  3314. this.backReferenceNames = [];
  3315. };
  3316. RegExpValidationState.prototype.reset = function reset (start, pattern, flags) {
  3317. var unicodeSets = flags.indexOf("v") !== -1;
  3318. var unicode = flags.indexOf("u") !== -1;
  3319. this.start = start | 0;
  3320. this.source = pattern + "";
  3321. this.flags = flags;
  3322. if (unicodeSets && this.parser.options.ecmaVersion >= 15) {
  3323. this.switchU = true;
  3324. this.switchV = true;
  3325. this.switchN = true;
  3326. } else {
  3327. this.switchU = unicode && this.parser.options.ecmaVersion >= 6;
  3328. this.switchV = false;
  3329. this.switchN = unicode && this.parser.options.ecmaVersion >= 9;
  3330. }
  3331. };
  3332. RegExpValidationState.prototype.raise = function raise (message) {
  3333. this.parser.raiseRecoverable(this.start, ("Invalid regular expression: /" + (this.source) + "/: " + message));
  3334. };
  3335. // If u flag is given, this returns the code point at the index (it combines a surrogate pair).
  3336. // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair).
  3337. RegExpValidationState.prototype.at = function at (i, forceU) {
  3338. if ( forceU === void 0 ) forceU = false;
  3339. var s = this.source;
  3340. var l = s.length;
  3341. if (i >= l) {
  3342. return -1
  3343. }
  3344. var c = s.charCodeAt(i);
  3345. if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {
  3346. return c
  3347. }
  3348. var next = s.charCodeAt(i + 1);
  3349. return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c
  3350. };
  3351. RegExpValidationState.prototype.nextIndex = function nextIndex (i, forceU) {
  3352. if ( forceU === void 0 ) forceU = false;
  3353. var s = this.source;
  3354. var l = s.length;
  3355. if (i >= l) {
  3356. return l
  3357. }
  3358. var c = s.charCodeAt(i), next;
  3359. if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l ||
  3360. (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) {
  3361. return i + 1
  3362. }
  3363. return i + 2
  3364. };
  3365. RegExpValidationState.prototype.current = function current (forceU) {
  3366. if ( forceU === void 0 ) forceU = false;
  3367. return this.at(this.pos, forceU)
  3368. };
  3369. RegExpValidationState.prototype.lookahead = function lookahead (forceU) {
  3370. if ( forceU === void 0 ) forceU = false;
  3371. return this.at(this.nextIndex(this.pos, forceU), forceU)
  3372. };
  3373. RegExpValidationState.prototype.advance = function advance (forceU) {
  3374. if ( forceU === void 0 ) forceU = false;
  3375. this.pos = this.nextIndex(this.pos, forceU);
  3376. };
  3377. RegExpValidationState.prototype.eat = function eat (ch, forceU) {
  3378. if ( forceU === void 0 ) forceU = false;
  3379. if (this.current(forceU) === ch) {
  3380. this.advance(forceU);
  3381. return true
  3382. }
  3383. return false
  3384. };
  3385. RegExpValidationState.prototype.eatChars = function eatChars (chs, forceU) {
  3386. if ( forceU === void 0 ) forceU = false;
  3387. var pos = this.pos;
  3388. for (var i = 0, list = chs; i < list.length; i += 1) {
  3389. var ch = list[i];
  3390. var current = this.at(pos, forceU);
  3391. if (current === -1 || current !== ch) {
  3392. return false
  3393. }
  3394. pos = this.nextIndex(pos, forceU);
  3395. }
  3396. this.pos = pos;
  3397. return true
  3398. };
  3399. /**
  3400. * Validate the flags part of a given RegExpLiteral.
  3401. *
  3402. * @param {RegExpValidationState} state The state to validate RegExp.
  3403. * @returns {void}
  3404. */
  3405. pp$1.validateRegExpFlags = function(state) {
  3406. var validFlags = state.validFlags;
  3407. var flags = state.flags;
  3408. var u = false;
  3409. var v = false;
  3410. for (var i = 0; i < flags.length; i++) {
  3411. var flag = flags.charAt(i);
  3412. if (validFlags.indexOf(flag) === -1) {
  3413. this.raise(state.start, "Invalid regular expression flag");
  3414. }
  3415. if (flags.indexOf(flag, i + 1) > -1) {
  3416. this.raise(state.start, "Duplicate regular expression flag");
  3417. }
  3418. if (flag === "u") { u = true; }
  3419. if (flag === "v") { v = true; }
  3420. }
  3421. if (this.options.ecmaVersion >= 15 && u && v) {
  3422. this.raise(state.start, "Invalid regular expression flag");
  3423. }
  3424. };
  3425. /**
  3426. * Validate the pattern part of a given RegExpLiteral.
  3427. *
  3428. * @param {RegExpValidationState} state The state to validate RegExp.
  3429. * @returns {void}
  3430. */
  3431. pp$1.validateRegExpPattern = function(state) {
  3432. this.regexp_pattern(state);
  3433. // The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of
  3434. // parsing contains a |GroupName|, reparse with the goal symbol
  3435. // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError*
  3436. // exception if _P_ did not conform to the grammar, if any elements of _P_
  3437. // were not matched by the parse, or if any Early Error conditions exist.
  3438. if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {
  3439. state.switchN = true;
  3440. this.regexp_pattern(state);
  3441. }
  3442. };
  3443. // https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern
  3444. pp$1.regexp_pattern = function(state) {
  3445. state.pos = 0;
  3446. state.lastIntValue = 0;
  3447. state.lastStringValue = "";
  3448. state.lastAssertionIsQuantifiable = false;
  3449. state.numCapturingParens = 0;
  3450. state.maxBackReference = 0;
  3451. state.groupNames.length = 0;
  3452. state.backReferenceNames.length = 0;
  3453. this.regexp_disjunction(state);
  3454. if (state.pos !== state.source.length) {
  3455. // Make the same messages as V8.
  3456. if (state.eat(0x29 /* ) */)) {
  3457. state.raise("Unmatched ')'");
  3458. }
  3459. if (state.eat(0x5D /* ] */) || state.eat(0x7D /* } */)) {
  3460. state.raise("Lone quantifier brackets");
  3461. }
  3462. }
  3463. if (state.maxBackReference > state.numCapturingParens) {
  3464. state.raise("Invalid escape");
  3465. }
  3466. for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) {
  3467. var name = list[i];
  3468. if (state.groupNames.indexOf(name) === -1) {
  3469. state.raise("Invalid named capture referenced");
  3470. }
  3471. }
  3472. };
  3473. // https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction
  3474. pp$1.regexp_disjunction = function(state) {
  3475. this.regexp_alternative(state);
  3476. while (state.eat(0x7C /* | */)) {
  3477. this.regexp_alternative(state);
  3478. }
  3479. // Make the same message as V8.
  3480. if (this.regexp_eatQuantifier(state, true)) {
  3481. state.raise("Nothing to repeat");
  3482. }
  3483. if (state.eat(0x7B /* { */)) {
  3484. state.raise("Lone quantifier brackets");
  3485. }
  3486. };
  3487. // https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative
  3488. pp$1.regexp_alternative = function(state) {
  3489. while (state.pos < state.source.length && this.regexp_eatTerm(state))
  3490. { }
  3491. };
  3492. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term
  3493. pp$1.regexp_eatTerm = function(state) {
  3494. if (this.regexp_eatAssertion(state)) {
  3495. // Handle `QuantifiableAssertion Quantifier` alternative.
  3496. // `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion
  3497. // is a QuantifiableAssertion.
  3498. if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) {
  3499. // Make the same message as V8.
  3500. if (state.switchU) {
  3501. state.raise("Invalid quantifier");
  3502. }
  3503. }
  3504. return true
  3505. }
  3506. if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) {
  3507. this.regexp_eatQuantifier(state);
  3508. return true
  3509. }
  3510. return false
  3511. };
  3512. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion
  3513. pp$1.regexp_eatAssertion = function(state) {
  3514. var start = state.pos;
  3515. state.lastAssertionIsQuantifiable = false;
  3516. // ^, $
  3517. if (state.eat(0x5E /* ^ */) || state.eat(0x24 /* $ */)) {
  3518. return true
  3519. }
  3520. // \b \B
  3521. if (state.eat(0x5C /* \ */)) {
  3522. if (state.eat(0x42 /* B */) || state.eat(0x62 /* b */)) {
  3523. return true
  3524. }
  3525. state.pos = start;
  3526. }
  3527. // Lookahead / Lookbehind
  3528. if (state.eat(0x28 /* ( */) && state.eat(0x3F /* ? */)) {
  3529. var lookbehind = false;
  3530. if (this.options.ecmaVersion >= 9) {
  3531. lookbehind = state.eat(0x3C /* < */);
  3532. }
  3533. if (state.eat(0x3D /* = */) || state.eat(0x21 /* ! */)) {
  3534. this.regexp_disjunction(state);
  3535. if (!state.eat(0x29 /* ) */)) {
  3536. state.raise("Unterminated group");
  3537. }
  3538. state.lastAssertionIsQuantifiable = !lookbehind;
  3539. return true
  3540. }
  3541. }
  3542. state.pos = start;
  3543. return false
  3544. };
  3545. // https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier
  3546. pp$1.regexp_eatQuantifier = function(state, noError) {
  3547. if ( noError === void 0 ) noError = false;
  3548. if (this.regexp_eatQuantifierPrefix(state, noError)) {
  3549. state.eat(0x3F /* ? */);
  3550. return true
  3551. }
  3552. return false
  3553. };
  3554. // https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix
  3555. pp$1.regexp_eatQuantifierPrefix = function(state, noError) {
  3556. return (
  3557. state.eat(0x2A /* * */) ||
  3558. state.eat(0x2B /* + */) ||
  3559. state.eat(0x3F /* ? */) ||
  3560. this.regexp_eatBracedQuantifier(state, noError)
  3561. )
  3562. };
  3563. pp$1.regexp_eatBracedQuantifier = function(state, noError) {
  3564. var start = state.pos;
  3565. if (state.eat(0x7B /* { */)) {
  3566. var min = 0, max = -1;
  3567. if (this.regexp_eatDecimalDigits(state)) {
  3568. min = state.lastIntValue;
  3569. if (state.eat(0x2C /* , */) && this.regexp_eatDecimalDigits(state)) {
  3570. max = state.lastIntValue;
  3571. }
  3572. if (state.eat(0x7D /* } */)) {
  3573. // SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-term
  3574. if (max !== -1 && max < min && !noError) {
  3575. state.raise("numbers out of order in {} quantifier");
  3576. }
  3577. return true
  3578. }
  3579. }
  3580. if (state.switchU && !noError) {
  3581. state.raise("Incomplete quantifier");
  3582. }
  3583. state.pos = start;
  3584. }
  3585. return false
  3586. };
  3587. // https://www.ecma-international.org/ecma-262/8.0/#prod-Atom
  3588. pp$1.regexp_eatAtom = function(state) {
  3589. return (
  3590. this.regexp_eatPatternCharacters(state) ||
  3591. state.eat(0x2E /* . */) ||
  3592. this.regexp_eatReverseSolidusAtomEscape(state) ||
  3593. this.regexp_eatCharacterClass(state) ||
  3594. this.regexp_eatUncapturingGroup(state) ||
  3595. this.regexp_eatCapturingGroup(state)
  3596. )
  3597. };
  3598. pp$1.regexp_eatReverseSolidusAtomEscape = function(state) {
  3599. var start = state.pos;
  3600. if (state.eat(0x5C /* \ */)) {
  3601. if (this.regexp_eatAtomEscape(state)) {
  3602. return true
  3603. }
  3604. state.pos = start;
  3605. }
  3606. return false
  3607. };
  3608. pp$1.regexp_eatUncapturingGroup = function(state) {
  3609. var start = state.pos;
  3610. if (state.eat(0x28 /* ( */)) {
  3611. if (state.eat(0x3F /* ? */) && state.eat(0x3A /* : */)) {
  3612. this.regexp_disjunction(state);
  3613. if (state.eat(0x29 /* ) */)) {
  3614. return true
  3615. }
  3616. state.raise("Unterminated group");
  3617. }
  3618. state.pos = start;
  3619. }
  3620. return false
  3621. };
  3622. pp$1.regexp_eatCapturingGroup = function(state) {
  3623. if (state.eat(0x28 /* ( */)) {
  3624. if (this.options.ecmaVersion >= 9) {
  3625. this.regexp_groupSpecifier(state);
  3626. } else if (state.current() === 0x3F /* ? */) {
  3627. state.raise("Invalid group");
  3628. }
  3629. this.regexp_disjunction(state);
  3630. if (state.eat(0x29 /* ) */)) {
  3631. state.numCapturingParens += 1;
  3632. return true
  3633. }
  3634. state.raise("Unterminated group");
  3635. }
  3636. return false
  3637. };
  3638. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom
  3639. pp$1.regexp_eatExtendedAtom = function(state) {
  3640. return (
  3641. state.eat(0x2E /* . */) ||
  3642. this.regexp_eatReverseSolidusAtomEscape(state) ||
  3643. this.regexp_eatCharacterClass(state) ||
  3644. this.regexp_eatUncapturingGroup(state) ||
  3645. this.regexp_eatCapturingGroup(state) ||
  3646. this.regexp_eatInvalidBracedQuantifier(state) ||
  3647. this.regexp_eatExtendedPatternCharacter(state)
  3648. )
  3649. };
  3650. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier
  3651. pp$1.regexp_eatInvalidBracedQuantifier = function(state) {
  3652. if (this.regexp_eatBracedQuantifier(state, true)) {
  3653. state.raise("Nothing to repeat");
  3654. }
  3655. return false
  3656. };
  3657. // https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter
  3658. pp$1.regexp_eatSyntaxCharacter = function(state) {
  3659. var ch = state.current();
  3660. if (isSyntaxCharacter(ch)) {
  3661. state.lastIntValue = ch;
  3662. state.advance();
  3663. return true
  3664. }
  3665. return false
  3666. };
  3667. function isSyntaxCharacter(ch) {
  3668. return (
  3669. ch === 0x24 /* $ */ ||
  3670. ch >= 0x28 /* ( */ && ch <= 0x2B /* + */ ||
  3671. ch === 0x2E /* . */ ||
  3672. ch === 0x3F /* ? */ ||
  3673. ch >= 0x5B /* [ */ && ch <= 0x5E /* ^ */ ||
  3674. ch >= 0x7B /* { */ && ch <= 0x7D /* } */
  3675. )
  3676. }
  3677. // https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter
  3678. // But eat eager.
  3679. pp$1.regexp_eatPatternCharacters = function(state) {
  3680. var start = state.pos;
  3681. var ch = 0;
  3682. while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) {
  3683. state.advance();
  3684. }
  3685. return state.pos !== start
  3686. };
  3687. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter
  3688. pp$1.regexp_eatExtendedPatternCharacter = function(state) {
  3689. var ch = state.current();
  3690. if (
  3691. ch !== -1 &&
  3692. ch !== 0x24 /* $ */ &&
  3693. !(ch >= 0x28 /* ( */ && ch <= 0x2B /* + */) &&
  3694. ch !== 0x2E /* . */ &&
  3695. ch !== 0x3F /* ? */ &&
  3696. ch !== 0x5B /* [ */ &&
  3697. ch !== 0x5E /* ^ */ &&
  3698. ch !== 0x7C /* | */
  3699. ) {
  3700. state.advance();
  3701. return true
  3702. }
  3703. return false
  3704. };
  3705. // GroupSpecifier ::
  3706. // [empty]
  3707. // `?` GroupName
  3708. pp$1.regexp_groupSpecifier = function(state) {
  3709. if (state.eat(0x3F /* ? */)) {
  3710. if (this.regexp_eatGroupName(state)) {
  3711. if (state.groupNames.indexOf(state.lastStringValue) !== -1) {
  3712. state.raise("Duplicate capture group name");
  3713. }
  3714. state.groupNames.push(state.lastStringValue);
  3715. return
  3716. }
  3717. state.raise("Invalid group");
  3718. }
  3719. };
  3720. // GroupName ::
  3721. // `<` RegExpIdentifierName `>`
  3722. // Note: this updates `state.lastStringValue` property with the eaten name.
  3723. pp$1.regexp_eatGroupName = function(state) {
  3724. state.lastStringValue = "";
  3725. if (state.eat(0x3C /* < */)) {
  3726. if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E /* > */)) {
  3727. return true
  3728. }
  3729. state.raise("Invalid capture group name");
  3730. }
  3731. return false
  3732. };
  3733. // RegExpIdentifierName ::
  3734. // RegExpIdentifierStart
  3735. // RegExpIdentifierName RegExpIdentifierPart
  3736. // Note: this updates `state.lastStringValue` property with the eaten name.
  3737. pp$1.regexp_eatRegExpIdentifierName = function(state) {
  3738. state.lastStringValue = "";
  3739. if (this.regexp_eatRegExpIdentifierStart(state)) {
  3740. state.lastStringValue += codePointToString(state.lastIntValue);
  3741. while (this.regexp_eatRegExpIdentifierPart(state)) {
  3742. state.lastStringValue += codePointToString(state.lastIntValue);
  3743. }
  3744. return true
  3745. }
  3746. return false
  3747. };
  3748. // RegExpIdentifierStart ::
  3749. // UnicodeIDStart
  3750. // `$`
  3751. // `_`
  3752. // `\` RegExpUnicodeEscapeSequence[+U]
  3753. pp$1.regexp_eatRegExpIdentifierStart = function(state) {
  3754. var start = state.pos;
  3755. var forceU = this.options.ecmaVersion >= 11;
  3756. var ch = state.current(forceU);
  3757. state.advance(forceU);
  3758. if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
  3759. ch = state.lastIntValue;
  3760. }
  3761. if (isRegExpIdentifierStart(ch)) {
  3762. state.lastIntValue = ch;
  3763. return true
  3764. }
  3765. state.pos = start;
  3766. return false
  3767. };
  3768. function isRegExpIdentifierStart(ch) {
  3769. return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */
  3770. }
  3771. // RegExpIdentifierPart ::
  3772. // UnicodeIDContinue
  3773. // `$`
  3774. // `_`
  3775. // `\` RegExpUnicodeEscapeSequence[+U]
  3776. // <ZWNJ>
  3777. // <ZWJ>
  3778. pp$1.regexp_eatRegExpIdentifierPart = function(state) {
  3779. var start = state.pos;
  3780. var forceU = this.options.ecmaVersion >= 11;
  3781. var ch = state.current(forceU);
  3782. state.advance(forceU);
  3783. if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
  3784. ch = state.lastIntValue;
  3785. }
  3786. if (isRegExpIdentifierPart(ch)) {
  3787. state.lastIntValue = ch;
  3788. return true
  3789. }
  3790. state.pos = start;
  3791. return false
  3792. };
  3793. function isRegExpIdentifierPart(ch) {
  3794. return isIdentifierChar(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ || ch === 0x200C /* <ZWNJ> */ || ch === 0x200D /* <ZWJ> */
  3795. }
  3796. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape
  3797. pp$1.regexp_eatAtomEscape = function(state) {
  3798. if (
  3799. this.regexp_eatBackReference(state) ||
  3800. this.regexp_eatCharacterClassEscape(state) ||
  3801. this.regexp_eatCharacterEscape(state) ||
  3802. (state.switchN && this.regexp_eatKGroupName(state))
  3803. ) {
  3804. return true
  3805. }
  3806. if (state.switchU) {
  3807. // Make the same message as V8.
  3808. if (state.current() === 0x63 /* c */) {
  3809. state.raise("Invalid unicode escape");
  3810. }
  3811. state.raise("Invalid escape");
  3812. }
  3813. return false
  3814. };
  3815. pp$1.regexp_eatBackReference = function(state) {
  3816. var start = state.pos;
  3817. if (this.regexp_eatDecimalEscape(state)) {
  3818. var n = state.lastIntValue;
  3819. if (state.switchU) {
  3820. // For SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-atomescape
  3821. if (n > state.maxBackReference) {
  3822. state.maxBackReference = n;
  3823. }
  3824. return true
  3825. }
  3826. if (n <= state.numCapturingParens) {
  3827. return true
  3828. }
  3829. state.pos = start;
  3830. }
  3831. return false
  3832. };
  3833. pp$1.regexp_eatKGroupName = function(state) {
  3834. if (state.eat(0x6B /* k */)) {
  3835. if (this.regexp_eatGroupName(state)) {
  3836. state.backReferenceNames.push(state.lastStringValue);
  3837. return true
  3838. }
  3839. state.raise("Invalid named reference");
  3840. }
  3841. return false
  3842. };
  3843. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape
  3844. pp$1.regexp_eatCharacterEscape = function(state) {
  3845. return (
  3846. this.regexp_eatControlEscape(state) ||
  3847. this.regexp_eatCControlLetter(state) ||
  3848. this.regexp_eatZero(state) ||
  3849. this.regexp_eatHexEscapeSequence(state) ||
  3850. this.regexp_eatRegExpUnicodeEscapeSequence(state, false) ||
  3851. (!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) ||
  3852. this.regexp_eatIdentityEscape(state)
  3853. )
  3854. };
  3855. pp$1.regexp_eatCControlLetter = function(state) {
  3856. var start = state.pos;
  3857. if (state.eat(0x63 /* c */)) {
  3858. if (this.regexp_eatControlLetter(state)) {
  3859. return true
  3860. }
  3861. state.pos = start;
  3862. }
  3863. return false
  3864. };
  3865. pp$1.regexp_eatZero = function(state) {
  3866. if (state.current() === 0x30 /* 0 */ && !isDecimalDigit(state.lookahead())) {
  3867. state.lastIntValue = 0;
  3868. state.advance();
  3869. return true
  3870. }
  3871. return false
  3872. };
  3873. // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape
  3874. pp$1.regexp_eatControlEscape = function(state) {
  3875. var ch = state.current();
  3876. if (ch === 0x74 /* t */) {
  3877. state.lastIntValue = 0x09; /* \t */
  3878. state.advance();
  3879. return true
  3880. }
  3881. if (ch === 0x6E /* n */) {
  3882. state.lastIntValue = 0x0A; /* \n */
  3883. state.advance();
  3884. return true
  3885. }
  3886. if (ch === 0x76 /* v */) {
  3887. state.lastIntValue = 0x0B; /* \v */
  3888. state.advance();
  3889. return true
  3890. }
  3891. if (ch === 0x66 /* f */) {
  3892. state.lastIntValue = 0x0C; /* \f */
  3893. state.advance();
  3894. return true
  3895. }
  3896. if (ch === 0x72 /* r */) {
  3897. state.lastIntValue = 0x0D; /* \r */
  3898. state.advance();
  3899. return true
  3900. }
  3901. return false
  3902. };
  3903. // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter
  3904. pp$1.regexp_eatControlLetter = function(state) {
  3905. var ch = state.current();
  3906. if (isControlLetter(ch)) {
  3907. state.lastIntValue = ch % 0x20;
  3908. state.advance();
  3909. return true
  3910. }
  3911. return false
  3912. };
  3913. function isControlLetter(ch) {
  3914. return (
  3915. (ch >= 0x41 /* A */ && ch <= 0x5A /* Z */) ||
  3916. (ch >= 0x61 /* a */ && ch <= 0x7A /* z */)
  3917. )
  3918. }
  3919. // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence
  3920. pp$1.regexp_eatRegExpUnicodeEscapeSequence = function(state, forceU) {
  3921. if ( forceU === void 0 ) forceU = false;
  3922. var start = state.pos;
  3923. var switchU = forceU || state.switchU;
  3924. if (state.eat(0x75 /* u */)) {
  3925. if (this.regexp_eatFixedHexDigits(state, 4)) {
  3926. var lead = state.lastIntValue;
  3927. if (switchU && lead >= 0xD800 && lead <= 0xDBFF) {
  3928. var leadSurrogateEnd = state.pos;
  3929. if (state.eat(0x5C /* \ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) {
  3930. var trail = state.lastIntValue;
  3931. if (trail >= 0xDC00 && trail <= 0xDFFF) {
  3932. state.lastIntValue = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
  3933. return true
  3934. }
  3935. }
  3936. state.pos = leadSurrogateEnd;
  3937. state.lastIntValue = lead;
  3938. }
  3939. return true
  3940. }
  3941. if (
  3942. switchU &&
  3943. state.eat(0x7B /* { */) &&
  3944. this.regexp_eatHexDigits(state) &&
  3945. state.eat(0x7D /* } */) &&
  3946. isValidUnicode(state.lastIntValue)
  3947. ) {
  3948. return true
  3949. }
  3950. if (switchU) {
  3951. state.raise("Invalid unicode escape");
  3952. }
  3953. state.pos = start;
  3954. }
  3955. return false
  3956. };
  3957. function isValidUnicode(ch) {
  3958. return ch >= 0 && ch <= 0x10FFFF
  3959. }
  3960. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape
  3961. pp$1.regexp_eatIdentityEscape = function(state) {
  3962. if (state.switchU) {
  3963. if (this.regexp_eatSyntaxCharacter(state)) {
  3964. return true
  3965. }
  3966. if (state.eat(0x2F /* / */)) {
  3967. state.lastIntValue = 0x2F; /* / */
  3968. return true
  3969. }
  3970. return false
  3971. }
  3972. var ch = state.current();
  3973. if (ch !== 0x63 /* c */ && (!state.switchN || ch !== 0x6B /* k */)) {
  3974. state.lastIntValue = ch;
  3975. state.advance();
  3976. return true
  3977. }
  3978. return false
  3979. };
  3980. // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape
  3981. pp$1.regexp_eatDecimalEscape = function(state) {
  3982. state.lastIntValue = 0;
  3983. var ch = state.current();
  3984. if (ch >= 0x31 /* 1 */ && ch <= 0x39 /* 9 */) {
  3985. do {
  3986. state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */);
  3987. state.advance();
  3988. } while ((ch = state.current()) >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */)
  3989. return true
  3990. }
  3991. return false
  3992. };
  3993. // Return values used by character set parsing methods, needed to
  3994. // forbid negation of sets that can match strings.
  3995. var CharSetNone = 0; // Nothing parsed
  3996. var CharSetOk = 1; // Construct parsed, cannot contain strings
  3997. var CharSetString = 2; // Construct parsed, can contain strings
  3998. // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape
  3999. pp$1.regexp_eatCharacterClassEscape = function(state) {
  4000. var ch = state.current();
  4001. if (isCharacterClassEscape(ch)) {
  4002. state.lastIntValue = -1;
  4003. state.advance();
  4004. return CharSetOk
  4005. }
  4006. var negate = false;
  4007. if (
  4008. state.switchU &&
  4009. this.options.ecmaVersion >= 9 &&
  4010. ((negate = ch === 0x50 /* P */) || ch === 0x70 /* p */)
  4011. ) {
  4012. state.lastIntValue = -1;
  4013. state.advance();
  4014. var result;
  4015. if (
  4016. state.eat(0x7B /* { */) &&
  4017. (result = this.regexp_eatUnicodePropertyValueExpression(state)) &&
  4018. state.eat(0x7D /* } */)
  4019. ) {
  4020. if (negate && result === CharSetString) { state.raise("Invalid property name"); }
  4021. return result
  4022. }
  4023. state.raise("Invalid property name");
  4024. }
  4025. return CharSetNone
  4026. };
  4027. function isCharacterClassEscape(ch) {
  4028. return (
  4029. ch === 0x64 /* d */ ||
  4030. ch === 0x44 /* D */ ||
  4031. ch === 0x73 /* s */ ||
  4032. ch === 0x53 /* S */ ||
  4033. ch === 0x77 /* w */ ||
  4034. ch === 0x57 /* W */
  4035. )
  4036. }
  4037. // UnicodePropertyValueExpression ::
  4038. // UnicodePropertyName `=` UnicodePropertyValue
  4039. // LoneUnicodePropertyNameOrValue
  4040. pp$1.regexp_eatUnicodePropertyValueExpression = function(state) {
  4041. var start = state.pos;
  4042. // UnicodePropertyName `=` UnicodePropertyValue
  4043. if (this.regexp_eatUnicodePropertyName(state) && state.eat(0x3D /* = */)) {
  4044. var name = state.lastStringValue;
  4045. if (this.regexp_eatUnicodePropertyValue(state)) {
  4046. var value = state.lastStringValue;
  4047. this.regexp_validateUnicodePropertyNameAndValue(state, name, value);
  4048. return CharSetOk
  4049. }
  4050. }
  4051. state.pos = start;
  4052. // LoneUnicodePropertyNameOrValue
  4053. if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {
  4054. var nameOrValue = state.lastStringValue;
  4055. return this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue)
  4056. }
  4057. return CharSetNone
  4058. };
  4059. pp$1.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) {
  4060. if (!hasOwn(state.unicodeProperties.nonBinary, name))
  4061. { state.raise("Invalid property name"); }
  4062. if (!state.unicodeProperties.nonBinary[name].test(value))
  4063. { state.raise("Invalid property value"); }
  4064. };
  4065. pp$1.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) {
  4066. if (state.unicodeProperties.binary.test(nameOrValue)) { return CharSetOk }
  4067. if (state.switchV && state.unicodeProperties.binaryOfStrings.test(nameOrValue)) { return CharSetString }
  4068. state.raise("Invalid property name");
  4069. };
  4070. // UnicodePropertyName ::
  4071. // UnicodePropertyNameCharacters
  4072. pp$1.regexp_eatUnicodePropertyName = function(state) {
  4073. var ch = 0;
  4074. state.lastStringValue = "";
  4075. while (isUnicodePropertyNameCharacter(ch = state.current())) {
  4076. state.lastStringValue += codePointToString(ch);
  4077. state.advance();
  4078. }
  4079. return state.lastStringValue !== ""
  4080. };
  4081. function isUnicodePropertyNameCharacter(ch) {
  4082. return isControlLetter(ch) || ch === 0x5F /* _ */
  4083. }
  4084. // UnicodePropertyValue ::
  4085. // UnicodePropertyValueCharacters
  4086. pp$1.regexp_eatUnicodePropertyValue = function(state) {
  4087. var ch = 0;
  4088. state.lastStringValue = "";
  4089. while (isUnicodePropertyValueCharacter(ch = state.current())) {
  4090. state.lastStringValue += codePointToString(ch);
  4091. state.advance();
  4092. }
  4093. return state.lastStringValue !== ""
  4094. };
  4095. function isUnicodePropertyValueCharacter(ch) {
  4096. return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch)
  4097. }
  4098. // LoneUnicodePropertyNameOrValue ::
  4099. // UnicodePropertyValueCharacters
  4100. pp$1.regexp_eatLoneUnicodePropertyNameOrValue = function(state) {
  4101. return this.regexp_eatUnicodePropertyValue(state)
  4102. };
  4103. // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass
  4104. pp$1.regexp_eatCharacterClass = function(state) {
  4105. if (state.eat(0x5B /* [ */)) {
  4106. var negate = state.eat(0x5E /* ^ */);
  4107. var result = this.regexp_classContents(state);
  4108. if (!state.eat(0x5D /* ] */))
  4109. { state.raise("Unterminated character class"); }
  4110. if (negate && result === CharSetString)
  4111. { state.raise("Negated character class may contain strings"); }
  4112. return true
  4113. }
  4114. return false
  4115. };
  4116. // https://tc39.es/ecma262/#prod-ClassContents
  4117. // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges
  4118. pp$1.regexp_classContents = function(state) {
  4119. if (state.current() === 0x5D /* ] */) { return CharSetOk }
  4120. if (state.switchV) { return this.regexp_classSetExpression(state) }
  4121. this.regexp_nonEmptyClassRanges(state);
  4122. return CharSetOk
  4123. };
  4124. // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges
  4125. // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash
  4126. pp$1.regexp_nonEmptyClassRanges = function(state) {
  4127. while (this.regexp_eatClassAtom(state)) {
  4128. var left = state.lastIntValue;
  4129. if (state.eat(0x2D /* - */) && this.regexp_eatClassAtom(state)) {
  4130. var right = state.lastIntValue;
  4131. if (state.switchU && (left === -1 || right === -1)) {
  4132. state.raise("Invalid character class");
  4133. }
  4134. if (left !== -1 && right !== -1 && left > right) {
  4135. state.raise("Range out of order in character class");
  4136. }
  4137. }
  4138. }
  4139. };
  4140. // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom
  4141. // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash
  4142. pp$1.regexp_eatClassAtom = function(state) {
  4143. var start = state.pos;
  4144. if (state.eat(0x5C /* \ */)) {
  4145. if (this.regexp_eatClassEscape(state)) {
  4146. return true
  4147. }
  4148. if (state.switchU) {
  4149. // Make the same message as V8.
  4150. var ch$1 = state.current();
  4151. if (ch$1 === 0x63 /* c */ || isOctalDigit(ch$1)) {
  4152. state.raise("Invalid class escape");
  4153. }
  4154. state.raise("Invalid escape");
  4155. }
  4156. state.pos = start;
  4157. }
  4158. var ch = state.current();
  4159. if (ch !== 0x5D /* ] */) {
  4160. state.lastIntValue = ch;
  4161. state.advance();
  4162. return true
  4163. }
  4164. return false
  4165. };
  4166. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape
  4167. pp$1.regexp_eatClassEscape = function(state) {
  4168. var start = state.pos;
  4169. if (state.eat(0x62 /* b */)) {
  4170. state.lastIntValue = 0x08; /* <BS> */
  4171. return true
  4172. }
  4173. if (state.switchU && state.eat(0x2D /* - */)) {
  4174. state.lastIntValue = 0x2D; /* - */
  4175. return true
  4176. }
  4177. if (!state.switchU && state.eat(0x63 /* c */)) {
  4178. if (this.regexp_eatClassControlLetter(state)) {
  4179. return true
  4180. }
  4181. state.pos = start;
  4182. }
  4183. return (
  4184. this.regexp_eatCharacterClassEscape(state) ||
  4185. this.regexp_eatCharacterEscape(state)
  4186. )
  4187. };
  4188. // https://tc39.es/ecma262/#prod-ClassSetExpression
  4189. // https://tc39.es/ecma262/#prod-ClassUnion
  4190. // https://tc39.es/ecma262/#prod-ClassIntersection
  4191. // https://tc39.es/ecma262/#prod-ClassSubtraction
  4192. pp$1.regexp_classSetExpression = function(state) {
  4193. var result = CharSetOk, subResult;
  4194. if (this.regexp_eatClassSetRange(state)) ; else if (subResult = this.regexp_eatClassSetOperand(state)) {
  4195. if (subResult === CharSetString) { result = CharSetString; }
  4196. // https://tc39.es/ecma262/#prod-ClassIntersection
  4197. var start = state.pos;
  4198. while (state.eatChars([0x26, 0x26] /* && */)) {
  4199. if (
  4200. state.current() !== 0x26 /* & */ &&
  4201. (subResult = this.regexp_eatClassSetOperand(state))
  4202. ) {
  4203. if (subResult !== CharSetString) { result = CharSetOk; }
  4204. continue
  4205. }
  4206. state.raise("Invalid character in character class");
  4207. }
  4208. if (start !== state.pos) { return result }
  4209. // https://tc39.es/ecma262/#prod-ClassSubtraction
  4210. while (state.eatChars([0x2D, 0x2D] /* -- */)) {
  4211. if (this.regexp_eatClassSetOperand(state)) { continue }
  4212. state.raise("Invalid character in character class");
  4213. }
  4214. if (start !== state.pos) { return result }
  4215. } else {
  4216. state.raise("Invalid character in character class");
  4217. }
  4218. // https://tc39.es/ecma262/#prod-ClassUnion
  4219. for (;;) {
  4220. if (this.regexp_eatClassSetRange(state)) { continue }
  4221. subResult = this.regexp_eatClassSetOperand(state);
  4222. if (!subResult) { return result }
  4223. if (subResult === CharSetString) { result = CharSetString; }
  4224. }
  4225. };
  4226. // https://tc39.es/ecma262/#prod-ClassSetRange
  4227. pp$1.regexp_eatClassSetRange = function(state) {
  4228. var start = state.pos;
  4229. if (this.regexp_eatClassSetCharacter(state)) {
  4230. var left = state.lastIntValue;
  4231. if (state.eat(0x2D /* - */) && this.regexp_eatClassSetCharacter(state)) {
  4232. var right = state.lastIntValue;
  4233. if (left !== -1 && right !== -1 && left > right) {
  4234. state.raise("Range out of order in character class");
  4235. }
  4236. return true
  4237. }
  4238. state.pos = start;
  4239. }
  4240. return false
  4241. };
  4242. // https://tc39.es/ecma262/#prod-ClassSetOperand
  4243. pp$1.regexp_eatClassSetOperand = function(state) {
  4244. if (this.regexp_eatClassSetCharacter(state)) { return CharSetOk }
  4245. return this.regexp_eatClassStringDisjunction(state) || this.regexp_eatNestedClass(state)
  4246. };
  4247. // https://tc39.es/ecma262/#prod-NestedClass
  4248. pp$1.regexp_eatNestedClass = function(state) {
  4249. var start = state.pos;
  4250. if (state.eat(0x5B /* [ */)) {
  4251. var negate = state.eat(0x5E /* ^ */);
  4252. var result = this.regexp_classContents(state);
  4253. if (state.eat(0x5D /* ] */)) {
  4254. if (negate && result === CharSetString) {
  4255. state.raise("Negated character class may contain strings");
  4256. }
  4257. return result
  4258. }
  4259. state.pos = start;
  4260. }
  4261. if (state.eat(0x5C /* \ */)) {
  4262. var result$1 = this.regexp_eatCharacterClassEscape(state);
  4263. if (result$1) {
  4264. return result$1
  4265. }
  4266. state.pos = start;
  4267. }
  4268. return null
  4269. };
  4270. // https://tc39.es/ecma262/#prod-ClassStringDisjunction
  4271. pp$1.regexp_eatClassStringDisjunction = function(state) {
  4272. var start = state.pos;
  4273. if (state.eatChars([0x5C, 0x71] /* \q */)) {
  4274. if (state.eat(0x7B /* { */)) {
  4275. var result = this.regexp_classStringDisjunctionContents(state);
  4276. if (state.eat(0x7D /* } */)) {
  4277. return result
  4278. }
  4279. } else {
  4280. // Make the same message as V8.
  4281. state.raise("Invalid escape");
  4282. }
  4283. state.pos = start;
  4284. }
  4285. return null
  4286. };
  4287. // https://tc39.es/ecma262/#prod-ClassStringDisjunctionContents
  4288. pp$1.regexp_classStringDisjunctionContents = function(state) {
  4289. var result = this.regexp_classString(state);
  4290. while (state.eat(0x7C /* | */)) {
  4291. if (this.regexp_classString(state) === CharSetString) { result = CharSetString; }
  4292. }
  4293. return result
  4294. };
  4295. // https://tc39.es/ecma262/#prod-ClassString
  4296. // https://tc39.es/ecma262/#prod-NonEmptyClassString
  4297. pp$1.regexp_classString = function(state) {
  4298. var count = 0;
  4299. while (this.regexp_eatClassSetCharacter(state)) { count++; }
  4300. return count === 1 ? CharSetOk : CharSetString
  4301. };
  4302. // https://tc39.es/ecma262/#prod-ClassSetCharacter
  4303. pp$1.regexp_eatClassSetCharacter = function(state) {
  4304. var start = state.pos;
  4305. if (state.eat(0x5C /* \ */)) {
  4306. if (
  4307. this.regexp_eatCharacterEscape(state) ||
  4308. this.regexp_eatClassSetReservedPunctuator(state)
  4309. ) {
  4310. return true
  4311. }
  4312. if (state.eat(0x62 /* b */)) {
  4313. state.lastIntValue = 0x08; /* <BS> */
  4314. return true
  4315. }
  4316. state.pos = start;
  4317. return false
  4318. }
  4319. var ch = state.current();
  4320. if (ch < 0 || ch === state.lookahead() && isClassSetReservedDoublePunctuatorCharacter(ch)) { return false }
  4321. if (isClassSetSyntaxCharacter(ch)) { return false }
  4322. state.advance();
  4323. state.lastIntValue = ch;
  4324. return true
  4325. };
  4326. // https://tc39.es/ecma262/#prod-ClassSetReservedDoublePunctuator
  4327. function isClassSetReservedDoublePunctuatorCharacter(ch) {
  4328. return (
  4329. ch === 0x21 /* ! */ ||
  4330. ch >= 0x23 /* # */ && ch <= 0x26 /* & */ ||
  4331. ch >= 0x2A /* * */ && ch <= 0x2C /* , */ ||
  4332. ch === 0x2E /* . */ ||
  4333. ch >= 0x3A /* : */ && ch <= 0x40 /* @ */ ||
  4334. ch === 0x5E /* ^ */ ||
  4335. ch === 0x60 /* ` */ ||
  4336. ch === 0x7E /* ~ */
  4337. )
  4338. }
  4339. // https://tc39.es/ecma262/#prod-ClassSetSyntaxCharacter
  4340. function isClassSetSyntaxCharacter(ch) {
  4341. return (
  4342. ch === 0x28 /* ( */ ||
  4343. ch === 0x29 /* ) */ ||
  4344. ch === 0x2D /* - */ ||
  4345. ch === 0x2F /* / */ ||
  4346. ch >= 0x5B /* [ */ && ch <= 0x5D /* ] */ ||
  4347. ch >= 0x7B /* { */ && ch <= 0x7D /* } */
  4348. )
  4349. }
  4350. // https://tc39.es/ecma262/#prod-ClassSetReservedPunctuator
  4351. pp$1.regexp_eatClassSetReservedPunctuator = function(state) {
  4352. var ch = state.current();
  4353. if (isClassSetReservedPunctuator(ch)) {
  4354. state.lastIntValue = ch;
  4355. state.advance();
  4356. return true
  4357. }
  4358. return false
  4359. };
  4360. // https://tc39.es/ecma262/#prod-ClassSetReservedPunctuator
  4361. function isClassSetReservedPunctuator(ch) {
  4362. return (
  4363. ch === 0x21 /* ! */ ||
  4364. ch === 0x23 /* # */ ||
  4365. ch === 0x25 /* % */ ||
  4366. ch === 0x26 /* & */ ||
  4367. ch === 0x2C /* , */ ||
  4368. ch === 0x2D /* - */ ||
  4369. ch >= 0x3A /* : */ && ch <= 0x3E /* > */ ||
  4370. ch === 0x40 /* @ */ ||
  4371. ch === 0x60 /* ` */ ||
  4372. ch === 0x7E /* ~ */
  4373. )
  4374. }
  4375. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter
  4376. pp$1.regexp_eatClassControlLetter = function(state) {
  4377. var ch = state.current();
  4378. if (isDecimalDigit(ch) || ch === 0x5F /* _ */) {
  4379. state.lastIntValue = ch % 0x20;
  4380. state.advance();
  4381. return true
  4382. }
  4383. return false
  4384. };
  4385. // https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
  4386. pp$1.regexp_eatHexEscapeSequence = function(state) {
  4387. var start = state.pos;
  4388. if (state.eat(0x78 /* x */)) {
  4389. if (this.regexp_eatFixedHexDigits(state, 2)) {
  4390. return true
  4391. }
  4392. if (state.switchU) {
  4393. state.raise("Invalid escape");
  4394. }
  4395. state.pos = start;
  4396. }
  4397. return false
  4398. };
  4399. // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits
  4400. pp$1.regexp_eatDecimalDigits = function(state) {
  4401. var start = state.pos;
  4402. var ch = 0;
  4403. state.lastIntValue = 0;
  4404. while (isDecimalDigit(ch = state.current())) {
  4405. state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */);
  4406. state.advance();
  4407. }
  4408. return state.pos !== start
  4409. };
  4410. function isDecimalDigit(ch) {
  4411. return ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */
  4412. }
  4413. // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits
  4414. pp$1.regexp_eatHexDigits = function(state) {
  4415. var start = state.pos;
  4416. var ch = 0;
  4417. state.lastIntValue = 0;
  4418. while (isHexDigit(ch = state.current())) {
  4419. state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
  4420. state.advance();
  4421. }
  4422. return state.pos !== start
  4423. };
  4424. function isHexDigit(ch) {
  4425. return (
  4426. (ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */) ||
  4427. (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) ||
  4428. (ch >= 0x61 /* a */ && ch <= 0x66 /* f */)
  4429. )
  4430. }
  4431. function hexToInt(ch) {
  4432. if (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) {
  4433. return 10 + (ch - 0x41 /* A */)
  4434. }
  4435. if (ch >= 0x61 /* a */ && ch <= 0x66 /* f */) {
  4436. return 10 + (ch - 0x61 /* a */)
  4437. }
  4438. return ch - 0x30 /* 0 */
  4439. }
  4440. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence
  4441. // Allows only 0-377(octal) i.e. 0-255(decimal).
  4442. pp$1.regexp_eatLegacyOctalEscapeSequence = function(state) {
  4443. if (this.regexp_eatOctalDigit(state)) {
  4444. var n1 = state.lastIntValue;
  4445. if (this.regexp_eatOctalDigit(state)) {
  4446. var n2 = state.lastIntValue;
  4447. if (n1 <= 3 && this.regexp_eatOctalDigit(state)) {
  4448. state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue;
  4449. } else {
  4450. state.lastIntValue = n1 * 8 + n2;
  4451. }
  4452. } else {
  4453. state.lastIntValue = n1;
  4454. }
  4455. return true
  4456. }
  4457. return false
  4458. };
  4459. // https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit
  4460. pp$1.regexp_eatOctalDigit = function(state) {
  4461. var ch = state.current();
  4462. if (isOctalDigit(ch)) {
  4463. state.lastIntValue = ch - 0x30; /* 0 */
  4464. state.advance();
  4465. return true
  4466. }
  4467. state.lastIntValue = 0;
  4468. return false
  4469. };
  4470. function isOctalDigit(ch) {
  4471. return ch >= 0x30 /* 0 */ && ch <= 0x37 /* 7 */
  4472. }
  4473. // https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits
  4474. // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit
  4475. // And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
  4476. pp$1.regexp_eatFixedHexDigits = function(state, length) {
  4477. var start = state.pos;
  4478. state.lastIntValue = 0;
  4479. for (var i = 0; i < length; ++i) {
  4480. var ch = state.current();
  4481. if (!isHexDigit(ch)) {
  4482. state.pos = start;
  4483. return false
  4484. }
  4485. state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
  4486. state.advance();
  4487. }
  4488. return true
  4489. };
  4490. // Object type used to represent tokens. Note that normally, tokens
  4491. // simply exist as properties on the parser object. This is only
  4492. // used for the onToken callback and the external tokenizer.
  4493. var Token = function Token(p) {
  4494. this.type = p.type;
  4495. this.value = p.value;
  4496. this.start = p.start;
  4497. this.end = p.end;
  4498. if (p.options.locations)
  4499. { this.loc = new SourceLocation(p, p.startLoc, p.endLoc); }
  4500. if (p.options.ranges)
  4501. { this.range = [p.start, p.end]; }
  4502. };
  4503. // ## Tokenizer
  4504. var pp = Parser.prototype;
  4505. // Move to the next token
  4506. pp.next = function(ignoreEscapeSequenceInKeyword) {
  4507. if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc)
  4508. { this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword); }
  4509. if (this.options.onToken)
  4510. { this.options.onToken(new Token(this)); }
  4511. this.lastTokEnd = this.end;
  4512. this.lastTokStart = this.start;
  4513. this.lastTokEndLoc = this.endLoc;
  4514. this.lastTokStartLoc = this.startLoc;
  4515. this.nextToken();
  4516. };
  4517. pp.getToken = function() {
  4518. this.next();
  4519. return new Token(this)
  4520. };
  4521. // If we're in an ES6 environment, make parsers iterable
  4522. if (typeof Symbol !== "undefined")
  4523. { pp[Symbol.iterator] = function() {
  4524. var this$1$1 = this;
  4525. return {
  4526. next: function () {
  4527. var token = this$1$1.getToken();
  4528. return {
  4529. done: token.type === types$1.eof,
  4530. value: token
  4531. }
  4532. }
  4533. }
  4534. }; }
  4535. // Toggle strict mode. Re-reads the next number or string to please
  4536. // pedantic tests (`"use strict"; 010;` should fail).
  4537. // Read a single token, updating the parser object's token-related
  4538. // properties.
  4539. pp.nextToken = function() {
  4540. var curContext = this.curContext();
  4541. if (!curContext || !curContext.preserveSpace) { this.skipSpace(); }
  4542. this.start = this.pos;
  4543. if (this.options.locations) { this.startLoc = this.curPosition(); }
  4544. if (this.pos >= this.input.length) { return this.finishToken(types$1.eof) }
  4545. if (curContext.override) { return curContext.override(this) }
  4546. else { this.readToken(this.fullCharCodeAtPos()); }
  4547. };
  4548. pp.readToken = function(code) {
  4549. // Identifier or keyword. '\uXXXX' sequences are allowed in
  4550. // identifiers, so '\' also dispatches to that.
  4551. if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */)
  4552. { return this.readWord() }
  4553. return this.getTokenFromCode(code)
  4554. };
  4555. pp.fullCharCodeAtPos = function() {
  4556. var code = this.input.charCodeAt(this.pos);
  4557. if (code <= 0xd7ff || code >= 0xdc00) { return code }
  4558. var next = this.input.charCodeAt(this.pos + 1);
  4559. return next <= 0xdbff || next >= 0xe000 ? code : (code << 10) + next - 0x35fdc00
  4560. };
  4561. pp.skipBlockComment = function() {
  4562. var startLoc = this.options.onComment && this.curPosition();
  4563. var start = this.pos, end = this.input.indexOf("*/", this.pos += 2);
  4564. if (end === -1) { this.raise(this.pos - 2, "Unterminated comment"); }
  4565. this.pos = end + 2;
  4566. if (this.options.locations) {
  4567. for (var nextBreak = (void 0), pos = start; (nextBreak = nextLineBreak(this.input, pos, this.pos)) > -1;) {
  4568. ++this.curLine;
  4569. pos = this.lineStart = nextBreak;
  4570. }
  4571. }
  4572. if (this.options.onComment)
  4573. { this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos,
  4574. startLoc, this.curPosition()); }
  4575. };
  4576. pp.skipLineComment = function(startSkip) {
  4577. var start = this.pos;
  4578. var startLoc = this.options.onComment && this.curPosition();
  4579. var ch = this.input.charCodeAt(this.pos += startSkip);
  4580. while (this.pos < this.input.length && !isNewLine(ch)) {
  4581. ch = this.input.charCodeAt(++this.pos);
  4582. }
  4583. if (this.options.onComment)
  4584. { this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos,
  4585. startLoc, this.curPosition()); }
  4586. };
  4587. // Called at the start of the parse and after every token. Skips
  4588. // whitespace and comments, and.
  4589. pp.skipSpace = function() {
  4590. loop: while (this.pos < this.input.length) {
  4591. var ch = this.input.charCodeAt(this.pos);
  4592. switch (ch) {
  4593. case 32: case 160: // ' '
  4594. ++this.pos;
  4595. break
  4596. case 13:
  4597. if (this.input.charCodeAt(this.pos + 1) === 10) {
  4598. ++this.pos;
  4599. }
  4600. case 10: case 8232: case 8233:
  4601. ++this.pos;
  4602. if (this.options.locations) {
  4603. ++this.curLine;
  4604. this.lineStart = this.pos;
  4605. }
  4606. break
  4607. case 47: // '/'
  4608. switch (this.input.charCodeAt(this.pos + 1)) {
  4609. case 42: // '*'
  4610. this.skipBlockComment();
  4611. break
  4612. case 47:
  4613. this.skipLineComment(2);
  4614. break
  4615. default:
  4616. break loop
  4617. }
  4618. break
  4619. default:
  4620. if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
  4621. ++this.pos;
  4622. } else {
  4623. break loop
  4624. }
  4625. }
  4626. }
  4627. };
  4628. // Called at the end of every token. Sets `end`, `val`, and
  4629. // maintains `context` and `exprAllowed`, and skips the space after
  4630. // the token, so that the next one's `start` will point at the
  4631. // right position.
  4632. pp.finishToken = function(type, val) {
  4633. this.end = this.pos;
  4634. if (this.options.locations) { this.endLoc = this.curPosition(); }
  4635. var prevType = this.type;
  4636. this.type = type;
  4637. this.value = val;
  4638. this.updateContext(prevType);
  4639. };
  4640. // ### Token reading
  4641. // This is the function that is called to fetch the next token. It
  4642. // is somewhat obscure, because it works in character codes rather
  4643. // than characters, and because operator parsing has been inlined
  4644. // into it.
  4645. //
  4646. // All in the name of speed.
  4647. //
  4648. pp.readToken_dot = function() {
  4649. var next = this.input.charCodeAt(this.pos + 1);
  4650. if (next >= 48 && next <= 57) { return this.readNumber(true) }
  4651. var next2 = this.input.charCodeAt(this.pos + 2);
  4652. if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.'
  4653. this.pos += 3;
  4654. return this.finishToken(types$1.ellipsis)
  4655. } else {
  4656. ++this.pos;
  4657. return this.finishToken(types$1.dot)
  4658. }
  4659. };
  4660. pp.readToken_slash = function() { // '/'
  4661. var next = this.input.charCodeAt(this.pos + 1);
  4662. if (this.exprAllowed) { ++this.pos; return this.readRegexp() }
  4663. if (next === 61) { return this.finishOp(types$1.assign, 2) }
  4664. return this.finishOp(types$1.slash, 1)
  4665. };
  4666. pp.readToken_mult_modulo_exp = function(code) { // '%*'
  4667. var next = this.input.charCodeAt(this.pos + 1);
  4668. var size = 1;
  4669. var tokentype = code === 42 ? types$1.star : types$1.modulo;
  4670. // exponentiation operator ** and **=
  4671. if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) {
  4672. ++size;
  4673. tokentype = types$1.starstar;
  4674. next = this.input.charCodeAt(this.pos + 2);
  4675. }
  4676. if (next === 61) { return this.finishOp(types$1.assign, size + 1) }
  4677. return this.finishOp(tokentype, size)
  4678. };
  4679. pp.readToken_pipe_amp = function(code) { // '|&'
  4680. var next = this.input.charCodeAt(this.pos + 1);
  4681. if (next === code) {
  4682. if (this.options.ecmaVersion >= 12) {
  4683. var next2 = this.input.charCodeAt(this.pos + 2);
  4684. if (next2 === 61) { return this.finishOp(types$1.assign, 3) }
  4685. }
  4686. return this.finishOp(code === 124 ? types$1.logicalOR : types$1.logicalAND, 2)
  4687. }
  4688. if (next === 61) { return this.finishOp(types$1.assign, 2) }
  4689. return this.finishOp(code === 124 ? types$1.bitwiseOR : types$1.bitwiseAND, 1)
  4690. };
  4691. pp.readToken_caret = function() { // '^'
  4692. var next = this.input.charCodeAt(this.pos + 1);
  4693. if (next === 61) { return this.finishOp(types$1.assign, 2) }
  4694. return this.finishOp(types$1.bitwiseXOR, 1)
  4695. };
  4696. pp.readToken_plus_min = function(code) { // '+-'
  4697. var next = this.input.charCodeAt(this.pos + 1);
  4698. if (next === code) {
  4699. if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 &&
  4700. (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {
  4701. // A `-->` line comment
  4702. this.skipLineComment(3);
  4703. this.skipSpace();
  4704. return this.nextToken()
  4705. }
  4706. return this.finishOp(types$1.incDec, 2)
  4707. }
  4708. if (next === 61) { return this.finishOp(types$1.assign, 2) }
  4709. return this.finishOp(types$1.plusMin, 1)
  4710. };
  4711. pp.readToken_lt_gt = function(code) { // '<>'
  4712. var next = this.input.charCodeAt(this.pos + 1);
  4713. var size = 1;
  4714. if (next === code) {
  4715. size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
  4716. if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types$1.assign, size + 1) }
  4717. return this.finishOp(types$1.bitShift, size)
  4718. }
  4719. if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&
  4720. this.input.charCodeAt(this.pos + 3) === 45) {
  4721. // `<!--`, an XML-style comment that should be interpreted as a line comment
  4722. this.skipLineComment(4);
  4723. this.skipSpace();
  4724. return this.nextToken()
  4725. }
  4726. if (next === 61) { size = 2; }
  4727. return this.finishOp(types$1.relational, size)
  4728. };
  4729. pp.readToken_eq_excl = function(code) { // '=!'
  4730. var next = this.input.charCodeAt(this.pos + 1);
  4731. if (next === 61) { return this.finishOp(types$1.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2) }
  4732. if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) { // '=>'
  4733. this.pos += 2;
  4734. return this.finishToken(types$1.arrow)
  4735. }
  4736. return this.finishOp(code === 61 ? types$1.eq : types$1.prefix, 1)
  4737. };
  4738. pp.readToken_question = function() { // '?'
  4739. var ecmaVersion = this.options.ecmaVersion;
  4740. if (ecmaVersion >= 11) {
  4741. var next = this.input.charCodeAt(this.pos + 1);
  4742. if (next === 46) {
  4743. var next2 = this.input.charCodeAt(this.pos + 2);
  4744. if (next2 < 48 || next2 > 57) { return this.finishOp(types$1.questionDot, 2) }
  4745. }
  4746. if (next === 63) {
  4747. if (ecmaVersion >= 12) {
  4748. var next2$1 = this.input.charCodeAt(this.pos + 2);
  4749. if (next2$1 === 61) { return this.finishOp(types$1.assign, 3) }
  4750. }
  4751. return this.finishOp(types$1.coalesce, 2)
  4752. }
  4753. }
  4754. return this.finishOp(types$1.question, 1)
  4755. };
  4756. pp.readToken_numberSign = function() { // '#'
  4757. var ecmaVersion = this.options.ecmaVersion;
  4758. var code = 35; // '#'
  4759. if (ecmaVersion >= 13) {
  4760. ++this.pos;
  4761. code = this.fullCharCodeAtPos();
  4762. if (isIdentifierStart(code, true) || code === 92 /* '\' */) {
  4763. return this.finishToken(types$1.privateId, this.readWord1())
  4764. }
  4765. }
  4766. this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
  4767. };
  4768. pp.getTokenFromCode = function(code) {
  4769. switch (code) {
  4770. // The interpretation of a dot depends on whether it is followed
  4771. // by a digit or another two dots.
  4772. case 46: // '.'
  4773. return this.readToken_dot()
  4774. // Punctuation tokens.
  4775. case 40: ++this.pos; return this.finishToken(types$1.parenL)
  4776. case 41: ++this.pos; return this.finishToken(types$1.parenR)
  4777. case 59: ++this.pos; return this.finishToken(types$1.semi)
  4778. case 44: ++this.pos; return this.finishToken(types$1.comma)
  4779. case 91: ++this.pos; return this.finishToken(types$1.bracketL)
  4780. case 93: ++this.pos; return this.finishToken(types$1.bracketR)
  4781. case 123: ++this.pos; return this.finishToken(types$1.braceL)
  4782. case 125: ++this.pos; return this.finishToken(types$1.braceR)
  4783. case 58: ++this.pos; return this.finishToken(types$1.colon)
  4784. case 96: // '`'
  4785. if (this.options.ecmaVersion < 6) { break }
  4786. ++this.pos;
  4787. return this.finishToken(types$1.backQuote)
  4788. case 48: // '0'
  4789. var next = this.input.charCodeAt(this.pos + 1);
  4790. if (next === 120 || next === 88) { return this.readRadixNumber(16) } // '0x', '0X' - hex number
  4791. if (this.options.ecmaVersion >= 6) {
  4792. if (next === 111 || next === 79) { return this.readRadixNumber(8) } // '0o', '0O' - octal number
  4793. if (next === 98 || next === 66) { return this.readRadixNumber(2) } // '0b', '0B' - binary number
  4794. }
  4795. // Anything else beginning with a digit is an integer, octal
  4796. // number, or float.
  4797. case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: // 1-9
  4798. return this.readNumber(false)
  4799. // Quotes produce strings.
  4800. case 34: case 39: // '"', "'"
  4801. return this.readString(code)
  4802. // Operators are parsed inline in tiny state machines. '=' (61) is
  4803. // often referred to. `finishOp` simply skips the amount of
  4804. // characters it is given as second argument, and returns a token
  4805. // of the type given by its first argument.
  4806. case 47: // '/'
  4807. return this.readToken_slash()
  4808. case 37: case 42: // '%*'
  4809. return this.readToken_mult_modulo_exp(code)
  4810. case 124: case 38: // '|&'
  4811. return this.readToken_pipe_amp(code)
  4812. case 94: // '^'
  4813. return this.readToken_caret()
  4814. case 43: case 45: // '+-'
  4815. return this.readToken_plus_min(code)
  4816. case 60: case 62: // '<>'
  4817. return this.readToken_lt_gt(code)
  4818. case 61: case 33: // '=!'
  4819. return this.readToken_eq_excl(code)
  4820. case 63: // '?'
  4821. return this.readToken_question()
  4822. case 126: // '~'
  4823. return this.finishOp(types$1.prefix, 1)
  4824. case 35: // '#'
  4825. return this.readToken_numberSign()
  4826. }
  4827. this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
  4828. };
  4829. pp.finishOp = function(type, size) {
  4830. var str = this.input.slice(this.pos, this.pos + size);
  4831. this.pos += size;
  4832. return this.finishToken(type, str)
  4833. };
  4834. pp.readRegexp = function() {
  4835. var escaped, inClass, start = this.pos;
  4836. for (;;) {
  4837. if (this.pos >= this.input.length) { this.raise(start, "Unterminated regular expression"); }
  4838. var ch = this.input.charAt(this.pos);
  4839. if (lineBreak.test(ch)) { this.raise(start, "Unterminated regular expression"); }
  4840. if (!escaped) {
  4841. if (ch === "[") { inClass = true; }
  4842. else if (ch === "]" && inClass) { inClass = false; }
  4843. else if (ch === "/" && !inClass) { break }
  4844. escaped = ch === "\\";
  4845. } else { escaped = false; }
  4846. ++this.pos;
  4847. }
  4848. var pattern = this.input.slice(start, this.pos);
  4849. ++this.pos;
  4850. var flagsStart = this.pos;
  4851. var flags = this.readWord1();
  4852. if (this.containsEsc) { this.unexpected(flagsStart); }
  4853. // Validate pattern
  4854. var state = this.regexpState || (this.regexpState = new RegExpValidationState(this));
  4855. state.reset(start, pattern, flags);
  4856. this.validateRegExpFlags(state);
  4857. this.validateRegExpPattern(state);
  4858. // Create Literal#value property value.
  4859. var value = null;
  4860. try {
  4861. value = new RegExp(pattern, flags);
  4862. } catch (e) {
  4863. // ESTree requires null if it failed to instantiate RegExp object.
  4864. // https://github.com/estree/estree/blob/a27003adf4fd7bfad44de9cef372a2eacd527b1c/es5.md#regexpliteral
  4865. }
  4866. return this.finishToken(types$1.regexp, {pattern: pattern, flags: flags, value: value})
  4867. };
  4868. // Read an integer in the given radix. Return null if zero digits
  4869. // were read, the integer value otherwise. When `len` is given, this
  4870. // will return `null` unless the integer has exactly `len` digits.
  4871. pp.readInt = function(radix, len, maybeLegacyOctalNumericLiteral) {
  4872. // `len` is used for character escape sequences. In that case, disallow separators.
  4873. var allowSeparators = this.options.ecmaVersion >= 12 && len === undefined;
  4874. // `maybeLegacyOctalNumericLiteral` is true if it doesn't have prefix (0x,0o,0b)
  4875. // and isn't fraction part nor exponent part. In that case, if the first digit
  4876. // is zero then disallow separators.
  4877. var isLegacyOctalNumericLiteral = maybeLegacyOctalNumericLiteral && this.input.charCodeAt(this.pos) === 48;
  4878. var start = this.pos, total = 0, lastCode = 0;
  4879. for (var i = 0, e = len == null ? Infinity : len; i < e; ++i, ++this.pos) {
  4880. var code = this.input.charCodeAt(this.pos), val = (void 0);
  4881. if (allowSeparators && code === 95) {
  4882. if (isLegacyOctalNumericLiteral) { this.raiseRecoverable(this.pos, "Numeric separator is not allowed in legacy octal numeric literals"); }
  4883. if (lastCode === 95) { this.raiseRecoverable(this.pos, "Numeric separator must be exactly one underscore"); }
  4884. if (i === 0) { this.raiseRecoverable(this.pos, "Numeric separator is not allowed at the first of digits"); }
  4885. lastCode = code;
  4886. continue
  4887. }
  4888. if (code >= 97) { val = code - 97 + 10; } // a
  4889. else if (code >= 65) { val = code - 65 + 10; } // A
  4890. else if (code >= 48 && code <= 57) { val = code - 48; } // 0-9
  4891. else { val = Infinity; }
  4892. if (val >= radix) { break }
  4893. lastCode = code;
  4894. total = total * radix + val;
  4895. }
  4896. if (allowSeparators && lastCode === 95) { this.raiseRecoverable(this.pos - 1, "Numeric separator is not allowed at the last of digits"); }
  4897. if (this.pos === start || len != null && this.pos - start !== len) { return null }
  4898. return total
  4899. };
  4900. function stringToNumber(str, isLegacyOctalNumericLiteral) {
  4901. if (isLegacyOctalNumericLiteral) {
  4902. return parseInt(str, 8)
  4903. }
  4904. // `parseFloat(value)` stops parsing at the first numeric separator then returns a wrong value.
  4905. return parseFloat(str.replace(/_/g, ""))
  4906. }
  4907. function stringToBigInt(str) {
  4908. if (typeof BigInt !== "function") {
  4909. return null
  4910. }
  4911. // `BigInt(value)` throws syntax error if the string contains numeric separators.
  4912. return BigInt(str.replace(/_/g, ""))
  4913. }
  4914. pp.readRadixNumber = function(radix) {
  4915. var start = this.pos;
  4916. this.pos += 2; // 0x
  4917. var val = this.readInt(radix);
  4918. if (val == null) { this.raise(this.start + 2, "Expected number in radix " + radix); }
  4919. if (this.options.ecmaVersion >= 11 && this.input.charCodeAt(this.pos) === 110) {
  4920. val = stringToBigInt(this.input.slice(start, this.pos));
  4921. ++this.pos;
  4922. } else if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
  4923. return this.finishToken(types$1.num, val)
  4924. };
  4925. // Read an integer, octal integer, or floating-point number.
  4926. pp.readNumber = function(startsWithDot) {
  4927. var start = this.pos;
  4928. if (!startsWithDot && this.readInt(10, undefined, true) === null) { this.raise(start, "Invalid number"); }
  4929. var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48;
  4930. if (octal && this.strict) { this.raise(start, "Invalid number"); }
  4931. var next = this.input.charCodeAt(this.pos);
  4932. if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) {
  4933. var val$1 = stringToBigInt(this.input.slice(start, this.pos));
  4934. ++this.pos;
  4935. if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
  4936. return this.finishToken(types$1.num, val$1)
  4937. }
  4938. if (octal && /[89]/.test(this.input.slice(start, this.pos))) { octal = false; }
  4939. if (next === 46 && !octal) { // '.'
  4940. ++this.pos;
  4941. this.readInt(10);
  4942. next = this.input.charCodeAt(this.pos);
  4943. }
  4944. if ((next === 69 || next === 101) && !octal) { // 'eE'
  4945. next = this.input.charCodeAt(++this.pos);
  4946. if (next === 43 || next === 45) { ++this.pos; } // '+-'
  4947. if (this.readInt(10) === null) { this.raise(start, "Invalid number"); }
  4948. }
  4949. if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
  4950. var val = stringToNumber(this.input.slice(start, this.pos), octal);
  4951. return this.finishToken(types$1.num, val)
  4952. };
  4953. // Read a string value, interpreting backslash-escapes.
  4954. pp.readCodePoint = function() {
  4955. var ch = this.input.charCodeAt(this.pos), code;
  4956. if (ch === 123) { // '{'
  4957. if (this.options.ecmaVersion < 6) { this.unexpected(); }
  4958. var codePos = ++this.pos;
  4959. code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
  4960. ++this.pos;
  4961. if (code > 0x10FFFF) { this.invalidStringToken(codePos, "Code point out of bounds"); }
  4962. } else {
  4963. code = this.readHexChar(4);
  4964. }
  4965. return code
  4966. };
  4967. pp.readString = function(quote) {
  4968. var out = "", chunkStart = ++this.pos;
  4969. for (;;) {
  4970. if (this.pos >= this.input.length) { this.raise(this.start, "Unterminated string constant"); }
  4971. var ch = this.input.charCodeAt(this.pos);
  4972. if (ch === quote) { break }
  4973. if (ch === 92) { // '\'
  4974. out += this.input.slice(chunkStart, this.pos);
  4975. out += this.readEscapedChar(false);
  4976. chunkStart = this.pos;
  4977. } else if (ch === 0x2028 || ch === 0x2029) {
  4978. if (this.options.ecmaVersion < 10) { this.raise(this.start, "Unterminated string constant"); }
  4979. ++this.pos;
  4980. if (this.options.locations) {
  4981. this.curLine++;
  4982. this.lineStart = this.pos;
  4983. }
  4984. } else {
  4985. if (isNewLine(ch)) { this.raise(this.start, "Unterminated string constant"); }
  4986. ++this.pos;
  4987. }
  4988. }
  4989. out += this.input.slice(chunkStart, this.pos++);
  4990. return this.finishToken(types$1.string, out)
  4991. };
  4992. // Reads template string tokens.
  4993. var INVALID_TEMPLATE_ESCAPE_ERROR = {};
  4994. pp.tryReadTemplateToken = function() {
  4995. this.inTemplateElement = true;
  4996. try {
  4997. this.readTmplToken();
  4998. } catch (err) {
  4999. if (err === INVALID_TEMPLATE_ESCAPE_ERROR) {
  5000. this.readInvalidTemplateToken();
  5001. } else {
  5002. throw err
  5003. }
  5004. }
  5005. this.inTemplateElement = false;
  5006. };
  5007. pp.invalidStringToken = function(position, message) {
  5008. if (this.inTemplateElement && this.options.ecmaVersion >= 9) {
  5009. throw INVALID_TEMPLATE_ESCAPE_ERROR
  5010. } else {
  5011. this.raise(position, message);
  5012. }
  5013. };
  5014. pp.readTmplToken = function() {
  5015. var out = "", chunkStart = this.pos;
  5016. for (;;) {
  5017. if (this.pos >= this.input.length) { this.raise(this.start, "Unterminated template"); }
  5018. var ch = this.input.charCodeAt(this.pos);
  5019. if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) { // '`', '${'
  5020. if (this.pos === this.start && (this.type === types$1.template || this.type === types$1.invalidTemplate)) {
  5021. if (ch === 36) {
  5022. this.pos += 2;
  5023. return this.finishToken(types$1.dollarBraceL)
  5024. } else {
  5025. ++this.pos;
  5026. return this.finishToken(types$1.backQuote)
  5027. }
  5028. }
  5029. out += this.input.slice(chunkStart, this.pos);
  5030. return this.finishToken(types$1.template, out)
  5031. }
  5032. if (ch === 92) { // '\'
  5033. out += this.input.slice(chunkStart, this.pos);
  5034. out += this.readEscapedChar(true);
  5035. chunkStart = this.pos;
  5036. } else if (isNewLine(ch)) {
  5037. out += this.input.slice(chunkStart, this.pos);
  5038. ++this.pos;
  5039. switch (ch) {
  5040. case 13:
  5041. if (this.input.charCodeAt(this.pos) === 10) { ++this.pos; }
  5042. case 10:
  5043. out += "\n";
  5044. break
  5045. default:
  5046. out += String.fromCharCode(ch);
  5047. break
  5048. }
  5049. if (this.options.locations) {
  5050. ++this.curLine;
  5051. this.lineStart = this.pos;
  5052. }
  5053. chunkStart = this.pos;
  5054. } else {
  5055. ++this.pos;
  5056. }
  5057. }
  5058. };
  5059. // Reads a template token to search for the end, without validating any escape sequences
  5060. pp.readInvalidTemplateToken = function() {
  5061. for (; this.pos < this.input.length; this.pos++) {
  5062. switch (this.input[this.pos]) {
  5063. case "\\":
  5064. ++this.pos;
  5065. break
  5066. case "$":
  5067. if (this.input[this.pos + 1] !== "{") {
  5068. break
  5069. }
  5070. // falls through
  5071. case "`":
  5072. return this.finishToken(types$1.invalidTemplate, this.input.slice(this.start, this.pos))
  5073. // no default
  5074. }
  5075. }
  5076. this.raise(this.start, "Unterminated template");
  5077. };
  5078. // Used to read escaped characters
  5079. pp.readEscapedChar = function(inTemplate) {
  5080. var ch = this.input.charCodeAt(++this.pos);
  5081. ++this.pos;
  5082. switch (ch) {
  5083. case 110: return "\n" // 'n' -> '\n'
  5084. case 114: return "\r" // 'r' -> '\r'
  5085. case 120: return String.fromCharCode(this.readHexChar(2)) // 'x'
  5086. case 117: return codePointToString(this.readCodePoint()) // 'u'
  5087. case 116: return "\t" // 't' -> '\t'
  5088. case 98: return "\b" // 'b' -> '\b'
  5089. case 118: return "\u000b" // 'v' -> '\u000b'
  5090. case 102: return "\f" // 'f' -> '\f'
  5091. case 13: if (this.input.charCodeAt(this.pos) === 10) { ++this.pos; } // '\r\n'
  5092. case 10: // ' \n'
  5093. if (this.options.locations) { this.lineStart = this.pos; ++this.curLine; }
  5094. return ""
  5095. case 56:
  5096. case 57:
  5097. if (this.strict) {
  5098. this.invalidStringToken(
  5099. this.pos - 1,
  5100. "Invalid escape sequence"
  5101. );
  5102. }
  5103. if (inTemplate) {
  5104. var codePos = this.pos - 1;
  5105. this.invalidStringToken(
  5106. codePos,
  5107. "Invalid escape sequence in template string"
  5108. );
  5109. }
  5110. default:
  5111. if (ch >= 48 && ch <= 55) {
  5112. var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0];
  5113. var octal = parseInt(octalStr, 8);
  5114. if (octal > 255) {
  5115. octalStr = octalStr.slice(0, -1);
  5116. octal = parseInt(octalStr, 8);
  5117. }
  5118. this.pos += octalStr.length - 1;
  5119. ch = this.input.charCodeAt(this.pos);
  5120. if ((octalStr !== "0" || ch === 56 || ch === 57) && (this.strict || inTemplate)) {
  5121. this.invalidStringToken(
  5122. this.pos - 1 - octalStr.length,
  5123. inTemplate
  5124. ? "Octal literal in template string"
  5125. : "Octal literal in strict mode"
  5126. );
  5127. }
  5128. return String.fromCharCode(octal)
  5129. }
  5130. if (isNewLine(ch)) {
  5131. // Unicode new line characters after \ get removed from output in both
  5132. // template literals and strings
  5133. return ""
  5134. }
  5135. return String.fromCharCode(ch)
  5136. }
  5137. };
  5138. // Used to read character escape sequences ('\x', '\u', '\U').
  5139. pp.readHexChar = function(len) {
  5140. var codePos = this.pos;
  5141. var n = this.readInt(16, len);
  5142. if (n === null) { this.invalidStringToken(codePos, "Bad character escape sequence"); }
  5143. return n
  5144. };
  5145. // Read an identifier, and return it as a string. Sets `this.containsEsc`
  5146. // to whether the word contained a '\u' escape.
  5147. //
  5148. // Incrementally adds only escaped chars, adding other chunks as-is
  5149. // as a micro-optimization.
  5150. pp.readWord1 = function() {
  5151. this.containsEsc = false;
  5152. var word = "", first = true, chunkStart = this.pos;
  5153. var astral = this.options.ecmaVersion >= 6;
  5154. while (this.pos < this.input.length) {
  5155. var ch = this.fullCharCodeAtPos();
  5156. if (isIdentifierChar(ch, astral)) {
  5157. this.pos += ch <= 0xffff ? 1 : 2;
  5158. } else if (ch === 92) { // "\"
  5159. this.containsEsc = true;
  5160. word += this.input.slice(chunkStart, this.pos);
  5161. var escStart = this.pos;
  5162. if (this.input.charCodeAt(++this.pos) !== 117) // "u"
  5163. { this.invalidStringToken(this.pos, "Expecting Unicode escape sequence \\uXXXX"); }
  5164. ++this.pos;
  5165. var esc = this.readCodePoint();
  5166. if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral))
  5167. { this.invalidStringToken(escStart, "Invalid Unicode escape"); }
  5168. word += codePointToString(esc);
  5169. chunkStart = this.pos;
  5170. } else {
  5171. break
  5172. }
  5173. first = false;
  5174. }
  5175. return word + this.input.slice(chunkStart, this.pos)
  5176. };
  5177. // Read an identifier or keyword token. Will check for reserved
  5178. // words when necessary.
  5179. pp.readWord = function() {
  5180. var word = this.readWord1();
  5181. var type = types$1.name;
  5182. if (this.keywords.test(word)) {
  5183. type = keywords[word];
  5184. }
  5185. return this.finishToken(type, word)
  5186. };
  5187. // Acorn is a tiny, fast JavaScript parser written in JavaScript.
  5188. //
  5189. // Acorn was written by Marijn Haverbeke, Ingvar Stepanyan, and
  5190. // various contributors and released under an MIT license.
  5191. //
  5192. // Git repositories for Acorn are available at
  5193. //
  5194. // http://marijnhaverbeke.nl/git/acorn
  5195. // https://github.com/acornjs/acorn.git
  5196. //
  5197. // Please use the [github bug tracker][ghbt] to report issues.
  5198. //
  5199. // [ghbt]: https://github.com/acornjs/acorn/issues
  5200. //
  5201. // [walk]: util/walk.js
  5202. var version = "8.10.0";
  5203. Parser.acorn = {
  5204. Parser: Parser,
  5205. version: version,
  5206. defaultOptions: defaultOptions,
  5207. Position: Position,
  5208. SourceLocation: SourceLocation,
  5209. getLineInfo: getLineInfo,
  5210. Node: Node,
  5211. TokenType: TokenType,
  5212. tokTypes: types$1,
  5213. keywordTypes: keywords,
  5214. TokContext: TokContext,
  5215. tokContexts: types,
  5216. isIdentifierChar: isIdentifierChar,
  5217. isIdentifierStart: isIdentifierStart,
  5218. Token: Token,
  5219. isNewLine: isNewLine,
  5220. lineBreak: lineBreak,
  5221. lineBreakG: lineBreakG,
  5222. nonASCIIwhitespace: nonASCIIwhitespace
  5223. };
  5224. // The main exported interface (under `self.acorn` when in the
  5225. // browser) is a `parse` function that takes a code string and
  5226. // returns an abstract syntax tree as specified by [Mozilla parser
  5227. // API][api].
  5228. //
  5229. // [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
  5230. function parse(input, options) {
  5231. return Parser.parse(input, options)
  5232. }
  5233. // This function tries to parse a single expression at a given
  5234. // offset in a string. Useful for parsing mixed-language formats
  5235. // that embed JavaScript expressions.
  5236. function parseExpressionAt(input, pos, options) {
  5237. return Parser.parseExpressionAt(input, pos, options)
  5238. }
  5239. // Acorn is organized as a tokenizer and a recursive-descent parser.
  5240. // The `tokenizer` export provides an interface to the tokenizer.
  5241. function tokenizer(input, options) {
  5242. return Parser.tokenizer(input, options)
  5243. }
  5244. exports.Node = Node;
  5245. exports.Parser = Parser;
  5246. exports.Position = Position;
  5247. exports.SourceLocation = SourceLocation;
  5248. exports.TokContext = TokContext;
  5249. exports.Token = Token;
  5250. exports.TokenType = TokenType;
  5251. exports.defaultOptions = defaultOptions;
  5252. exports.getLineInfo = getLineInfo;
  5253. exports.isIdentifierChar = isIdentifierChar;
  5254. exports.isIdentifierStart = isIdentifierStart;
  5255. exports.isNewLine = isNewLine;
  5256. exports.keywordTypes = keywords;
  5257. exports.lineBreak = lineBreak;
  5258. exports.lineBreakG = lineBreakG;
  5259. exports.nonASCIIwhitespace = nonASCIIwhitespace;
  5260. exports.parse = parse;
  5261. exports.parseExpressionAt = parseExpressionAt;
  5262. exports.tokContexts = types;
  5263. exports.tokTypes = types$1;
  5264. exports.tokenizer = tokenizer;
  5265. exports.version = version;
  5266. }));