Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

acorn.js 176KB

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