acorn_csp.js 132 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985
  1. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.acorn = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
  2. // The main exported interface (under `self.acorn` when in the
  3. // browser) is a `parse` function that takes a code string and
  4. // returns an abstract syntax tree as specified by [Mozilla parser
  5. // API][api].
  6. //
  7. // [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
  8. "use strict";
  9. exports.parse = parse;
  10. // This function tries to parse a single expression at a given
  11. // offset in a string. Useful for parsing mixed-language formats
  12. // that embed JavaScript expressions.
  13. exports.parseExpressionAt = parseExpressionAt;
  14. // Acorn is organized as a tokenizer and a recursive-descent parser.
  15. // The `tokenize` export provides an interface to the tokenizer.
  16. exports.tokenizer = tokenizer;
  17. exports.__esModule = true;
  18. // Acorn is a tiny, fast JavaScript parser written in JavaScript.
  19. //
  20. // Acorn was written by Marijn Haverbeke, Ingvar Stepanyan, and
  21. // various contributors and released under an MIT license.
  22. //
  23. // Git repositories for Acorn are available at
  24. //
  25. // http://marijnhaverbeke.nl/git/acorn
  26. // https://github.com/marijnh/acorn.git
  27. //
  28. // Please use the [github bug tracker][ghbt] to report issues.
  29. //
  30. // [ghbt]: https://github.com/marijnh/acorn/issues
  31. //
  32. // This file defines the main parser interface. The library also comes
  33. // with a [error-tolerant parser][dammit] and an
  34. // [abstract syntax tree walker][walk], defined in other files.
  35. //
  36. // [dammit]: acorn_loose.js
  37. // [walk]: util/walk.js
  38. var _state = _dereq_("./state");
  39. var Parser = _state.Parser;
  40. var _options = _dereq_("./options");
  41. var getOptions = _options.getOptions;
  42. _dereq_("./parseutil");
  43. _dereq_("./statement");
  44. _dereq_("./lval");
  45. _dereq_("./expression");
  46. exports.Parser = _state.Parser;
  47. exports.plugins = _state.plugins;
  48. exports.defaultOptions = _options.defaultOptions;
  49. var _location = _dereq_("./location");
  50. exports.SourceLocation = _location.SourceLocation;
  51. exports.getLineInfo = _location.getLineInfo;
  52. exports.Node = _dereq_("./node").Node;
  53. var _tokentype = _dereq_("./tokentype");
  54. exports.TokenType = _tokentype.TokenType;
  55. exports.tokTypes = _tokentype.types;
  56. var _tokencontext = _dereq_("./tokencontext");
  57. exports.TokContext = _tokencontext.TokContext;
  58. exports.tokContexts = _tokencontext.types;
  59. var _identifier = _dereq_("./identifier");
  60. exports.isIdentifierChar = _identifier.isIdentifierChar;
  61. exports.isIdentifierStart = _identifier.isIdentifierStart;
  62. exports.Token = _dereq_("./tokenize").Token;
  63. var _whitespace = _dereq_("./whitespace");
  64. exports.isNewLine = _whitespace.isNewLine;
  65. exports.lineBreak = _whitespace.lineBreak;
  66. exports.lineBreakG = _whitespace.lineBreakG;
  67. var version = "1.2.2";exports.version = version;
  68. function parse(input, options) {
  69. var p = parser(options, input);
  70. var startPos = p.pos,
  71. startLoc = p.options.locations && p.curPosition();
  72. p.nextToken();
  73. return p.parseTopLevel(p.options.program || p.startNodeAt(startPos, startLoc));
  74. }
  75. function parseExpressionAt(input, pos, options) {
  76. var p = parser(options, input, pos);
  77. p.nextToken();
  78. return p.parseExpression();
  79. }
  80. function tokenizer(input, options) {
  81. return parser(options, input);
  82. }
  83. function parser(options, input) {
  84. return new Parser(getOptions(options), String(input));
  85. }
  86. },{"./expression":6,"./identifier":7,"./location":8,"./lval":9,"./node":10,"./options":11,"./parseutil":12,"./state":13,"./statement":14,"./tokencontext":15,"./tokenize":16,"./tokentype":17,"./whitespace":19}],2:[function(_dereq_,module,exports){
  87. if (typeof Object.create === 'function') {
  88. // implementation from standard node.js 'util' module
  89. module.exports = function inherits(ctor, superCtor) {
  90. ctor.super_ = superCtor
  91. ctor.prototype = Object.create(superCtor.prototype, {
  92. constructor: {
  93. value: ctor,
  94. enumerable: false,
  95. writable: true,
  96. configurable: true
  97. }
  98. });
  99. };
  100. } else {
  101. // old school shim for old browsers
  102. module.exports = function inherits(ctor, superCtor) {
  103. ctor.super_ = superCtor
  104. var TempCtor = function () {}
  105. TempCtor.prototype = superCtor.prototype
  106. ctor.prototype = new TempCtor()
  107. ctor.prototype.constructor = ctor
  108. }
  109. }
  110. },{}],3:[function(_dereq_,module,exports){
  111. // shim for using process in browser
  112. var process = module.exports = {};
  113. var queue = [];
  114. var draining = false;
  115. function drainQueue() {
  116. if (draining) {
  117. return;
  118. }
  119. draining = true;
  120. var currentQueue;
  121. var len = queue.length;
  122. while(len) {
  123. currentQueue = queue;
  124. queue = [];
  125. var i = -1;
  126. while (++i < len) {
  127. currentQueue[i]();
  128. }
  129. len = queue.length;
  130. }
  131. draining = false;
  132. }
  133. process.nextTick = function (fun) {
  134. queue.push(fun);
  135. if (!draining) {
  136. setTimeout(drainQueue, 0);
  137. }
  138. };
  139. process.title = 'browser';
  140. process.browser = true;
  141. process.env = {};
  142. process.argv = [];
  143. process.version = ''; // empty string to avoid regexp issues
  144. process.versions = {};
  145. function noop() {}
  146. process.on = noop;
  147. process.addListener = noop;
  148. process.once = noop;
  149. process.off = noop;
  150. process.removeListener = noop;
  151. process.removeAllListeners = noop;
  152. process.emit = noop;
  153. process.binding = function (name) {
  154. throw new Error('process.binding is not supported');
  155. };
  156. // TODO(shtylman)
  157. process.cwd = function () { return '/' };
  158. process.chdir = function (dir) {
  159. throw new Error('process.chdir is not supported');
  160. };
  161. process.umask = function() { return 0; };
  162. },{}],4:[function(_dereq_,module,exports){
  163. module.exports = function isBuffer(arg) {
  164. return arg && typeof arg === 'object'
  165. && typeof arg.copy === 'function'
  166. && typeof arg.fill === 'function'
  167. && typeof arg.readUInt8 === 'function';
  168. }
  169. },{}],5:[function(_dereq_,module,exports){
  170. (function (process,global){
  171. // Copyright Joyent, Inc. and other Node contributors.
  172. //
  173. // Permission is hereby granted, free of charge, to any person obtaining a
  174. // copy of this software and associated documentation files (the
  175. // "Software"), to deal in the Software without restriction, including
  176. // without limitation the rights to use, copy, modify, merge, publish,
  177. // distribute, sublicense, and/or sell copies of the Software, and to permit
  178. // persons to whom the Software is furnished to do so, subject to the
  179. // following conditions:
  180. //
  181. // The above copyright notice and this permission notice shall be included
  182. // in all copies or substantial portions of the Software.
  183. //
  184. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  185. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  186. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  187. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  188. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  189. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  190. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  191. var formatRegExp = /%[sdj%]/g;
  192. exports.format = function(f) {
  193. if (!isString(f)) {
  194. var objects = [];
  195. for (var i = 0; i < arguments.length; i++) {
  196. objects.push(inspect(arguments[i]));
  197. }
  198. return objects.join(' ');
  199. }
  200. var i = 1;
  201. var args = arguments;
  202. var len = args.length;
  203. var str = String(f).replace(formatRegExp, function(x) {
  204. if (x === '%%') return '%';
  205. if (i >= len) return x;
  206. switch (x) {
  207. case '%s': return String(args[i++]);
  208. case '%d': return Number(args[i++]);
  209. case '%j':
  210. try {
  211. return JSON.stringify(args[i++]);
  212. } catch (_) {
  213. return '[Circular]';
  214. }
  215. default:
  216. return x;
  217. }
  218. });
  219. for (var x = args[i]; i < len; x = args[++i]) {
  220. if (isNull(x) || !isObject(x)) {
  221. str += ' ' + x;
  222. } else {
  223. str += ' ' + inspect(x);
  224. }
  225. }
  226. return str;
  227. };
  228. // Mark that a method should not be used.
  229. // Returns a modified function which warns once by default.
  230. // If --no-deprecation is set, then it is a no-op.
  231. exports.deprecate = function(fn, msg) {
  232. // Allow for deprecating things in the process of starting up.
  233. if (isUndefined(global.process)) {
  234. return function() {
  235. return exports.deprecate(fn, msg).apply(this, arguments);
  236. };
  237. }
  238. if (process.noDeprecation === true) {
  239. return fn;
  240. }
  241. var warned = false;
  242. function deprecated() {
  243. if (!warned) {
  244. if (process.throwDeprecation) {
  245. throw new Error(msg);
  246. } else if (process.traceDeprecation) {
  247. console.trace(msg);
  248. } else {
  249. console.error(msg);
  250. }
  251. warned = true;
  252. }
  253. return fn.apply(this, arguments);
  254. }
  255. return deprecated;
  256. };
  257. var debugs = {};
  258. var debugEnviron;
  259. exports.debuglog = function(set) {
  260. if (isUndefined(debugEnviron))
  261. debugEnviron = process.env.NODE_DEBUG || '';
  262. set = set.toUpperCase();
  263. if (!debugs[set]) {
  264. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  265. var pid = process.pid;
  266. debugs[set] = function() {
  267. var msg = exports.format.apply(exports, arguments);
  268. console.error('%s %d: %s', set, pid, msg);
  269. };
  270. } else {
  271. debugs[set] = function() {};
  272. }
  273. }
  274. return debugs[set];
  275. };
  276. /**
  277. * Echos the value of a value. Trys to print the value out
  278. * in the best way possible given the different types.
  279. *
  280. * @param {Object} obj The object to print out.
  281. * @param {Object} opts Optional options object that alters the output.
  282. */
  283. /* legacy: obj, showHidden, depth, colors*/
  284. function inspect(obj, opts) {
  285. // default options
  286. var ctx = {
  287. seen: [],
  288. stylize: stylizeNoColor
  289. };
  290. // legacy...
  291. if (arguments.length >= 3) ctx.depth = arguments[2];
  292. if (arguments.length >= 4) ctx.colors = arguments[3];
  293. if (isBoolean(opts)) {
  294. // legacy...
  295. ctx.showHidden = opts;
  296. } else if (opts) {
  297. // got an "options" object
  298. exports._extend(ctx, opts);
  299. }
  300. // set default options
  301. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  302. if (isUndefined(ctx.depth)) ctx.depth = 2;
  303. if (isUndefined(ctx.colors)) ctx.colors = false;
  304. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  305. if (ctx.colors) ctx.stylize = stylizeWithColor;
  306. return formatValue(ctx, obj, ctx.depth);
  307. }
  308. exports.inspect = inspect;
  309. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  310. inspect.colors = {
  311. 'bold' : [1, 22],
  312. 'italic' : [3, 23],
  313. 'underline' : [4, 24],
  314. 'inverse' : [7, 27],
  315. 'white' : [37, 39],
  316. 'grey' : [90, 39],
  317. 'black' : [30, 39],
  318. 'blue' : [34, 39],
  319. 'cyan' : [36, 39],
  320. 'green' : [32, 39],
  321. 'magenta' : [35, 39],
  322. 'red' : [31, 39],
  323. 'yellow' : [33, 39]
  324. };
  325. // Don't use 'blue' not visible on cmd.exe
  326. inspect.styles = {
  327. 'special': 'cyan',
  328. 'number': 'yellow',
  329. 'boolean': 'yellow',
  330. 'undefined': 'grey',
  331. 'null': 'bold',
  332. 'string': 'green',
  333. 'date': 'magenta',
  334. // "name": intentionally not styling
  335. 'regexp': 'red'
  336. };
  337. function stylizeWithColor(str, styleType) {
  338. var style = inspect.styles[styleType];
  339. if (style) {
  340. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  341. '\u001b[' + inspect.colors[style][1] + 'm';
  342. } else {
  343. return str;
  344. }
  345. }
  346. function stylizeNoColor(str, styleType) {
  347. return str;
  348. }
  349. function arrayToHash(array) {
  350. var hash = {};
  351. array.forEach(function(val, idx) {
  352. hash[val] = true;
  353. });
  354. return hash;
  355. }
  356. function formatValue(ctx, value, recurseTimes) {
  357. // Provide a hook for user-specified inspect functions.
  358. // Check that value is an object with an inspect function on it
  359. if (ctx.customInspect &&
  360. value &&
  361. isFunction(value.inspect) &&
  362. // Filter out the util module, it's inspect function is special
  363. value.inspect !== exports.inspect &&
  364. // Also filter out any prototype objects using the circular check.
  365. !(value.constructor && value.constructor.prototype === value)) {
  366. var ret = value.inspect(recurseTimes, ctx);
  367. if (!isString(ret)) {
  368. ret = formatValue(ctx, ret, recurseTimes);
  369. }
  370. return ret;
  371. }
  372. // Primitive types cannot have properties
  373. var primitive = formatPrimitive(ctx, value);
  374. if (primitive) {
  375. return primitive;
  376. }
  377. // Look up the keys of the object.
  378. var keys = Object.keys(value);
  379. var visibleKeys = arrayToHash(keys);
  380. if (ctx.showHidden) {
  381. keys = Object.getOwnPropertyNames(value);
  382. }
  383. // IE doesn't make error fields non-enumerable
  384. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  385. if (isError(value)
  386. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  387. return formatError(value);
  388. }
  389. // Some type of object without properties can be shortcutted.
  390. if (keys.length === 0) {
  391. if (isFunction(value)) {
  392. var name = value.name ? ': ' + value.name : '';
  393. return ctx.stylize('[Function' + name + ']', 'special');
  394. }
  395. if (isRegExp(value)) {
  396. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  397. }
  398. if (isDate(value)) {
  399. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  400. }
  401. if (isError(value)) {
  402. return formatError(value);
  403. }
  404. }
  405. var base = '', array = false, braces = ['{', '}'];
  406. // Make Array say that they are Array
  407. if (isArray(value)) {
  408. array = true;
  409. braces = ['[', ']'];
  410. }
  411. // Make functions say that they are functions
  412. if (isFunction(value)) {
  413. var n = value.name ? ': ' + value.name : '';
  414. base = ' [Function' + n + ']';
  415. }
  416. // Make RegExps say that they are RegExps
  417. if (isRegExp(value)) {
  418. base = ' ' + RegExp.prototype.toString.call(value);
  419. }
  420. // Make dates with properties first say the date
  421. if (isDate(value)) {
  422. base = ' ' + Date.prototype.toUTCString.call(value);
  423. }
  424. // Make error with message first say the error
  425. if (isError(value)) {
  426. base = ' ' + formatError(value);
  427. }
  428. if (keys.length === 0 && (!array || value.length == 0)) {
  429. return braces[0] + base + braces[1];
  430. }
  431. if (recurseTimes < 0) {
  432. if (isRegExp(value)) {
  433. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  434. } else {
  435. return ctx.stylize('[Object]', 'special');
  436. }
  437. }
  438. ctx.seen.push(value);
  439. var output;
  440. if (array) {
  441. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  442. } else {
  443. output = keys.map(function(key) {
  444. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  445. });
  446. }
  447. ctx.seen.pop();
  448. return reduceToSingleString(output, base, braces);
  449. }
  450. function formatPrimitive(ctx, value) {
  451. if (isUndefined(value))
  452. return ctx.stylize('undefined', 'undefined');
  453. if (isString(value)) {
  454. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  455. .replace(/'/g, "\\'")
  456. .replace(/\\"/g, '"') + '\'';
  457. return ctx.stylize(simple, 'string');
  458. }
  459. if (isNumber(value))
  460. return ctx.stylize('' + value, 'number');
  461. if (isBoolean(value))
  462. return ctx.stylize('' + value, 'boolean');
  463. // For some reason typeof null is "object", so special case here.
  464. if (isNull(value))
  465. return ctx.stylize('null', 'null');
  466. }
  467. function formatError(value) {
  468. return '[' + Error.prototype.toString.call(value) + ']';
  469. }
  470. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  471. var output = [];
  472. for (var i = 0, l = value.length; i < l; ++i) {
  473. if (hasOwnProperty(value, String(i))) {
  474. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  475. String(i), true));
  476. } else {
  477. output.push('');
  478. }
  479. }
  480. keys.forEach(function(key) {
  481. if (!key.match(/^\d+$/)) {
  482. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  483. key, true));
  484. }
  485. });
  486. return output;
  487. }
  488. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  489. var name, str, desc;
  490. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  491. if (desc.get) {
  492. if (desc.set) {
  493. str = ctx.stylize('[Getter/Setter]', 'special');
  494. } else {
  495. str = ctx.stylize('[Getter]', 'special');
  496. }
  497. } else {
  498. if (desc.set) {
  499. str = ctx.stylize('[Setter]', 'special');
  500. }
  501. }
  502. if (!hasOwnProperty(visibleKeys, key)) {
  503. name = '[' + key + ']';
  504. }
  505. if (!str) {
  506. if (ctx.seen.indexOf(desc.value) < 0) {
  507. if (isNull(recurseTimes)) {
  508. str = formatValue(ctx, desc.value, null);
  509. } else {
  510. str = formatValue(ctx, desc.value, recurseTimes - 1);
  511. }
  512. if (str.indexOf('\n') > -1) {
  513. if (array) {
  514. str = str.split('\n').map(function(line) {
  515. return ' ' + line;
  516. }).join('\n').substr(2);
  517. } else {
  518. str = '\n' + str.split('\n').map(function(line) {
  519. return ' ' + line;
  520. }).join('\n');
  521. }
  522. }
  523. } else {
  524. str = ctx.stylize('[Circular]', 'special');
  525. }
  526. }
  527. if (isUndefined(name)) {
  528. if (array && key.match(/^\d+$/)) {
  529. return str;
  530. }
  531. name = JSON.stringify('' + key);
  532. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  533. name = name.substr(1, name.length - 2);
  534. name = ctx.stylize(name, 'name');
  535. } else {
  536. name = name.replace(/'/g, "\\'")
  537. .replace(/\\"/g, '"')
  538. .replace(/(^"|"$)/g, "'");
  539. name = ctx.stylize(name, 'string');
  540. }
  541. }
  542. return name + ': ' + str;
  543. }
  544. function reduceToSingleString(output, base, braces) {
  545. var numLinesEst = 0;
  546. var length = output.reduce(function(prev, cur) {
  547. numLinesEst++;
  548. if (cur.indexOf('\n') >= 0) numLinesEst++;
  549. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  550. }, 0);
  551. if (length > 60) {
  552. return braces[0] +
  553. (base === '' ? '' : base + '\n ') +
  554. ' ' +
  555. output.join(',\n ') +
  556. ' ' +
  557. braces[1];
  558. }
  559. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  560. }
  561. // NOTE: These type checking functions intentionally don't use `instanceof`
  562. // because it is fragile and can be easily faked with `Object.create()`.
  563. function isArray(ar) {
  564. return Array.isArray(ar);
  565. }
  566. exports.isArray = isArray;
  567. function isBoolean(arg) {
  568. return typeof arg === 'boolean';
  569. }
  570. exports.isBoolean = isBoolean;
  571. function isNull(arg) {
  572. return arg === null;
  573. }
  574. exports.isNull = isNull;
  575. function isNullOrUndefined(arg) {
  576. return arg == null;
  577. }
  578. exports.isNullOrUndefined = isNullOrUndefined;
  579. function isNumber(arg) {
  580. return typeof arg === 'number';
  581. }
  582. exports.isNumber = isNumber;
  583. function isString(arg) {
  584. return typeof arg === 'string';
  585. }
  586. exports.isString = isString;
  587. function isSymbol(arg) {
  588. return typeof arg === 'symbol';
  589. }
  590. exports.isSymbol = isSymbol;
  591. function isUndefined(arg) {
  592. return arg === void 0;
  593. }
  594. exports.isUndefined = isUndefined;
  595. function isRegExp(re) {
  596. return isObject(re) && objectToString(re) === '[object RegExp]';
  597. }
  598. exports.isRegExp = isRegExp;
  599. function isObject(arg) {
  600. return typeof arg === 'object' && arg !== null;
  601. }
  602. exports.isObject = isObject;
  603. function isDate(d) {
  604. return isObject(d) && objectToString(d) === '[object Date]';
  605. }
  606. exports.isDate = isDate;
  607. function isError(e) {
  608. return isObject(e) &&
  609. (objectToString(e) === '[object Error]' || e instanceof Error);
  610. }
  611. exports.isError = isError;
  612. function isFunction(arg) {
  613. return typeof arg === 'function';
  614. }
  615. exports.isFunction = isFunction;
  616. function isPrimitive(arg) {
  617. return arg === null ||
  618. typeof arg === 'boolean' ||
  619. typeof arg === 'number' ||
  620. typeof arg === 'string' ||
  621. typeof arg === 'symbol' || // ES6 symbol
  622. typeof arg === 'undefined';
  623. }
  624. exports.isPrimitive = isPrimitive;
  625. exports.isBuffer = _dereq_('./support/isBuffer');
  626. function objectToString(o) {
  627. return Object.prototype.toString.call(o);
  628. }
  629. function pad(n) {
  630. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  631. }
  632. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  633. 'Oct', 'Nov', 'Dec'];
  634. // 26 Feb 16:19:34
  635. function timestamp() {
  636. var d = new Date();
  637. var time = [pad(d.getHours()),
  638. pad(d.getMinutes()),
  639. pad(d.getSeconds())].join(':');
  640. return [d.getDate(), months[d.getMonth()], time].join(' ');
  641. }
  642. // log is just a thin wrapper to console.log that prepends a timestamp
  643. exports.log = function() {
  644. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  645. };
  646. /**
  647. * Inherit the prototype methods from one constructor into another.
  648. *
  649. * The Function.prototype.inherits from lang.js rewritten as a standalone
  650. * function (not on Function.prototype). NOTE: If this file is to be loaded
  651. * during bootstrapping this function needs to be rewritten using some native
  652. * functions as prototype setup using normal JavaScript does not work as
  653. * expected during bootstrapping (see mirror.js in r114903).
  654. *
  655. * @param {function} ctor Constructor function which needs to inherit the
  656. * prototype.
  657. * @param {function} superCtor Constructor function to inherit prototype from.
  658. */
  659. exports.inherits = _dereq_('inherits');
  660. exports._extend = function(origin, add) {
  661. // Don't do anything if add isn't an object
  662. if (!add || !isObject(add)) return origin;
  663. var keys = Object.keys(add);
  664. var i = keys.length;
  665. while (i--) {
  666. origin[keys[i]] = add[keys[i]];
  667. }
  668. return origin;
  669. };
  670. function hasOwnProperty(obj, prop) {
  671. return Object.prototype.hasOwnProperty.call(obj, prop);
  672. }
  673. }).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  674. },{"./support/isBuffer":4,"_process":3,"inherits":2}],6:[function(_dereq_,module,exports){
  675. // A recursive descent parser operates by defining functions for all
  676. // syntactic elements, and recursively calling those, each function
  677. // advancing the input stream and returning an AST node. Precedence
  678. // of constructs (for example, the fact that `!x[1]` means `!(x[1])`
  679. // instead of `(!x)[1]` is handled by the fact that the parser
  680. // function that parses unary prefix operators is called first, and
  681. // in turn calls the function that parses `[]` subscripts — that
  682. // way, it'll receive the node for `x[1]` already parsed, and wraps
  683. // *that* in the unary operator node.
  684. //
  685. // Acorn uses an [operator precedence parser][opp] to handle binary
  686. // operator precedence, because it is much more compact than using
  687. // the technique outlined above, which uses different, nesting
  688. // functions to specify precedence, for all of the ten binary
  689. // precedence levels that JavaScript defines.
  690. //
  691. // [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser
  692. "use strict";
  693. var tt = _dereq_("./tokentype").types;
  694. var Parser = _dereq_("./state").Parser;
  695. var reservedWords = _dereq_("./identifier").reservedWords;
  696. var has = _dereq_("./util").has;
  697. var pp = Parser.prototype;
  698. // Check if property name clashes with already added.
  699. // Object/class getters and setters are not allowed to clash —
  700. // either with each other or with an init property — and in
  701. // strict mode, init properties are also not allowed to be repeated.
  702. pp.checkPropClash = function (prop, propHash) {
  703. if (this.options.ecmaVersion >= 6) return;
  704. var key = prop.key,
  705. name = undefined;
  706. switch (key.type) {
  707. case "Identifier":
  708. name = key.name;break;
  709. case "Literal":
  710. name = String(key.value);break;
  711. default:
  712. return;
  713. }
  714. var kind = prop.kind || "init",
  715. other = undefined;
  716. if (has(propHash, name)) {
  717. other = propHash[name];
  718. var isGetSet = kind !== "init";
  719. if ((this.strict || isGetSet) && other[kind] || !(isGetSet ^ other.init)) this.raise(key.start, "Redefinition of property");
  720. } else {
  721. other = propHash[name] = {
  722. init: false,
  723. get: false,
  724. set: false
  725. };
  726. }
  727. other[kind] = true;
  728. };
  729. // ### Expression parsing
  730. // These nest, from the most general expression type at the top to
  731. // 'atomic', nondivisible expression types at the bottom. Most of
  732. // the functions will simply let the function(s) below them parse,
  733. // and, *if* the syntactic construct they handle is present, wrap
  734. // the AST node that the inner parser gave them in another node.
  735. // Parse a full expression. The optional arguments are used to
  736. // forbid the `in` operator (in for loops initalization expressions)
  737. // and provide reference for storing '=' operator inside shorthand
  738. // property assignment in contexts where both object expression
  739. // and object pattern might appear (so it's possible to raise
  740. // delayed syntax error at correct position).
  741. pp.parseExpression = function (noIn, refShorthandDefaultPos) {
  742. var startPos = this.start,
  743. startLoc = this.startLoc;
  744. var expr = this.parseMaybeAssign(noIn, refShorthandDefaultPos);
  745. if (this.type === tt.comma) {
  746. var node = this.startNodeAt(startPos, startLoc);
  747. node.expressions = [expr];
  748. while (this.eat(tt.comma)) node.expressions.push(this.parseMaybeAssign(noIn, refShorthandDefaultPos));
  749. return this.finishNode(node, "SequenceExpression");
  750. }
  751. return expr;
  752. };
  753. // Parse an assignment expression. This includes applications of
  754. // operators like `+=`.
  755. pp.parseMaybeAssign = function (noIn, refShorthandDefaultPos, afterLeftParse) {
  756. if (this.type == tt._yield && this.inGenerator) return this.parseYield();
  757. var failOnShorthandAssign = undefined;
  758. if (!refShorthandDefaultPos) {
  759. refShorthandDefaultPos = { start: 0 };
  760. failOnShorthandAssign = true;
  761. } else {
  762. failOnShorthandAssign = false;
  763. }
  764. var startPos = this.start,
  765. startLoc = this.startLoc;
  766. if (this.type == tt.parenL || this.type == tt.name) this.potentialArrowAt = this.start;
  767. var left = this.parseMaybeConditional(noIn, refShorthandDefaultPos);
  768. if (afterLeftParse) left = afterLeftParse.call(this, left, startPos, startLoc);
  769. if (this.type.isAssign) {
  770. var node = this.startNodeAt(startPos, startLoc);
  771. node.operator = this.value;
  772. node.left = this.type === tt.eq ? this.toAssignable(left) : left;
  773. refShorthandDefaultPos.start = 0; // reset because shorthand default was used correctly
  774. this.checkLVal(left);
  775. this.next();
  776. node.right = this.parseMaybeAssign(noIn);
  777. return this.finishNode(node, "AssignmentExpression");
  778. } else if (failOnShorthandAssign && refShorthandDefaultPos.start) {
  779. this.unexpected(refShorthandDefaultPos.start);
  780. }
  781. return left;
  782. };
  783. // Parse a ternary conditional (`?:`) operator.
  784. pp.parseMaybeConditional = function (noIn, refShorthandDefaultPos) {
  785. var startPos = this.start,
  786. startLoc = this.startLoc;
  787. var expr = this.parseExprOps(noIn, refShorthandDefaultPos);
  788. if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;
  789. if (this.eat(tt.question)) {
  790. var node = this.startNodeAt(startPos, startLoc);
  791. node.test = expr;
  792. node.consequent = this.parseMaybeAssign();
  793. this.expect(tt.colon);
  794. node.alternate = this.parseMaybeAssign(noIn);
  795. return this.finishNode(node, "ConditionalExpression");
  796. }
  797. return expr;
  798. };
  799. // Start the precedence parser.
  800. pp.parseExprOps = function (noIn, refShorthandDefaultPos) {
  801. var startPos = this.start,
  802. startLoc = this.startLoc;
  803. var expr = this.parseMaybeUnary(refShorthandDefaultPos);
  804. if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;
  805. return this.parseExprOp(expr, startPos, startLoc, -1, noIn);
  806. };
  807. // Parse binary operators with the operator precedence parsing
  808. // algorithm. `left` is the left-hand side of the operator.
  809. // `minPrec` provides context that allows the function to stop and
  810. // defer further parser to one of its callers when it encounters an
  811. // operator that has a lower precedence than the set it is parsing.
  812. pp.parseExprOp = function (left, leftStartPos, leftStartLoc, minPrec, noIn) {
  813. var prec = this.type.binop;
  814. if (Array.isArray(leftStartPos)) {
  815. if (this.options.locations && noIn === undefined) {
  816. // shift arguments to left by one
  817. noIn = minPrec;
  818. minPrec = leftStartLoc;
  819. // flatten leftStartPos
  820. leftStartLoc = leftStartPos[1];
  821. leftStartPos = leftStartPos[0];
  822. }
  823. }
  824. if (prec != null && (!noIn || this.type !== tt._in)) {
  825. if (prec > minPrec) {
  826. var node = this.startNodeAt(leftStartPos, leftStartLoc);
  827. node.left = left;
  828. node.operator = this.value;
  829. var op = this.type;
  830. this.next();
  831. var startPos = this.start,
  832. startLoc = this.startLoc;
  833. node.right = this.parseExprOp(this.parseMaybeUnary(), startPos, startLoc, prec, noIn);
  834. this.finishNode(node, op === tt.logicalOR || op === tt.logicalAND ? "LogicalExpression" : "BinaryExpression");
  835. return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn);
  836. }
  837. }
  838. return left;
  839. };
  840. // Parse unary operators, both prefix and postfix.
  841. pp.parseMaybeUnary = function (refShorthandDefaultPos) {
  842. if (this.type.prefix) {
  843. var node = this.startNode(),
  844. update = this.type === tt.incDec;
  845. node.operator = this.value;
  846. node.prefix = true;
  847. this.next();
  848. node.argument = this.parseMaybeUnary();
  849. if (refShorthandDefaultPos && refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start);
  850. if (update) this.checkLVal(node.argument);else if (this.strict && node.operator === "delete" && node.argument.type === "Identifier") this.raise(node.start, "Deleting local variable in strict mode");
  851. return this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
  852. }
  853. var startPos = this.start,
  854. startLoc = this.startLoc;
  855. var expr = this.parseExprSubscripts(refShorthandDefaultPos);
  856. if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;
  857. while (this.type.postfix && !this.canInsertSemicolon()) {
  858. var node = this.startNodeAt(startPos, startLoc);
  859. node.operator = this.value;
  860. node.prefix = false;
  861. node.argument = expr;
  862. this.checkLVal(expr);
  863. this.next();
  864. expr = this.finishNode(node, "UpdateExpression");
  865. }
  866. return expr;
  867. };
  868. // Parse call, dot, and `[]`-subscript expressions.
  869. pp.parseExprSubscripts = function (refShorthandDefaultPos) {
  870. var startPos = this.start,
  871. startLoc = this.startLoc;
  872. var expr = this.parseExprAtom(refShorthandDefaultPos);
  873. if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;
  874. return this.parseSubscripts(expr, startPos, startLoc);
  875. };
  876. pp.parseSubscripts = function (base, startPos, startLoc, noCalls) {
  877. if (Array.isArray(startPos)) {
  878. if (this.options.locations && noCalls === undefined) {
  879. // shift arguments to left by one
  880. noCalls = startLoc;
  881. // flatten startPos
  882. startLoc = startPos[1];
  883. startPos = startPos[0];
  884. }
  885. }
  886. for (;;) {
  887. if (this.eat(tt.dot)) {
  888. var node = this.startNodeAt(startPos, startLoc);
  889. node.object = base;
  890. node.property = this.parseIdent(true);
  891. node.computed = false;
  892. base = this.finishNode(node, "MemberExpression");
  893. } else if (this.eat(tt.bracketL)) {
  894. var node = this.startNodeAt(startPos, startLoc);
  895. node.object = base;
  896. node.property = this.parseExpression();
  897. node.computed = true;
  898. this.expect(tt.bracketR);
  899. base = this.finishNode(node, "MemberExpression");
  900. } else if (!noCalls && this.eat(tt.parenL)) {
  901. var node = this.startNodeAt(startPos, startLoc);
  902. node.callee = base;
  903. node.arguments = this.parseExprList(tt.parenR, false);
  904. base = this.finishNode(node, "CallExpression");
  905. } else if (this.type === tt.backQuote) {
  906. var node = this.startNodeAt(startPos, startLoc);
  907. node.tag = base;
  908. node.quasi = this.parseTemplate();
  909. base = this.finishNode(node, "TaggedTemplateExpression");
  910. } else {
  911. return base;
  912. }
  913. }
  914. };
  915. // Parse an atomic expression — either a single token that is an
  916. // expression, an expression started by a keyword like `function` or
  917. // `new`, or an expression wrapped in punctuation like `()`, `[]`,
  918. // or `{}`.
  919. pp.parseExprAtom = function (refShorthandDefaultPos) {
  920. var node = undefined,
  921. canBeArrow = this.potentialArrowAt == this.start;
  922. switch (this.type) {
  923. case tt._this:
  924. case tt._super:
  925. var type = this.type === tt._this ? "ThisExpression" : "Super";
  926. node = this.startNode();
  927. this.next();
  928. return this.finishNode(node, type);
  929. case tt._yield:
  930. if (this.inGenerator) this.unexpected();
  931. case tt.name:
  932. var startPos = this.start,
  933. startLoc = this.startLoc;
  934. var id = this.parseIdent(this.type !== tt.name);
  935. if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id]);
  936. return id;
  937. case tt.regexp:
  938. var value = this.value;
  939. node = this.parseLiteral(value.value);
  940. node.regex = { pattern: value.pattern, flags: value.flags };
  941. return node;
  942. case tt.num:case tt.string:
  943. return this.parseLiteral(this.value);
  944. case tt._null:case tt._true:case tt._false:
  945. node = this.startNode();
  946. node.value = this.type === tt._null ? null : this.type === tt._true;
  947. node.raw = this.type.keyword;
  948. this.next();
  949. return this.finishNode(node, "Literal");
  950. case tt.parenL:
  951. return this.parseParenAndDistinguishExpression(canBeArrow);
  952. case tt.bracketL:
  953. node = this.startNode();
  954. this.next();
  955. // check whether this is array comprehension or regular array
  956. if (this.options.ecmaVersion >= 7 && this.type === tt._for) {
  957. return this.parseComprehension(node, false);
  958. }
  959. node.elements = this.parseExprList(tt.bracketR, true, true, refShorthandDefaultPos);
  960. return this.finishNode(node, "ArrayExpression");
  961. case tt.braceL:
  962. return this.parseObj(false, refShorthandDefaultPos);
  963. case tt._function:
  964. node = this.startNode();
  965. this.next();
  966. return this.parseFunction(node, false);
  967. case tt._class:
  968. return this.parseClass(this.startNode(), false);
  969. case tt._new:
  970. return this.parseNew();
  971. case tt.backQuote:
  972. return this.parseTemplate();
  973. default:
  974. this.unexpected();
  975. }
  976. };
  977. pp.parseLiteral = function (value) {
  978. var node = this.startNode();
  979. node.value = value;
  980. node.raw = this.input.slice(this.start, this.end);
  981. this.next();
  982. return this.finishNode(node, "Literal");
  983. };
  984. pp.parseParenExpression = function () {
  985. this.expect(tt.parenL);
  986. var val = this.parseExpression();
  987. this.expect(tt.parenR);
  988. return val;
  989. };
  990. pp.parseParenAndDistinguishExpression = function (canBeArrow) {
  991. var startPos = this.start,
  992. startLoc = this.startLoc,
  993. val = undefined;
  994. if (this.options.ecmaVersion >= 6) {
  995. this.next();
  996. if (this.options.ecmaVersion >= 7 && this.type === tt._for) {
  997. return this.parseComprehension(this.startNodeAt(startPos, startLoc), true);
  998. }
  999. var innerStartPos = this.start,
  1000. innerStartLoc = this.startLoc;
  1001. var exprList = [],
  1002. first = true;
  1003. var refShorthandDefaultPos = { start: 0 },
  1004. spreadStart = undefined,
  1005. innerParenStart = undefined;
  1006. while (this.type !== tt.parenR) {
  1007. first ? first = false : this.expect(tt.comma);
  1008. if (this.type === tt.ellipsis) {
  1009. spreadStart = this.start;
  1010. exprList.push(this.parseParenItem(this.parseRest()));
  1011. break;
  1012. } else {
  1013. if (this.type === tt.parenL && !innerParenStart) {
  1014. innerParenStart = this.start;
  1015. }
  1016. exprList.push(this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem));
  1017. }
  1018. }
  1019. var innerEndPos = this.start,
  1020. innerEndLoc = this.startLoc;
  1021. this.expect(tt.parenR);
  1022. if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) {
  1023. if (innerParenStart) this.unexpected(innerParenStart);
  1024. return this.parseParenArrowList(startPos, startLoc, exprList);
  1025. }
  1026. if (!exprList.length) this.unexpected(this.lastTokStart);
  1027. if (spreadStart) this.unexpected(spreadStart);
  1028. if (refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start);
  1029. if (exprList.length > 1) {
  1030. val = this.startNodeAt(innerStartPos, innerStartLoc);
  1031. val.expressions = exprList;
  1032. this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);
  1033. } else {
  1034. val = exprList[0];
  1035. }
  1036. } else {
  1037. val = this.parseParenExpression();
  1038. }
  1039. if (this.options.preserveParens) {
  1040. var par = this.startNodeAt(startPos, startLoc);
  1041. par.expression = val;
  1042. return this.finishNode(par, "ParenthesizedExpression");
  1043. } else {
  1044. return val;
  1045. }
  1046. };
  1047. pp.parseParenItem = function (item) {
  1048. return item;
  1049. };
  1050. pp.parseParenArrowList = function (startPos, startLoc, exprList) {
  1051. return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList);
  1052. };
  1053. // New's precedence is slightly tricky. It must allow its argument
  1054. // to be a `[]` or dot subscript expression, but not a call — at
  1055. // least, not without wrapping it in parentheses. Thus, it uses the
  1056. var empty = [];
  1057. pp.parseNew = function () {
  1058. var node = this.startNode();
  1059. var meta = this.parseIdent(true);
  1060. if (this.options.ecmaVersion >= 6 && this.eat(tt.dot)) {
  1061. node.meta = meta;
  1062. node.property = this.parseIdent(true);
  1063. if (node.property.name !== "target") this.raise(node.property.start, "The only valid meta property for new is new.target");
  1064. return this.finishNode(node, "MetaProperty");
  1065. }
  1066. var startPos = this.start,
  1067. startLoc = this.startLoc;
  1068. node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true);
  1069. if (this.eat(tt.parenL)) node.arguments = this.parseExprList(tt.parenR, false);else node.arguments = empty;
  1070. return this.finishNode(node, "NewExpression");
  1071. };
  1072. // Parse template expression.
  1073. pp.parseTemplateElement = function () {
  1074. var elem = this.startNode();
  1075. elem.value = {
  1076. raw: this.input.slice(this.start, this.end),
  1077. cooked: this.value
  1078. };
  1079. this.next();
  1080. elem.tail = this.type === tt.backQuote;
  1081. return this.finishNode(elem, "TemplateElement");
  1082. };
  1083. pp.parseTemplate = function () {
  1084. var node = this.startNode();
  1085. this.next();
  1086. node.expressions = [];
  1087. var curElt = this.parseTemplateElement();
  1088. node.quasis = [curElt];
  1089. while (!curElt.tail) {
  1090. this.expect(tt.dollarBraceL);
  1091. node.expressions.push(this.parseExpression());
  1092. this.expect(tt.braceR);
  1093. node.quasis.push(curElt = this.parseTemplateElement());
  1094. }
  1095. this.next();
  1096. return this.finishNode(node, "TemplateLiteral");
  1097. };
  1098. // Parse an object literal or binding pattern.
  1099. pp.parseObj = function (isPattern, refShorthandDefaultPos) {
  1100. var node = this.startNode(),
  1101. first = true,
  1102. propHash = {};
  1103. node.properties = [];
  1104. this.next();
  1105. while (!this.eat(tt.braceR)) {
  1106. if (!first) {
  1107. this.expect(tt.comma);
  1108. if (this.afterTrailingComma(tt.braceR)) break;
  1109. } else first = false;
  1110. var prop = this.startNode(),
  1111. isGenerator = undefined,
  1112. startPos = undefined,
  1113. startLoc = undefined;
  1114. if (this.options.ecmaVersion >= 6) {
  1115. prop.method = false;
  1116. prop.shorthand = false;
  1117. if (isPattern || refShorthandDefaultPos) {
  1118. startPos = this.start;
  1119. startLoc = this.startLoc;
  1120. }
  1121. if (!isPattern) isGenerator = this.eat(tt.star);
  1122. }
  1123. this.parsePropertyName(prop);
  1124. this.parsePropertyValue(prop, isPattern, isGenerator, startPos, startLoc, refShorthandDefaultPos);
  1125. this.checkPropClash(prop, propHash);
  1126. node.properties.push(this.finishNode(prop, "Property"));
  1127. }
  1128. return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression");
  1129. };
  1130. pp.parsePropertyValue = function (prop, isPattern, isGenerator, startPos, startLoc, refShorthandDefaultPos) {
  1131. if (this.eat(tt.colon)) {
  1132. prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refShorthandDefaultPos);
  1133. prop.kind = "init";
  1134. } else if (this.options.ecmaVersion >= 6 && this.type === tt.parenL) {
  1135. if (isPattern) this.unexpected();
  1136. prop.kind = "init";
  1137. prop.method = true;
  1138. prop.value = this.parseMethod(isGenerator);
  1139. } else if (this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && (this.type != tt.comma && this.type != tt.braceR)) {
  1140. if (isGenerator || isPattern) this.unexpected();
  1141. prop.kind = prop.key.name;
  1142. this.parsePropertyName(prop);
  1143. prop.value = this.parseMethod(false);
  1144. } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
  1145. prop.kind = "init";
  1146. if (isPattern) {
  1147. if (this.isKeyword(prop.key.name) || this.strict && (reservedWords.strictBind(prop.key.name) || reservedWords.strict(prop.key.name)) || !this.options.allowReserved && this.isReservedWord(prop.key.name)) this.raise(prop.key.start, "Binding " + prop.key.name);
  1148. prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);
  1149. } else if (this.type === tt.eq && refShorthandDefaultPos) {
  1150. if (!refShorthandDefaultPos.start) refShorthandDefaultPos.start = this.start;
  1151. prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);
  1152. } else {
  1153. prop.value = prop.key;
  1154. }
  1155. prop.shorthand = true;
  1156. } else this.unexpected();
  1157. };
  1158. pp.parsePropertyName = function (prop) {
  1159. if (this.options.ecmaVersion >= 6) {
  1160. if (this.eat(tt.bracketL)) {
  1161. prop.computed = true;
  1162. prop.key = this.parseMaybeAssign();
  1163. this.expect(tt.bracketR);
  1164. return prop.key;
  1165. } else {
  1166. prop.computed = false;
  1167. }
  1168. }
  1169. return prop.key = this.type === tt.num || this.type === tt.string ? this.parseExprAtom() : this.parseIdent(true);
  1170. };
  1171. // Initialize empty function node.
  1172. pp.initFunction = function (node) {
  1173. node.id = null;
  1174. if (this.options.ecmaVersion >= 6) {
  1175. node.generator = false;
  1176. node.expression = false;
  1177. }
  1178. };
  1179. // Parse object or class method.
  1180. pp.parseMethod = function (isGenerator) {
  1181. var node = this.startNode();
  1182. this.initFunction(node);
  1183. this.expect(tt.parenL);
  1184. node.params = this.parseBindingList(tt.parenR, false, false);
  1185. var allowExpressionBody = undefined;
  1186. if (this.options.ecmaVersion >= 6) {
  1187. node.generator = isGenerator;
  1188. allowExpressionBody = true;
  1189. } else {
  1190. allowExpressionBody = false;
  1191. }
  1192. this.parseFunctionBody(node, allowExpressionBody);
  1193. return this.finishNode(node, "FunctionExpression");
  1194. };
  1195. // Parse arrow function expression with given parameters.
  1196. pp.parseArrowExpression = function (node, params) {
  1197. this.initFunction(node);
  1198. node.params = this.toAssignableList(params, true);
  1199. this.parseFunctionBody(node, true);
  1200. return this.finishNode(node, "ArrowFunctionExpression");
  1201. };
  1202. // Parse function body and check parameters.
  1203. pp.parseFunctionBody = function (node, allowExpression) {
  1204. var isExpression = allowExpression && this.type !== tt.braceL;
  1205. if (isExpression) {
  1206. node.body = this.parseMaybeAssign();
  1207. node.expression = true;
  1208. } else {
  1209. // Start a new scope with regard to labels and the `inFunction`
  1210. // flag (restore them to their old value afterwards).
  1211. var oldInFunc = this.inFunction,
  1212. oldInGen = this.inGenerator,
  1213. oldLabels = this.labels;
  1214. this.inFunction = true;this.inGenerator = node.generator;this.labels = [];
  1215. node.body = this.parseBlock(true);
  1216. node.expression = false;
  1217. this.inFunction = oldInFunc;this.inGenerator = oldInGen;this.labels = oldLabels;
  1218. }
  1219. // If this is a strict mode function, verify that argument names
  1220. // are not repeated, and it does not try to bind the words `eval`
  1221. // or `arguments`.
  1222. if (this.strict || !isExpression && node.body.body.length && this.isUseStrict(node.body.body[0])) {
  1223. var nameHash = {},
  1224. oldStrict = this.strict;
  1225. this.strict = true;
  1226. if (node.id) this.checkLVal(node.id, true);
  1227. for (var i = 0; i < node.params.length; i++) {
  1228. this.checkLVal(node.params[i], true, nameHash);
  1229. }this.strict = oldStrict;
  1230. }
  1231. };
  1232. // Parses a comma-separated list of expressions, and returns them as
  1233. // an array. `close` is the token type that ends the list, and
  1234. // `allowEmpty` can be turned on to allow subsequent commas with
  1235. // nothing in between them to be parsed as `null` (which is needed
  1236. // for array literals).
  1237. pp.parseExprList = function (close, allowTrailingComma, allowEmpty, refShorthandDefaultPos) {
  1238. var elts = [],
  1239. first = true;
  1240. while (!this.eat(close)) {
  1241. if (!first) {
  1242. this.expect(tt.comma);
  1243. if (allowTrailingComma && this.afterTrailingComma(close)) break;
  1244. } else first = false;
  1245. if (allowEmpty && this.type === tt.comma) {
  1246. elts.push(null);
  1247. } else {
  1248. if (this.type === tt.ellipsis) elts.push(this.parseSpread(refShorthandDefaultPos));else elts.push(this.parseMaybeAssign(false, refShorthandDefaultPos));
  1249. }
  1250. }
  1251. return elts;
  1252. };
  1253. // Parse the next token as an identifier. If `liberal` is true (used
  1254. // when parsing properties), it will also convert keywords into
  1255. // identifiers.
  1256. pp.parseIdent = function (liberal) {
  1257. var node = this.startNode();
  1258. if (liberal && this.options.allowReserved == "never") liberal = false;
  1259. if (this.type === tt.name) {
  1260. if (!liberal && (!this.options.allowReserved && this.isReservedWord(this.value) || this.strict && reservedWords.strict(this.value) && (this.options.ecmaVersion >= 6 || this.input.slice(this.start, this.end).indexOf("\\") == -1))) this.raise(this.start, "The keyword '" + this.value + "' is reserved");
  1261. node.name = this.value;
  1262. } else if (liberal && this.type.keyword) {
  1263. node.name = this.type.keyword;
  1264. } else {
  1265. this.unexpected();
  1266. }
  1267. this.next();
  1268. return this.finishNode(node, "Identifier");
  1269. };
  1270. // Parses yield expression inside generator.
  1271. pp.parseYield = function () {
  1272. var node = this.startNode();
  1273. this.next();
  1274. if (this.type == tt.semi || this.canInsertSemicolon() || this.type != tt.star && !this.type.startsExpr) {
  1275. node.delegate = false;
  1276. node.argument = null;
  1277. } else {
  1278. node.delegate = this.eat(tt.star);
  1279. node.argument = this.parseMaybeAssign();
  1280. }
  1281. return this.finishNode(node, "YieldExpression");
  1282. };
  1283. // Parses array and generator comprehensions.
  1284. pp.parseComprehension = function (node, isGenerator) {
  1285. node.blocks = [];
  1286. while (this.type === tt._for) {
  1287. var block = this.startNode();
  1288. this.next();
  1289. this.expect(tt.parenL);
  1290. block.left = this.parseBindingAtom();
  1291. this.checkLVal(block.left, true);
  1292. this.expectContextual("of");
  1293. block.right = this.parseExpression();
  1294. this.expect(tt.parenR);
  1295. node.blocks.push(this.finishNode(block, "ComprehensionBlock"));
  1296. }
  1297. node.filter = this.eat(tt._if) ? this.parseParenExpression() : null;
  1298. node.body = this.parseExpression();
  1299. this.expect(isGenerator ? tt.parenR : tt.bracketR);
  1300. node.generator = isGenerator;
  1301. return this.finishNode(node, "ComprehensionExpression");
  1302. };
  1303. },{"./identifier":7,"./state":13,"./tokentype":17,"./util":18}],7:[function(_dereq_,module,exports){
  1304. // Test whether a given character code starts an identifier.
  1305. "use strict";
  1306. exports.isIdentifierStart = isIdentifierStart;
  1307. // Test whether a given character is part of an identifier.
  1308. exports.isIdentifierChar = isIdentifierChar;
  1309. exports.__esModule = true;
  1310. // This is a trick taken from Esprima. It turns out that, on
  1311. // non-Chrome browsers, to check whether a string is in a set, a
  1312. // predicate containing a big ugly `switch` statement is faster than
  1313. // a regular expression, and on Chrome the two are about on par.
  1314. // This function uses `eval` (non-lexical) to produce such a
  1315. // predicate from a space-separated string of words.
  1316. //
  1317. // It starts by sorting the words by length.
  1318. // Removed to create an eval-free library
  1319. // Reserved word lists for various dialects of the language
  1320. var reservedWords = {
  1321. 3: function anonymous(str) {
  1322. switch(str.length){case 6:switch(str){case "double":case "export":case "import":case "native":case "public":case "static":case "throws":return true}return false;case 4:switch(str){case "byte":case "char":case "enum":case "goto":case "long":return true}return false;case 5:switch(str){case "class":case "final":case "float":case "short":case "super":return true}return false;case 7:switch(str){case "boolean":case "extends":case "package":case "private":return true}return false;case 9:switch(str){case "interface":case "protected":case "transient":return true}return false;case 8:switch(str){case "abstract":case "volatile":return true}return false;case 10:return str === "implements";case 3:return str === "int";case 12:return str === "synchronized";}
  1323. },
  1324. 5: function anonymous(str) {
  1325. switch(str.length){case 5:switch(str){case "class":case "super":case "const":return true}return false;case 6:switch(str){case "export":case "import":return true}return false;case 4:return str === "enum";case 7:return str === "extends";}
  1326. },
  1327. 6: function anonymous(str) {
  1328. switch(str){case "enum":case "await":return true}return false;
  1329. },
  1330. strict: function anonymous(str) {
  1331. switch(str.length){case 9:switch(str){case "interface":case "protected":return true}return false;case 7:switch(str){case "package":case "private":return true}return false;case 6:switch(str){case "public":case "static":return true}return false;case 10:return str === "implements";case 3:return str === "let";case 5:return str === "yield";}
  1332. },
  1333. strictBind: function anonymous(str) {
  1334. switch(str){case "eval":case "arguments":return true}return false;
  1335. }
  1336. };
  1337. exports.reservedWords = reservedWords;
  1338. // And the keywords
  1339. 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";
  1340. var keywords = {
  1341. 5: function anonymous(str) {
  1342. switch(str.length){case 4:switch(str){case "case":case "else":case "with":case "null":case "true":case "void":case "this":return true}return false;case 5:switch(str){case "break":case "catch":case "throw":case "while":case "false":return true}return false;case 3:switch(str){case "for":case "try":case "var":case "new":return true}return false;case 6:switch(str){case "return":case "switch":case "typeof":case "delete":return true}return false;case 8:switch(str){case "continue":case "debugger":case "function":return true}return false;case 2:switch(str){case "do":case "if":case "in":return true}return false;case 7:switch(str){case "default":case "finally":return true}return false;case 10:return str === "instanceof";}
  1343. },
  1344. 6: function anonymous(str) {
  1345. switch(str.length){case 5:switch(str){case "break":case "catch":case "throw":case "while":case "false":case "const":case "class":case "yield":case "super":return true}return false;case 4:switch(str){case "case":case "else":case "with":case "null":case "true":case "void":case "this":return true}return false;case 6:switch(str){case "return":case "switch":case "typeof":case "delete":case "export":case "import":return true}return false;case 3:switch(str){case "for":case "try":case "var":case "new":case "let":return true}return false;case 8:switch(str){case "continue":case "debugger":case "function":return true}return false;case 7:switch(str){case "default":case "finally":case "extends":return true}return false;case 2:switch(str){case "do":case "if":case "in":return true}return false;case 10:return str === "instanceof";}
  1346. }
  1347. };
  1348. exports.keywords = keywords;
  1349. // ## Character categories
  1350. // Big ugly regular expressions that match characters in the
  1351. // whitespace, identifier, and identifier-start categories. These
  1352. // are only applied when a character is found to actually have a
  1353. // code point above 128.
  1354. // Generated by `tools/generate-identifier-regex.js`.
  1355. var nonASCIIidentifierStartChars = "ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠ-ࢲऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞭꞰꞱꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭟꭤꭥꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ";
  1356. var nonASCIIidentifierChars = "‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣤ-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఃా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഁ-ഃാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏ᦰ-ᧀᧈᧉ᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳸᳹᷀-᷵᷼-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-꣄꣐-꣙꣠-꣱꤀-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︭︳︴﹍-﹏0-9_";
  1357. var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  1358. var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  1359. nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
  1360. // These are a run-length and offset encoded representation of the
  1361. // >0xffff code points that are a valid part of identifiers. The
  1362. // offset starts at 0x10000, and each pair of numbers represents an
  1363. // offset to the next range, and then a size of the range. They were
  1364. // generated by tools/generate-identifier-regex.js
  1365. var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 17, 26, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 99, 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, 98, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 26, 45, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 955, 52, 76, 44, 33, 24, 27, 35, 42, 34, 4, 0, 13, 47, 15, 3, 22, 0, 38, 17, 2, 24, 133, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 32, 4, 287, 47, 21, 1, 2, 0, 185, 46, 82, 47, 21, 0, 60, 42, 502, 63, 32, 0, 449, 56, 1288, 920, 104, 110, 2962, 1070, 13266, 568, 8, 30, 114, 29, 19, 47, 17, 3, 32, 20, 6, 18, 881, 68, 12, 0, 67, 12, 16481, 1, 3071, 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, 1340, 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, 16355, 541];
  1366. var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 1306, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 52, 0, 13, 2, 49, 13, 16, 9, 83, 11, 168, 11, 6, 9, 8, 2, 57, 0, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 316, 19, 13, 9, 214, 6, 3, 8, 112, 16, 16, 9, 82, 12, 9, 9, 535, 9, 20855, 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, 4305, 6, 792618, 239];
  1367. // This has a complexity linear to the value of the code. The
  1368. // assumption is that looking up astral identifier characters is
  1369. // rare.
  1370. function isInAstralSet(code, set) {
  1371. var pos = 65536;
  1372. for (var i = 0; i < set.length; i += 2) {
  1373. pos += set[i];
  1374. if (pos > code) {
  1375. return false;
  1376. }pos += set[i + 1];
  1377. if (pos >= code) {
  1378. return true;
  1379. }
  1380. }
  1381. }
  1382. function isIdentifierStart(code, astral) {
  1383. if (code < 65) {
  1384. return code === 36;
  1385. }if (code < 91) {
  1386. return true;
  1387. }if (code < 97) {
  1388. return code === 95;
  1389. }if (code < 123) {
  1390. return true;
  1391. }if (code <= 65535) {
  1392. return code >= 170 && nonASCIIidentifierStart.test(String.fromCharCode(code));
  1393. }if (astral === false) {
  1394. return false;
  1395. }return isInAstralSet(code, astralIdentifierStartCodes);
  1396. }
  1397. function isIdentifierChar(code, astral) {
  1398. if (code < 48) {
  1399. return code === 36;
  1400. }if (code < 58) {
  1401. return true;
  1402. }if (code < 65) {
  1403. return false;
  1404. }if (code < 91) {
  1405. return true;
  1406. }if (code < 97) {
  1407. return code === 95;
  1408. }if (code < 123) {
  1409. return true;
  1410. }if (code <= 65535) {
  1411. return code >= 170 && nonASCIIidentifier.test(String.fromCharCode(code));
  1412. }if (astral === false) {
  1413. return false;
  1414. }return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
  1415. }
  1416. },{}],8:[function(_dereq_,module,exports){
  1417. "use strict";
  1418. var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
  1419. // The `getLineInfo` function is mostly useful when the
  1420. // `locations` option is off (for performance reasons) and you
  1421. // want to find the line/column position for a given character
  1422. // offset. `input` should be the code string that the offset refers
  1423. // into.
  1424. exports.getLineInfo = getLineInfo;
  1425. exports.__esModule = true;
  1426. var Parser = _dereq_("./state").Parser;
  1427. var lineBreakG = _dereq_("./whitespace").lineBreakG;
  1428. var deprecate = _dereq_("util").deprecate;
  1429. // These are used when `options.locations` is on, for the
  1430. // `startLoc` and `endLoc` properties.
  1431. var Position = exports.Position = (function () {
  1432. function Position(line, col) {
  1433. _classCallCheck(this, Position);
  1434. this.line = line;
  1435. this.column = col;
  1436. }
  1437. Position.prototype.offset = function offset(n) {
  1438. return new Position(this.line, this.column + n);
  1439. };
  1440. return Position;
  1441. })();
  1442. var SourceLocation = exports.SourceLocation = function SourceLocation(p, start, end) {
  1443. _classCallCheck(this, SourceLocation);
  1444. this.start = start;
  1445. this.end = end;
  1446. if (p.sourceFile !== null) this.source = p.sourceFile;
  1447. };
  1448. function getLineInfo(input, offset) {
  1449. for (var line = 1, cur = 0;;) {
  1450. lineBreakG.lastIndex = cur;
  1451. var match = lineBreakG.exec(input);
  1452. if (match && match.index < offset) {
  1453. ++line;
  1454. cur = match.index + match[0].length;
  1455. } else {
  1456. return new Position(line, offset - cur);
  1457. }
  1458. }
  1459. }
  1460. var pp = Parser.prototype;
  1461. // This function is used to raise exceptions on parse errors. It
  1462. // takes an offset integer (into the current `input`) to indicate
  1463. // the location of the error, attaches the position to the end
  1464. // of the error message, and then raises a `SyntaxError` with that
  1465. // message.
  1466. pp.raise = function (pos, message) {
  1467. var loc = getLineInfo(this.input, pos);
  1468. message += " (" + loc.line + ":" + loc.column + ")";
  1469. var err = new SyntaxError(message);
  1470. err.pos = pos;err.loc = loc;err.raisedAt = this.pos;
  1471. throw err;
  1472. };
  1473. pp.curPosition = function () {
  1474. return new Position(this.curLine, this.pos - this.lineStart);
  1475. };
  1476. pp.markPosition = function () {
  1477. return this.options.locations ? [this.start, this.startLoc] : this.start;
  1478. };
  1479. },{"./state":13,"./whitespace":19,"util":5}],9:[function(_dereq_,module,exports){
  1480. "use strict";
  1481. var tt = _dereq_("./tokentype").types;
  1482. var Parser = _dereq_("./state").Parser;
  1483. var reservedWords = _dereq_("./identifier").reservedWords;
  1484. var has = _dereq_("./util").has;
  1485. var pp = Parser.prototype;
  1486. // Convert existing expression atom to assignable pattern
  1487. // if possible.
  1488. pp.toAssignable = function (node, isBinding) {
  1489. if (this.options.ecmaVersion >= 6 && node) {
  1490. switch (node.type) {
  1491. case "Identifier":
  1492. case "ObjectPattern":
  1493. case "ArrayPattern":
  1494. case "AssignmentPattern":
  1495. break;
  1496. case "ObjectExpression":
  1497. node.type = "ObjectPattern";
  1498. for (var i = 0; i < node.properties.length; i++) {
  1499. var prop = node.properties[i];
  1500. if (prop.kind !== "init") this.raise(prop.key.start, "Object pattern can't contain getter or setter");
  1501. this.toAssignable(prop.value, isBinding);
  1502. }
  1503. break;
  1504. case "ArrayExpression":
  1505. node.type = "ArrayPattern";
  1506. this.toAssignableList(node.elements, isBinding);
  1507. break;
  1508. case "AssignmentExpression":
  1509. if (node.operator === "=") {
  1510. node.type = "AssignmentPattern";
  1511. } else {
  1512. this.raise(node.left.end, "Only '=' operator can be used for specifying default value.");
  1513. }
  1514. break;
  1515. case "ParenthesizedExpression":
  1516. node.expression = this.toAssignable(node.expression, isBinding);
  1517. break;
  1518. case "MemberExpression":
  1519. if (!isBinding) break;
  1520. default:
  1521. this.raise(node.start, "Assigning to rvalue");
  1522. }
  1523. }
  1524. return node;
  1525. };
  1526. // Convert list of expression atoms to binding list.
  1527. pp.toAssignableList = function (exprList, isBinding) {
  1528. var end = exprList.length;
  1529. if (end) {
  1530. var last = exprList[end - 1];
  1531. if (last && last.type == "RestElement") {
  1532. --end;
  1533. } else if (last && last.type == "SpreadElement") {
  1534. last.type = "RestElement";
  1535. var arg = last.argument;
  1536. this.toAssignable(arg, isBinding);
  1537. if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern") this.unexpected(arg.start);
  1538. --end;
  1539. }
  1540. }
  1541. for (var i = 0; i < end; i++) {
  1542. var elt = exprList[i];
  1543. if (elt) this.toAssignable(elt, isBinding);
  1544. }
  1545. return exprList;
  1546. };
  1547. // Parses spread element.
  1548. pp.parseSpread = function (refShorthandDefaultPos) {
  1549. var node = this.startNode();
  1550. this.next();
  1551. node.argument = this.parseMaybeAssign(refShorthandDefaultPos);
  1552. return this.finishNode(node, "SpreadElement");
  1553. };
  1554. pp.parseRest = function () {
  1555. var node = this.startNode();
  1556. this.next();
  1557. node.argument = this.type === tt.name || this.type === tt.bracketL ? this.parseBindingAtom() : this.unexpected();
  1558. return this.finishNode(node, "RestElement");
  1559. };
  1560. // Parses lvalue (assignable) atom.
  1561. pp.parseBindingAtom = function () {
  1562. if (this.options.ecmaVersion < 6) return this.parseIdent();
  1563. switch (this.type) {
  1564. case tt.name:
  1565. return this.parseIdent();
  1566. case tt.bracketL:
  1567. var node = this.startNode();
  1568. this.next();
  1569. node.elements = this.parseBindingList(tt.bracketR, true, true);
  1570. return this.finishNode(node, "ArrayPattern");
  1571. case tt.braceL:
  1572. return this.parseObj(true);
  1573. default:
  1574. this.unexpected();
  1575. }
  1576. };
  1577. pp.parseBindingList = function (close, allowEmpty, allowTrailingComma) {
  1578. var elts = [],
  1579. first = true;
  1580. while (!this.eat(close)) {
  1581. if (first) first = false;else this.expect(tt.comma);
  1582. if (allowEmpty && this.type === tt.comma) {
  1583. elts.push(null);
  1584. } else if (allowTrailingComma && this.afterTrailingComma(close)) {
  1585. break;
  1586. } else if (this.type === tt.ellipsis) {
  1587. var rest = this.parseRest();
  1588. this.parseBindingListItem(rest);
  1589. elts.push(rest);
  1590. this.expect(close);
  1591. break;
  1592. } else {
  1593. var elem = this.parseMaybeDefault(this.start, this.startLoc);
  1594. this.parseBindingListItem(elem);
  1595. elts.push(elem);
  1596. }
  1597. }
  1598. return elts;
  1599. };
  1600. pp.parseBindingListItem = function (param) {
  1601. return param;
  1602. };
  1603. // Parses assignment pattern around given atom if possible.
  1604. pp.parseMaybeDefault = function (startPos, startLoc, left) {
  1605. if (Array.isArray(startPos)) {
  1606. if (this.options.locations && noCalls === undefined) {
  1607. // shift arguments to left by one
  1608. left = startLoc;
  1609. // flatten startPos
  1610. startLoc = startPos[1];
  1611. startPos = startPos[0];
  1612. }
  1613. }
  1614. left = left || this.parseBindingAtom();
  1615. if (!this.eat(tt.eq)) return left;
  1616. var node = this.startNodeAt(startPos, startLoc);
  1617. node.operator = "=";
  1618. node.left = left;
  1619. node.right = this.parseMaybeAssign();
  1620. return this.finishNode(node, "AssignmentPattern");
  1621. };
  1622. // Verify that a node is an lval — something that can be assigned
  1623. // to.
  1624. pp.checkLVal = function (expr, isBinding, checkClashes) {
  1625. switch (expr.type) {
  1626. case "Identifier":
  1627. if (this.strict && (reservedWords.strictBind(expr.name) || reservedWords.strict(expr.name))) this.raise(expr.start, (isBinding ? "Binding " : "Assigning to ") + expr.name + " in strict mode");
  1628. if (checkClashes) {
  1629. if (has(checkClashes, expr.name)) this.raise(expr.start, "Argument name clash in strict mode");
  1630. checkClashes[expr.name] = true;
  1631. }
  1632. break;
  1633. case "MemberExpression":
  1634. if (isBinding) this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " member expression");
  1635. break;
  1636. case "ObjectPattern":
  1637. for (var i = 0; i < expr.properties.length; i++) {
  1638. this.checkLVal(expr.properties[i].value, isBinding, checkClashes);
  1639. }break;
  1640. case "ArrayPattern":
  1641. for (var i = 0; i < expr.elements.length; i++) {
  1642. var elem = expr.elements[i];
  1643. if (elem) this.checkLVal(elem, isBinding, checkClashes);
  1644. }
  1645. break;
  1646. case "AssignmentPattern":
  1647. this.checkLVal(expr.left, isBinding, checkClashes);
  1648. break;
  1649. case "RestElement":
  1650. this.checkLVal(expr.argument, isBinding, checkClashes);
  1651. break;
  1652. case "ParenthesizedExpression":
  1653. this.checkLVal(expr.expression, isBinding, checkClashes);
  1654. break;
  1655. default:
  1656. this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " rvalue");
  1657. }
  1658. };
  1659. },{"./identifier":7,"./state":13,"./tokentype":17,"./util":18}],10:[function(_dereq_,module,exports){
  1660. "use strict";
  1661. var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
  1662. exports.__esModule = true;
  1663. var Parser = _dereq_("./state").Parser;
  1664. var SourceLocation = _dereq_("./location").SourceLocation;
  1665. // Start an AST node, attaching a start offset.
  1666. var pp = Parser.prototype;
  1667. var Node = exports.Node = function Node() {
  1668. _classCallCheck(this, Node);
  1669. };
  1670. pp.startNode = function () {
  1671. var node = new Node();
  1672. node.start = this.start;
  1673. if (this.options.locations) node.loc = new SourceLocation(this, this.startLoc);
  1674. if (this.options.directSourceFile) node.sourceFile = this.options.directSourceFile;
  1675. if (this.options.ranges) node.range = [this.start, 0];
  1676. return node;
  1677. };
  1678. pp.startNodeAt = function (pos, loc) {
  1679. var node = new Node();
  1680. if (Array.isArray(pos)) {
  1681. if (this.options.locations && loc === undefined) {
  1682. // flatten pos
  1683. loc = pos[1];
  1684. pos = pos[0];
  1685. }
  1686. }
  1687. node.start = pos;
  1688. if (this.options.locations) node.loc = new SourceLocation(this, loc);
  1689. if (this.options.directSourceFile) node.sourceFile = this.options.directSourceFile;
  1690. if (this.options.ranges) node.range = [pos, 0];
  1691. return node;
  1692. };
  1693. // Finish an AST node, adding `type` and `end` properties.
  1694. pp.finishNode = function (node, type) {
  1695. node.type = type;
  1696. node.end = this.lastTokEnd;
  1697. if (this.options.locations) node.loc.end = this.lastTokEndLoc;
  1698. if (this.options.ranges) node.range[1] = this.lastTokEnd;
  1699. return node;
  1700. };
  1701. // Finish node at given position
  1702. pp.finishNodeAt = function (node, type, pos, loc) {
  1703. node.type = type;
  1704. if (Array.isArray(pos)) {
  1705. if (this.options.locations && loc === undefined) {
  1706. // flatten pos
  1707. loc = pos[1];
  1708. pos = pos[0];
  1709. }
  1710. }
  1711. node.end = pos;
  1712. if (this.options.locations) node.loc.end = loc;
  1713. if (this.options.ranges) node.range[1] = pos;
  1714. return node;
  1715. };
  1716. },{"./location":8,"./state":13}],11:[function(_dereq_,module,exports){
  1717. // Interpret and default an options object
  1718. "use strict";
  1719. exports.getOptions = getOptions;
  1720. exports.__esModule = true;
  1721. var _util = _dereq_("./util");
  1722. var has = _util.has;
  1723. var isArray = _util.isArray;
  1724. var SourceLocation = _dereq_("./location").SourceLocation;
  1725. // A second optional argument can be given to further configure
  1726. // the parser process. These options are recognized:
  1727. var defaultOptions = {
  1728. // `ecmaVersion` indicates the ECMAScript version to parse. Must
  1729. // be either 3, or 5, or 6. This influences support for strict
  1730. // mode, the set of reserved words, support for getters and
  1731. // setters and other features.
  1732. ecmaVersion: 5,
  1733. // Source type ("script" or "module") for different semantics
  1734. sourceType: "script",
  1735. // `onInsertedSemicolon` can be a callback that will be called
  1736. // when a semicolon is automatically inserted. It will be passed
  1737. // th position of the comma as an offset, and if `locations` is
  1738. // enabled, it is given the location as a `{line, column}` object
  1739. // as second argument.
  1740. onInsertedSemicolon: null,
  1741. // `onTrailingComma` is similar to `onInsertedSemicolon`, but for
  1742. // trailing commas.
  1743. onTrailingComma: null,
  1744. // By default, reserved words are not enforced. Disable
  1745. // `allowReserved` to enforce them. When this option has the
  1746. // value "never", reserved words and keywords can also not be
  1747. // used as property names.
  1748. allowReserved: true,
  1749. // When enabled, a return at the top level is not considered an
  1750. // error.
  1751. allowReturnOutsideFunction: false,
  1752. // When enabled, import/export statements are not constrained to
  1753. // appearing at the top of the program.
  1754. allowImportExportEverywhere: false,
  1755. // When enabled, hashbang directive in the beginning of file
  1756. // is allowed and treated as a line comment.
  1757. allowHashBang: false,
  1758. // When `locations` is on, `loc` properties holding objects with
  1759. // `start` and `end` properties in `{line, column}` form (with
  1760. // line being 1-based and column 0-based) will be attached to the
  1761. // nodes.
  1762. locations: false,
  1763. // A function can be passed as `onToken` option, which will
  1764. // cause Acorn to call that function with object in the same
  1765. // format as tokenize() returns. Note that you are not
  1766. // allowed to call the parser from the callback—that will
  1767. // corrupt its internal state.
  1768. onToken: null,
  1769. // A function can be passed as `onComment` option, which will
  1770. // cause Acorn to call that function with `(block, text, start,
  1771. // end)` parameters whenever a comment is skipped. `block` is a
  1772. // boolean indicating whether this is a block (`/* */`) comment,
  1773. // `text` is the content of the comment, and `start` and `end` are
  1774. // character offsets that denote the start and end of the comment.
  1775. // When the `locations` option is on, two more parameters are
  1776. // passed, the full `{line, column}` locations of the start and
  1777. // end of the comments. Note that you are not allowed to call the
  1778. // parser from the callback—that will corrupt its internal state.
  1779. onComment: null,
  1780. // Nodes have their start and end characters offsets recorded in
  1781. // `start` and `end` properties (directly on the node, rather than
  1782. // the `loc` object, which holds line/column data. To also add a
  1783. // [semi-standardized][range] `range` property holding a `[start,
  1784. // end]` array with the same numbers, set the `ranges` option to
  1785. // `true`.
  1786. //
  1787. // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
  1788. ranges: false,
  1789. // It is possible to parse multiple files into a single AST by
  1790. // passing the tree produced by parsing the first file as
  1791. // `program` option in subsequent parses. This will add the
  1792. // toplevel forms of the parsed file to the `Program` (top) node
  1793. // of an existing parse tree.
  1794. program: null,
  1795. // When `locations` is on, you can pass this to record the source
  1796. // file in every node's `loc` object.
  1797. sourceFile: null,
  1798. // This value, if given, is stored in every node, whether
  1799. // `locations` is on or off.
  1800. directSourceFile: null,
  1801. // When enabled, parenthesized expressions are represented by
  1802. // (non-standard) ParenthesizedExpression nodes
  1803. preserveParens: false,
  1804. plugins: {}
  1805. };exports.defaultOptions = defaultOptions;
  1806. function getOptions(opts) {
  1807. var options = {};
  1808. for (var opt in defaultOptions) {
  1809. options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt];
  1810. }if (isArray(options.onToken)) {
  1811. (function () {
  1812. var tokens = options.onToken;
  1813. options.onToken = function (token) {
  1814. return tokens.push(token);
  1815. };
  1816. })();
  1817. }
  1818. if (isArray(options.onComment)) options.onComment = pushComment(options, options.onComment);
  1819. return options;
  1820. }
  1821. function pushComment(options, array) {
  1822. return function (block, text, start, end, startLoc, endLoc) {
  1823. var comment = {
  1824. type: block ? "Block" : "Line",
  1825. value: text,
  1826. start: start,
  1827. end: end
  1828. };
  1829. if (options.locations) comment.loc = new SourceLocation(this, startLoc, endLoc);
  1830. if (options.ranges) comment.range = [start, end];
  1831. array.push(comment);
  1832. };
  1833. }
  1834. },{"./location":8,"./util":18}],12:[function(_dereq_,module,exports){
  1835. "use strict";
  1836. var tt = _dereq_("./tokentype").types;
  1837. var Parser = _dereq_("./state").Parser;
  1838. var lineBreak = _dereq_("./whitespace").lineBreak;
  1839. var pp = Parser.prototype;
  1840. // ## Parser utilities
  1841. // Test whether a statement node is the string literal `"use strict"`.
  1842. pp.isUseStrict = function (stmt) {
  1843. return this.options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && stmt.expression.value === "use strict";
  1844. };
  1845. // Predicate that tests whether the next token is of the given
  1846. // type, and if yes, consumes it as a side effect.
  1847. pp.eat = function (type) {
  1848. if (this.type === type) {
  1849. this.next();
  1850. return true;
  1851. } else {
  1852. return false;
  1853. }
  1854. };
  1855. // Tests whether parsed token is a contextual keyword.
  1856. pp.isContextual = function (name) {
  1857. return this.type === tt.name && this.value === name;
  1858. };
  1859. // Consumes contextual keyword if possible.
  1860. pp.eatContextual = function (name) {
  1861. return this.value === name && this.eat(tt.name);
  1862. };
  1863. // Asserts that following token is given contextual keyword.
  1864. pp.expectContextual = function (name) {
  1865. if (!this.eatContextual(name)) this.unexpected();
  1866. };
  1867. // Test whether a semicolon can be inserted at the current position.
  1868. pp.canInsertSemicolon = function () {
  1869. return this.type === tt.eof || this.type === tt.braceR || lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
  1870. };
  1871. pp.insertSemicolon = function () {
  1872. if (this.canInsertSemicolon()) {
  1873. if (this.options.onInsertedSemicolon) this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc);
  1874. return true;
  1875. }
  1876. };
  1877. // Consume a semicolon, or, failing that, see if we are allowed to
  1878. // pretend that there is a semicolon at this position.
  1879. pp.semicolon = function () {
  1880. if (!this.eat(tt.semi) && !this.insertSemicolon()) this.unexpected();
  1881. };
  1882. pp.afterTrailingComma = function (tokType) {
  1883. if (this.type == tokType) {
  1884. if (this.options.onTrailingComma) this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc);
  1885. this.next();
  1886. return true;
  1887. }
  1888. };
  1889. // Expect a token of a given type. If found, consume it, otherwise,
  1890. // raise an unexpected token error.
  1891. pp.expect = function (type) {
  1892. this.eat(type) || this.unexpected();
  1893. };
  1894. // Raise an unexpected token error.
  1895. pp.unexpected = function (pos) {
  1896. this.raise(pos != null ? pos : this.start, "Unexpected token");
  1897. };
  1898. },{"./state":13,"./tokentype":17,"./whitespace":19}],13:[function(_dereq_,module,exports){
  1899. "use strict";
  1900. exports.Parser = Parser;
  1901. exports.__esModule = true;
  1902. var _identifier = _dereq_("./identifier");
  1903. var reservedWords = _identifier.reservedWords;
  1904. var keywords = _identifier.keywords;
  1905. var tt = _dereq_("./tokentype").types;
  1906. var lineBreak = _dereq_("./whitespace").lineBreak;
  1907. function Parser(options, input, startPos) {
  1908. this.options = options;
  1909. this.sourceFile = this.options.sourceFile || null;
  1910. this.isKeyword = keywords[this.options.ecmaVersion >= 6 ? 6 : 5];
  1911. this.isReservedWord = reservedWords[this.options.ecmaVersion];
  1912. this.input = input;
  1913. // Load plugins
  1914. this.loadPlugins(this.options.plugins);
  1915. // Set up token state
  1916. // The current position of the tokenizer in the input.
  1917. if (startPos) {
  1918. this.pos = startPos;
  1919. this.lineStart = Math.max(0, this.input.lastIndexOf("\n", startPos));
  1920. this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
  1921. } else {
  1922. this.pos = this.lineStart = 0;
  1923. this.curLine = 1;
  1924. }
  1925. // Properties of the current token:
  1926. // Its type
  1927. this.type = tt.eof;
  1928. // For tokens that include more information than their type, the value
  1929. this.value = null;
  1930. // Its start and end offset
  1931. this.start = this.end = this.pos;
  1932. // And, if locations are used, the {line, column} object
  1933. // corresponding to those offsets
  1934. this.startLoc = this.endLoc = null;
  1935. // Position information for the previous token
  1936. this.lastTokEndLoc = this.lastTokStartLoc = null;
  1937. this.lastTokStart = this.lastTokEnd = this.pos;
  1938. // The context stack is used to superficially track syntactic
  1939. // context to predict whether a regular expression is allowed in a
  1940. // given position.
  1941. this.context = this.initialContext();
  1942. this.exprAllowed = true;
  1943. // Figure out if it's a module code.
  1944. this.strict = this.inModule = this.options.sourceType === "module";
  1945. // Used to signify the start of a potential arrow function
  1946. this.potentialArrowAt = -1;
  1947. // Flags to track whether we are in a function, a generator.
  1948. this.inFunction = this.inGenerator = false;
  1949. // Labels in scope.
  1950. this.labels = [];
  1951. // If enabled, skip leading hashbang line.
  1952. if (this.pos === 0 && this.options.allowHashBang && this.input.slice(0, 2) === "#!") this.skipLineComment(2);
  1953. }
  1954. Parser.prototype.extend = function (name, f) {
  1955. this[name] = f(this[name]);
  1956. };
  1957. // Registered plugins
  1958. var plugins = {};
  1959. exports.plugins = plugins;
  1960. Parser.prototype.loadPlugins = function (plugins) {
  1961. for (var _name in plugins) {
  1962. var plugin = exports.plugins[_name];
  1963. if (!plugin) throw new Error("Plugin '" + _name + "' not found");
  1964. plugin(this, plugins[_name]);
  1965. }
  1966. };
  1967. },{"./identifier":7,"./tokentype":17,"./whitespace":19}],14:[function(_dereq_,module,exports){
  1968. "use strict";
  1969. var tt = _dereq_("./tokentype").types;
  1970. var Parser = _dereq_("./state").Parser;
  1971. var lineBreak = _dereq_("./whitespace").lineBreak;
  1972. var pp = Parser.prototype;
  1973. // ### Statement parsing
  1974. // Parse a program. Initializes the parser, reads any number of
  1975. // statements, and wraps them in a Program node. Optionally takes a
  1976. // `program` argument. If present, the statements will be appended
  1977. // to its body instead of creating a new node.
  1978. pp.parseTopLevel = function (node) {
  1979. var first = true;
  1980. if (!node.body) node.body = [];
  1981. while (this.type !== tt.eof) {
  1982. var stmt = this.parseStatement(true, true);
  1983. node.body.push(stmt);
  1984. if (first && this.isUseStrict(stmt)) this.setStrict(true);
  1985. first = false;
  1986. }
  1987. this.next();
  1988. if (this.options.ecmaVersion >= 6) {
  1989. node.sourceType = this.options.sourceType;
  1990. }
  1991. return this.finishNode(node, "Program");
  1992. };
  1993. var loopLabel = { kind: "loop" },
  1994. switchLabel = { kind: "switch" };
  1995. // Parse a single statement.
  1996. //
  1997. // If expecting a statement and finding a slash operator, parse a
  1998. // regular expression literal. This is to handle cases like
  1999. // `if (foo) /blah/.exec(foo)`, where looking at the previous token
  2000. // does not help.
  2001. pp.parseStatement = function (declaration, topLevel) {
  2002. var starttype = this.type,
  2003. node = this.startNode();
  2004. // Most types of statements are recognized by the keyword they
  2005. // start with. Many are trivial to parse, some require a bit of
  2006. // complexity.
  2007. switch (starttype) {
  2008. case tt._break:case tt._continue:
  2009. return this.parseBreakContinueStatement(node, starttype.keyword);
  2010. case tt._debugger:
  2011. return this.parseDebuggerStatement(node);
  2012. case tt._do:
  2013. return this.parseDoStatement(node);
  2014. case tt._for:
  2015. return this.parseForStatement(node);
  2016. case tt._function:
  2017. if (!declaration && this.options.ecmaVersion >= 6) this.unexpected();
  2018. return this.parseFunctionStatement(node);
  2019. case tt._class:
  2020. if (!declaration) this.unexpected();
  2021. return this.parseClass(node, true);
  2022. case tt._if:
  2023. return this.parseIfStatement(node);
  2024. case tt._return:
  2025. return this.parseReturnStatement(node);
  2026. case tt._switch:
  2027. return this.parseSwitchStatement(node);
  2028. case tt._throw:
  2029. return this.parseThrowStatement(node);
  2030. case tt._try:
  2031. return this.parseTryStatement(node);
  2032. case tt._let:case tt._const:
  2033. if (!declaration) this.unexpected(); // NOTE: falls through to _var
  2034. case tt._var:
  2035. return this.parseVarStatement(node, starttype);
  2036. case tt._while:
  2037. return this.parseWhileStatement(node);
  2038. case tt._with:
  2039. return this.parseWithStatement(node);
  2040. case tt.braceL:
  2041. return this.parseBlock();
  2042. case tt.semi:
  2043. return this.parseEmptyStatement(node);
  2044. case tt._export:
  2045. case tt._import:
  2046. if (!this.options.allowImportExportEverywhere) {
  2047. if (!topLevel) this.raise(this.start, "'import' and 'export' may only appear at the top level");
  2048. if (!this.inModule) this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");
  2049. }
  2050. return starttype === tt._import ? this.parseImport(node) : this.parseExport(node);
  2051. // If the statement does not start with a statement keyword or a
  2052. // brace, it's an ExpressionStatement or LabeledStatement. We
  2053. // simply start parsing an expression, and afterwards, if the
  2054. // next token is a colon and the expression was a simple
  2055. // Identifier node, we switch to interpreting it as a label.
  2056. default:
  2057. var maybeName = this.value,
  2058. expr = this.parseExpression();
  2059. if (starttype === tt.name && expr.type === "Identifier" && this.eat(tt.colon)) return this.parseLabeledStatement(node, maybeName, expr);else return this.parseExpressionStatement(node, expr);
  2060. }
  2061. };
  2062. pp.parseBreakContinueStatement = function (node, keyword) {
  2063. var isBreak = keyword == "break";
  2064. this.next();
  2065. if (this.eat(tt.semi) || this.insertSemicolon()) node.label = null;else if (this.type !== tt.name) this.unexpected();else {
  2066. node.label = this.parseIdent();
  2067. this.semicolon();
  2068. }
  2069. // Verify that there is an actual destination to break or
  2070. // continue to.
  2071. for (var i = 0; i < this.labels.length; ++i) {
  2072. var lab = this.labels[i];
  2073. if (node.label == null || lab.name === node.label.name) {
  2074. if (lab.kind != null && (isBreak || lab.kind === "loop")) break;
  2075. if (node.label && isBreak) break;
  2076. }
  2077. }
  2078. if (i === this.labels.length) this.raise(node.start, "Unsyntactic " + keyword);
  2079. return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
  2080. };
  2081. pp.parseDebuggerStatement = function (node) {
  2082. this.next();
  2083. this.semicolon();
  2084. return this.finishNode(node, "DebuggerStatement");
  2085. };
  2086. pp.parseDoStatement = function (node) {
  2087. this.next();
  2088. this.labels.push(loopLabel);
  2089. node.body = this.parseStatement(false);
  2090. this.labels.pop();
  2091. this.expect(tt._while);
  2092. node.test = this.parseParenExpression();
  2093. if (this.options.ecmaVersion >= 6) this.eat(tt.semi);else this.semicolon();
  2094. return this.finishNode(node, "DoWhileStatement");
  2095. };
  2096. // Disambiguating between a `for` and a `for`/`in` or `for`/`of`
  2097. // loop is non-trivial. Basically, we have to parse the init `var`
  2098. // statement or expression, disallowing the `in` operator (see
  2099. // the second parameter to `parseExpression`), and then check
  2100. // whether the next token is `in` or `of`. When there is no init
  2101. // part (semicolon immediately after the opening parenthesis), it
  2102. // is a regular `for` loop.
  2103. pp.parseForStatement = function (node) {
  2104. this.next();
  2105. this.labels.push(loopLabel);
  2106. this.expect(tt.parenL);
  2107. if (this.type === tt.semi) return this.parseFor(node, null);
  2108. if (this.type === tt._var || this.type === tt._let || this.type === tt._const) {
  2109. var _init = this.startNode(),
  2110. varKind = this.type;
  2111. this.next();
  2112. this.parseVar(_init, true, varKind);
  2113. this.finishNode(_init, "VariableDeclaration");
  2114. if ((this.type === tt._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) && _init.declarations.length === 1 && !(varKind !== tt._var && _init.declarations[0].init)) return this.parseForIn(node, _init);
  2115. return this.parseFor(node, _init);
  2116. }
  2117. var refShorthandDefaultPos = { start: 0 };
  2118. var init = this.parseExpression(true, refShorthandDefaultPos);
  2119. if (this.type === tt._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) {
  2120. this.toAssignable(init);
  2121. this.checkLVal(init);
  2122. return this.parseForIn(node, init);
  2123. } else if (refShorthandDefaultPos.start) {
  2124. this.unexpected(refShorthandDefaultPos.start);
  2125. }
  2126. return this.parseFor(node, init);
  2127. };
  2128. pp.parseFunctionStatement = function (node) {
  2129. this.next();
  2130. return this.parseFunction(node, true);
  2131. };
  2132. pp.parseIfStatement = function (node) {
  2133. this.next();
  2134. node.test = this.parseParenExpression();
  2135. node.consequent = this.parseStatement(false);
  2136. node.alternate = this.eat(tt._else) ? this.parseStatement(false) : null;
  2137. return this.finishNode(node, "IfStatement");
  2138. };
  2139. pp.parseReturnStatement = function (node) {
  2140. if (!this.inFunction && !this.options.allowReturnOutsideFunction) this.raise(this.start, "'return' outside of function");
  2141. this.next();
  2142. // In `return` (and `break`/`continue`), the keywords with
  2143. // optional arguments, we eagerly look for a semicolon or the
  2144. // possibility to insert one.
  2145. if (this.eat(tt.semi) || this.insertSemicolon()) node.argument = null;else {
  2146. node.argument = this.parseExpression();this.semicolon();
  2147. }
  2148. return this.finishNode(node, "ReturnStatement");
  2149. };
  2150. pp.parseSwitchStatement = function (node) {
  2151. this.next();
  2152. node.discriminant = this.parseParenExpression();
  2153. node.cases = [];
  2154. this.expect(tt.braceL);
  2155. this.labels.push(switchLabel);
  2156. // Statements under must be grouped (by label) in SwitchCase
  2157. // nodes. `cur` is used to keep the node that we are currently
  2158. // adding statements to.
  2159. for (var cur, sawDefault; this.type != tt.braceR;) {
  2160. if (this.type === tt._case || this.type === tt._default) {
  2161. var isCase = this.type === tt._case;
  2162. if (cur) this.finishNode(cur, "SwitchCase");
  2163. node.cases.push(cur = this.startNode());
  2164. cur.consequent = [];
  2165. this.next();
  2166. if (isCase) {
  2167. cur.test = this.parseExpression();
  2168. } else {
  2169. if (sawDefault) this.raise(this.lastTokStart, "Multiple default clauses");
  2170. sawDefault = true;
  2171. cur.test = null;
  2172. }
  2173. this.expect(tt.colon);
  2174. } else {
  2175. if (!cur) this.unexpected();
  2176. cur.consequent.push(this.parseStatement(true));
  2177. }
  2178. }
  2179. if (cur) this.finishNode(cur, "SwitchCase");
  2180. this.next(); // Closing brace
  2181. this.labels.pop();
  2182. return this.finishNode(node, "SwitchStatement");
  2183. };
  2184. pp.parseThrowStatement = function (node) {
  2185. this.next();
  2186. if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) this.raise(this.lastTokEnd, "Illegal newline after throw");
  2187. node.argument = this.parseExpression();
  2188. this.semicolon();
  2189. return this.finishNode(node, "ThrowStatement");
  2190. };
  2191. // Reused empty array added for node fields that are always empty.
  2192. var empty = [];
  2193. pp.parseTryStatement = function (node) {
  2194. this.next();
  2195. node.block = this.parseBlock();
  2196. node.handler = null;
  2197. if (this.type === tt._catch) {
  2198. var clause = this.startNode();
  2199. this.next();
  2200. this.expect(tt.parenL);
  2201. clause.param = this.parseBindingAtom();
  2202. this.checkLVal(clause.param, true);
  2203. this.expect(tt.parenR);
  2204. clause.guard = null;
  2205. clause.body = this.parseBlock();
  2206. node.handler = this.finishNode(clause, "CatchClause");
  2207. }
  2208. node.guardedHandlers = empty;
  2209. node.finalizer = this.eat(tt._finally) ? this.parseBlock() : null;
  2210. if (!node.handler && !node.finalizer) this.raise(node.start, "Missing catch or finally clause");
  2211. return this.finishNode(node, "TryStatement");
  2212. };
  2213. pp.parseVarStatement = function (node, kind) {
  2214. this.next();
  2215. this.parseVar(node, false, kind);
  2216. this.semicolon();
  2217. return this.finishNode(node, "VariableDeclaration");
  2218. };
  2219. pp.parseWhileStatement = function (node) {
  2220. this.next();
  2221. node.test = this.parseParenExpression();
  2222. this.labels.push(loopLabel);
  2223. node.body = this.parseStatement(false);
  2224. this.labels.pop();
  2225. return this.finishNode(node, "WhileStatement");
  2226. };
  2227. pp.parseWithStatement = function (node) {
  2228. if (this.strict) this.raise(this.start, "'with' in strict mode");
  2229. this.next();
  2230. node.object = this.parseParenExpression();
  2231. node.body = this.parseStatement(false);
  2232. return this.finishNode(node, "WithStatement");
  2233. };
  2234. pp.parseEmptyStatement = function (node) {
  2235. this.next();
  2236. return this.finishNode(node, "EmptyStatement");
  2237. };
  2238. pp.parseLabeledStatement = function (node, maybeName, expr) {
  2239. for (var i = 0; i < this.labels.length; ++i) {
  2240. if (this.labels[i].name === maybeName) this.raise(expr.start, "Label '" + maybeName + "' is already declared");
  2241. }var kind = this.type.isLoop ? "loop" : this.type === tt._switch ? "switch" : null;
  2242. this.labels.push({ name: maybeName, kind: kind });
  2243. node.body = this.parseStatement(true);
  2244. this.labels.pop();
  2245. node.label = expr;
  2246. return this.finishNode(node, "LabeledStatement");
  2247. };
  2248. pp.parseExpressionStatement = function (node, expr) {
  2249. node.expression = expr;
  2250. this.semicolon();
  2251. return this.finishNode(node, "ExpressionStatement");
  2252. };
  2253. // Parse a semicolon-enclosed block of statements, handling `"use
  2254. // strict"` declarations when `allowStrict` is true (used for
  2255. // function bodies).
  2256. pp.parseBlock = function (allowStrict) {
  2257. var node = this.startNode(),
  2258. first = true,
  2259. oldStrict = undefined;
  2260. node.body = [];
  2261. this.expect(tt.braceL);
  2262. while (!this.eat(tt.braceR)) {
  2263. var stmt = this.parseStatement(true);
  2264. node.body.push(stmt);
  2265. if (first && allowStrict && this.isUseStrict(stmt)) {
  2266. oldStrict = this.strict;
  2267. this.setStrict(this.strict = true);
  2268. }
  2269. first = false;
  2270. }
  2271. if (oldStrict === false) this.setStrict(false);
  2272. return this.finishNode(node, "BlockStatement");
  2273. };
  2274. // Parse a regular `for` loop. The disambiguation code in
  2275. // `parseStatement` will already have parsed the init statement or
  2276. // expression.
  2277. pp.parseFor = function (node, init) {
  2278. node.init = init;
  2279. this.expect(tt.semi);
  2280. node.test = this.type === tt.semi ? null : this.parseExpression();
  2281. this.expect(tt.semi);
  2282. node.update = this.type === tt.parenR ? null : this.parseExpression();
  2283. this.expect(tt.parenR);
  2284. node.body = this.parseStatement(false);
  2285. this.labels.pop();
  2286. return this.finishNode(node, "ForStatement");
  2287. };
  2288. // Parse a `for`/`in` and `for`/`of` loop, which are almost
  2289. // same from parser's perspective.
  2290. pp.parseForIn = function (node, init) {
  2291. var type = this.type === tt._in ? "ForInStatement" : "ForOfStatement";
  2292. this.next();
  2293. node.left = init;
  2294. node.right = this.parseExpression();
  2295. this.expect(tt.parenR);
  2296. node.body = this.parseStatement(false);
  2297. this.labels.pop();
  2298. return this.finishNode(node, type);
  2299. };
  2300. // Parse a list of variable declarations.
  2301. pp.parseVar = function (node, isFor, kind) {
  2302. node.declarations = [];
  2303. node.kind = kind.keyword;
  2304. for (;;) {
  2305. var decl = this.startNode();
  2306. this.parseVarId(decl);
  2307. if (this.eat(tt.eq)) {
  2308. decl.init = this.parseMaybeAssign(isFor);
  2309. } else if (kind === tt._const && !(this.type === tt._in || this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
  2310. this.unexpected();
  2311. } else if (decl.id.type != "Identifier" && !(isFor && (this.type === tt._in || this.isContextual("of")))) {
  2312. this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
  2313. } else {
  2314. decl.init = null;
  2315. }
  2316. node.declarations.push(this.finishNode(decl, "VariableDeclarator"));
  2317. if (!this.eat(tt.comma)) break;
  2318. }
  2319. return node;
  2320. };
  2321. pp.parseVarId = function (decl) {
  2322. decl.id = this.parseBindingAtom();
  2323. this.checkLVal(decl.id, true);
  2324. };
  2325. // Parse a function declaration or literal (depending on the
  2326. // `isStatement` parameter).
  2327. pp.parseFunction = function (node, isStatement, allowExpressionBody) {
  2328. this.initFunction(node);
  2329. if (this.options.ecmaVersion >= 6) node.generator = this.eat(tt.star);
  2330. if (isStatement || this.type === tt.name) node.id = this.parseIdent();
  2331. this.parseFunctionParams(node);
  2332. this.parseFunctionBody(node, allowExpressionBody);
  2333. return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");
  2334. };
  2335. pp.parseFunctionParams = function (node) {
  2336. this.expect(tt.parenL);
  2337. node.params = this.parseBindingList(tt.parenR, false, false);
  2338. };
  2339. // Parse a class declaration or literal (depending on the
  2340. // `isStatement` parameter).
  2341. pp.parseClass = function (node, isStatement) {
  2342. this.next();
  2343. this.parseClassId(node, isStatement);
  2344. this.parseClassSuper(node);
  2345. var classBody = this.startNode();
  2346. var hadConstructor = false;
  2347. classBody.body = [];
  2348. this.expect(tt.braceL);
  2349. while (!this.eat(tt.braceR)) {
  2350. if (this.eat(tt.semi)) continue;
  2351. var method = this.startNode();
  2352. var isGenerator = this.eat(tt.star);
  2353. var isMaybeStatic = this.type === tt.name && this.value === "static";
  2354. this.parsePropertyName(method);
  2355. method["static"] = isMaybeStatic && this.type !== tt.parenL;
  2356. if (method["static"]) {
  2357. if (isGenerator) this.unexpected();
  2358. isGenerator = this.eat(tt.star);
  2359. this.parsePropertyName(method);
  2360. }
  2361. method.kind = "method";
  2362. if (!method.computed) {
  2363. var key = method.key;
  2364. var isGetSet = false;
  2365. if (!isGenerator && key.type === "Identifier" && this.type !== tt.parenL && (key.name === "get" || key.name === "set")) {
  2366. isGetSet = true;
  2367. method.kind = key.name;
  2368. key = this.parsePropertyName(method);
  2369. }
  2370. if (!method["static"] && (key.type === "Identifier" && key.name === "constructor" || key.type === "Literal" && key.value === "constructor")) {
  2371. if (hadConstructor) this.raise(key.start, "Duplicate constructor in the same class");
  2372. if (isGetSet) this.raise(key.start, "Constructor can't have get/set modifier");
  2373. if (isGenerator) this.raise(key.start, "Constructor can't be a generator");
  2374. method.kind = "constructor";
  2375. hadConstructor = true;
  2376. }
  2377. }
  2378. this.parseClassMethod(classBody, method, isGenerator);
  2379. }
  2380. node.body = this.finishNode(classBody, "ClassBody");
  2381. return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
  2382. };
  2383. pp.parseClassMethod = function (classBody, method, isGenerator) {
  2384. method.value = this.parseMethod(isGenerator);
  2385. classBody.body.push(this.finishNode(method, "MethodDefinition"));
  2386. };
  2387. pp.parseClassId = function (node, isStatement) {
  2388. node.id = this.type === tt.name ? this.parseIdent() : isStatement ? this.unexpected() : null;
  2389. };
  2390. pp.parseClassSuper = function (node) {
  2391. node.superClass = this.eat(tt._extends) ? this.parseExprSubscripts() : null;
  2392. };
  2393. // Parses module export declaration.
  2394. pp.parseExport = function (node) {
  2395. this.next();
  2396. // export * from '...'
  2397. if (this.eat(tt.star)) {
  2398. this.expectContextual("from");
  2399. node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();
  2400. this.semicolon();
  2401. return this.finishNode(node, "ExportAllDeclaration");
  2402. }
  2403. if (this.eat(tt._default)) {
  2404. // export default ...
  2405. var expr = this.parseMaybeAssign();
  2406. var needsSemi = true;
  2407. if (expr.type == "FunctionExpression" || expr.type == "ClassExpression") {
  2408. needsSemi = false;
  2409. if (expr.id) {
  2410. expr.type = expr.type == "FunctionExpression" ? "FunctionDeclaration" : "ClassDeclaration";
  2411. }
  2412. }
  2413. node.declaration = expr;
  2414. if (needsSemi) this.semicolon();
  2415. return this.finishNode(node, "ExportDefaultDeclaration");
  2416. }
  2417. // export var|const|let|function|class ...
  2418. if (this.shouldParseExportStatement()) {
  2419. node.declaration = this.parseStatement(true);
  2420. node.specifiers = [];
  2421. node.source = null;
  2422. } else {
  2423. // export { x, y as z } [from '...']
  2424. node.declaration = null;
  2425. node.specifiers = this.parseExportSpecifiers();
  2426. if (this.eatContextual("from")) {
  2427. node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();
  2428. } else {
  2429. node.source = null;
  2430. }
  2431. this.semicolon();
  2432. }
  2433. return this.finishNode(node, "ExportNamedDeclaration");
  2434. };
  2435. pp.shouldParseExportStatement = function () {
  2436. return this.type.keyword;
  2437. };
  2438. // Parses a comma-separated list of module exports.
  2439. pp.parseExportSpecifiers = function () {
  2440. var nodes = [],
  2441. first = true;
  2442. // export { x, y as z } [from '...']
  2443. this.expect(tt.braceL);
  2444. while (!this.eat(tt.braceR)) {
  2445. if (!first) {
  2446. this.expect(tt.comma);
  2447. if (this.afterTrailingComma(tt.braceR)) break;
  2448. } else first = false;
  2449. var node = this.startNode();
  2450. node.local = this.parseIdent(this.type === tt._default);
  2451. node.exported = this.eatContextual("as") ? this.parseIdent(true) : node.local;
  2452. nodes.push(this.finishNode(node, "ExportSpecifier"));
  2453. }
  2454. return nodes;
  2455. };
  2456. // Parses import declaration.
  2457. pp.parseImport = function (node) {
  2458. this.next();
  2459. // import '...'
  2460. if (this.type === tt.string) {
  2461. node.specifiers = empty;
  2462. node.source = this.parseExprAtom();
  2463. node.kind = "";
  2464. } else {
  2465. node.specifiers = this.parseImportSpecifiers();
  2466. this.expectContextual("from");
  2467. node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();
  2468. }
  2469. this.semicolon();
  2470. return this.finishNode(node, "ImportDeclaration");
  2471. };
  2472. // Parses a comma-separated list of module imports.
  2473. pp.parseImportSpecifiers = function () {
  2474. var nodes = [],
  2475. first = true;
  2476. if (this.type === tt.name) {
  2477. // import defaultObj, { x, y as z } from '...'
  2478. var node = this.startNode();
  2479. node.local = this.parseIdent();
  2480. this.checkLVal(node.local, true);
  2481. nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));
  2482. if (!this.eat(tt.comma)) return nodes;
  2483. }
  2484. if (this.type === tt.star) {
  2485. var node = this.startNode();
  2486. this.next();
  2487. this.expectContextual("as");
  2488. node.local = this.parseIdent();
  2489. this.checkLVal(node.local, true);
  2490. nodes.push(this.finishNode(node, "ImportNamespaceSpecifier"));
  2491. return nodes;
  2492. }
  2493. this.expect(tt.braceL);
  2494. while (!this.eat(tt.braceR)) {
  2495. if (!first) {
  2496. this.expect(tt.comma);
  2497. if (this.afterTrailingComma(tt.braceR)) break;
  2498. } else first = false;
  2499. var node = this.startNode();
  2500. node.imported = this.parseIdent(true);
  2501. node.local = this.eatContextual("as") ? this.parseIdent() : node.imported;
  2502. this.checkLVal(node.local, true);
  2503. nodes.push(this.finishNode(node, "ImportSpecifier"));
  2504. }
  2505. return nodes;
  2506. };
  2507. },{"./state":13,"./tokentype":17,"./whitespace":19}],15:[function(_dereq_,module,exports){
  2508. "use strict";
  2509. var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
  2510. exports.__esModule = true;
  2511. // The algorithm used to determine whether a regexp can appear at a
  2512. // given point in the program is loosely based on sweet.js' approach.
  2513. // See https://github.com/mozilla/sweet.js/wiki/design
  2514. var Parser = _dereq_("./state").Parser;
  2515. var tt = _dereq_("./tokentype").types;
  2516. var lineBreak = _dereq_("./whitespace").lineBreak;
  2517. var TokContext = exports.TokContext = function TokContext(token, isExpr, preserveSpace, override) {
  2518. _classCallCheck(this, TokContext);
  2519. this.token = token;
  2520. this.isExpr = isExpr;
  2521. this.preserveSpace = preserveSpace;
  2522. this.override = override;
  2523. };
  2524. var types = {
  2525. b_stat: new TokContext("{", false),
  2526. b_expr: new TokContext("{", true),
  2527. b_tmpl: new TokContext("${", true),
  2528. p_stat: new TokContext("(", false),
  2529. p_expr: new TokContext("(", true),
  2530. q_tmpl: new TokContext("`", true, true, function (p) {
  2531. return p.readTmplToken();
  2532. }),
  2533. f_expr: new TokContext("function", true)
  2534. };
  2535. exports.types = types;
  2536. var pp = Parser.prototype;
  2537. pp.initialContext = function () {
  2538. return [types.b_stat];
  2539. };
  2540. pp.braceIsBlock = function (prevType) {
  2541. var parent = undefined;
  2542. if (prevType === tt.colon && (parent = this.curContext()).token == "{") return !parent.isExpr;
  2543. if (prevType === tt._return) return lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
  2544. if (prevType === tt._else || prevType === tt.semi || prevType === tt.eof) return true;
  2545. if (prevType == tt.braceL) return this.curContext() === types.b_stat;
  2546. return !this.exprAllowed;
  2547. };
  2548. pp.updateContext = function (prevType) {
  2549. var update = undefined,
  2550. type = this.type;
  2551. if (type.keyword && prevType == tt.dot) this.exprAllowed = false;else if (update = type.updateContext) update.call(this, prevType);else this.exprAllowed = type.beforeExpr;
  2552. };
  2553. // Token-specific context update code
  2554. tt.parenR.updateContext = tt.braceR.updateContext = function () {
  2555. if (this.context.length == 1) {
  2556. this.exprAllowed = true;
  2557. return;
  2558. }
  2559. var out = this.context.pop();
  2560. if (out === types.b_stat && this.curContext() === types.f_expr) {
  2561. this.context.pop();
  2562. this.exprAllowed = false;
  2563. } else if (out === types.b_tmpl) {
  2564. this.exprAllowed = true;
  2565. } else {
  2566. this.exprAllowed = !out.isExpr;
  2567. }
  2568. };
  2569. tt.braceL.updateContext = function (prevType) {
  2570. this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr);
  2571. this.exprAllowed = true;
  2572. };
  2573. tt.dollarBraceL.updateContext = function () {
  2574. this.context.push(types.b_tmpl);
  2575. this.exprAllowed = true;
  2576. };
  2577. tt.parenL.updateContext = function (prevType) {
  2578. var statementParens = prevType === tt._if || prevType === tt._for || prevType === tt._with || prevType === tt._while;
  2579. this.context.push(statementParens ? types.p_stat : types.p_expr);
  2580. this.exprAllowed = true;
  2581. };
  2582. tt.incDec.updateContext = function () {};
  2583. tt._function.updateContext = function () {
  2584. if (this.curContext() !== types.b_stat) this.context.push(types.f_expr);
  2585. this.exprAllowed = false;
  2586. };
  2587. tt.backQuote.updateContext = function () {
  2588. if (this.curContext() === types.q_tmpl) this.context.pop();else this.context.push(types.q_tmpl);
  2589. this.exprAllowed = false;
  2590. };
  2591. // tokExprAllowed stays unchanged
  2592. },{"./state":13,"./tokentype":17,"./whitespace":19}],16:[function(_dereq_,module,exports){
  2593. "use strict";
  2594. var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
  2595. exports.__esModule = true;
  2596. var _identifier = _dereq_("./identifier");
  2597. var isIdentifierStart = _identifier.isIdentifierStart;
  2598. var isIdentifierChar = _identifier.isIdentifierChar;
  2599. var _tokentype = _dereq_("./tokentype");
  2600. var tt = _tokentype.types;
  2601. var keywordTypes = _tokentype.keywords;
  2602. var Parser = _dereq_("./state").Parser;
  2603. var SourceLocation = _dereq_("./location").SourceLocation;
  2604. var _whitespace = _dereq_("./whitespace");
  2605. var lineBreak = _whitespace.lineBreak;
  2606. var lineBreakG = _whitespace.lineBreakG;
  2607. var isNewLine = _whitespace.isNewLine;
  2608. var nonASCIIwhitespace = _whitespace.nonASCIIwhitespace;
  2609. // Object type used to represent tokens. Note that normally, tokens
  2610. // simply exist as properties on the parser object. This is only
  2611. // used for the onToken callback and the external tokenizer.
  2612. var Token = exports.Token = function Token(p) {
  2613. _classCallCheck(this, Token);
  2614. this.type = p.type;
  2615. this.value = p.value;
  2616. this.start = p.start;
  2617. this.end = p.end;
  2618. if (p.options.locations) this.loc = new SourceLocation(p, p.startLoc, p.endLoc);
  2619. if (p.options.ranges) this.range = [p.start, p.end];
  2620. };
  2621. // ## Tokenizer
  2622. var pp = Parser.prototype;
  2623. // Are we running under Rhino?
  2624. var isRhino = typeof Packages !== "undefined";
  2625. // Move to the next token
  2626. pp.next = function () {
  2627. if (this.options.onToken) this.options.onToken(new Token(this));
  2628. this.lastTokEnd = this.end;
  2629. this.lastTokStart = this.start;
  2630. this.lastTokEndLoc = this.endLoc;
  2631. this.lastTokStartLoc = this.startLoc;
  2632. this.nextToken();
  2633. };
  2634. pp.getToken = function () {
  2635. this.next();
  2636. return new Token(this);
  2637. };
  2638. // If we're in an ES6 environment, make parsers iterable
  2639. if (typeof Symbol !== "undefined") pp[Symbol.iterator] = function () {
  2640. var self = this;
  2641. return { next: function next() {
  2642. var token = self.getToken();
  2643. return {
  2644. done: token.type === tt.eof,
  2645. value: token
  2646. };
  2647. } };
  2648. };
  2649. // Toggle strict mode. Re-reads the next number or string to please
  2650. // pedantic tests (`"use strict"; 010;` should fail).
  2651. pp.setStrict = function (strict) {
  2652. this.strict = strict;
  2653. if (this.type !== tt.num && this.type !== tt.string) return;
  2654. this.pos = this.start;
  2655. if (this.options.locations) {
  2656. while (this.pos < this.lineStart) {
  2657. this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1;
  2658. --this.curLine;
  2659. }
  2660. }
  2661. this.nextToken();
  2662. };
  2663. pp.curContext = function () {
  2664. return this.context[this.context.length - 1];
  2665. };
  2666. // Read a single token, updating the parser object's token-related
  2667. // properties.
  2668. pp.nextToken = function () {
  2669. var curContext = this.curContext();
  2670. if (!curContext || !curContext.preserveSpace) this.skipSpace();
  2671. this.start = this.pos;
  2672. if (this.options.locations) this.startLoc = this.curPosition();
  2673. if (this.pos >= this.input.length) return this.finishToken(tt.eof);
  2674. if (curContext.override) return curContext.override(this);else this.readToken(this.fullCharCodeAtPos());
  2675. };
  2676. pp.readToken = function (code) {
  2677. // Identifier or keyword. '\uXXXX' sequences are allowed in
  2678. // identifiers, so '\' also dispatches to that.
  2679. if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */) return this.readWord();
  2680. return this.getTokenFromCode(code);
  2681. };
  2682. pp.fullCharCodeAtPos = function () {
  2683. var code = this.input.charCodeAt(this.pos);
  2684. if (code <= 55295 || code >= 57344) return code;
  2685. var next = this.input.charCodeAt(this.pos + 1);
  2686. return (code << 10) + next - 56613888;
  2687. };
  2688. pp.skipBlockComment = function () {
  2689. var startLoc = this.options.onComment && this.options.locations && this.curPosition();
  2690. var start = this.pos,
  2691. end = this.input.indexOf("*/", this.pos += 2);
  2692. if (end === -1) this.raise(this.pos - 2, "Unterminated comment");
  2693. this.pos = end + 2;
  2694. if (this.options.locations) {
  2695. lineBreakG.lastIndex = start;
  2696. var match = undefined;
  2697. while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {
  2698. ++this.curLine;
  2699. this.lineStart = match.index + match[0].length;
  2700. }
  2701. }
  2702. if (this.options.onComment) this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos, startLoc, this.options.locations && this.curPosition());
  2703. };
  2704. pp.skipLineComment = function (startSkip) {
  2705. var start = this.pos;
  2706. var startLoc = this.options.onComment && this.options.locations && this.curPosition();
  2707. var ch = this.input.charCodeAt(this.pos += startSkip);
  2708. while (this.pos < this.input.length && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) {
  2709. ++this.pos;
  2710. ch = this.input.charCodeAt(this.pos);
  2711. }
  2712. if (this.options.onComment) this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos, startLoc, this.options.locations && this.curPosition());
  2713. };
  2714. // Called at the start of the parse and after every token. Skips
  2715. // whitespace and comments, and.
  2716. pp.skipSpace = function () {
  2717. while (this.pos < this.input.length) {
  2718. var ch = this.input.charCodeAt(this.pos);
  2719. if (ch === 32) {
  2720. // ' '
  2721. ++this.pos;
  2722. } else if (ch === 13) {
  2723. ++this.pos;
  2724. var next = this.input.charCodeAt(this.pos);
  2725. if (next === 10) {
  2726. ++this.pos;
  2727. }
  2728. if (this.options.locations) {
  2729. ++this.curLine;
  2730. this.lineStart = this.pos;
  2731. }
  2732. } else if (ch === 10 || ch === 8232 || ch === 8233) {
  2733. ++this.pos;
  2734. if (this.options.locations) {
  2735. ++this.curLine;
  2736. this.lineStart = this.pos;
  2737. }
  2738. } else if (ch > 8 && ch < 14) {
  2739. ++this.pos;
  2740. } else if (ch === 47) {
  2741. // '/'
  2742. var next = this.input.charCodeAt(this.pos + 1);
  2743. if (next === 42) {
  2744. // '*'
  2745. this.skipBlockComment();
  2746. } else if (next === 47) {
  2747. // '/'
  2748. this.skipLineComment(2);
  2749. } else break;
  2750. } else if (ch === 160) {
  2751. // '\xa0'
  2752. ++this.pos;
  2753. } else if (ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
  2754. ++this.pos;
  2755. } else {
  2756. break;
  2757. }
  2758. }
  2759. };
  2760. // Called at the end of every token. Sets `end`, `val`, and
  2761. // maintains `context` and `exprAllowed`, and skips the space after
  2762. // the token, so that the next one's `start` will point at the
  2763. // right position.
  2764. pp.finishToken = function (type, val) {
  2765. this.end = this.pos;
  2766. if (this.options.locations) this.endLoc = this.curPosition();
  2767. var prevType = this.type;
  2768. this.type = type;
  2769. this.value = val;
  2770. this.updateContext(prevType);
  2771. };
  2772. // ### Token reading
  2773. // This is the function that is called to fetch the next token. It
  2774. // is somewhat obscure, because it works in character codes rather
  2775. // than characters, and because operator parsing has been inlined
  2776. // into it.
  2777. //
  2778. // All in the name of speed.
  2779. //
  2780. pp.readToken_dot = function () {
  2781. var next = this.input.charCodeAt(this.pos + 1);
  2782. if (next >= 48 && next <= 57) return this.readNumber(true);
  2783. var next2 = this.input.charCodeAt(this.pos + 2);
  2784. if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) {
  2785. // 46 = dot '.'
  2786. this.pos += 3;
  2787. return this.finishToken(tt.ellipsis);
  2788. } else {
  2789. ++this.pos;
  2790. return this.finishToken(tt.dot);
  2791. }
  2792. };
  2793. pp.readToken_slash = function () {
  2794. // '/'
  2795. var next = this.input.charCodeAt(this.pos + 1);
  2796. if (this.exprAllowed) {
  2797. ++this.pos;return this.readRegexp();
  2798. }
  2799. if (next === 61) return this.finishOp(tt.assign, 2);
  2800. return this.finishOp(tt.slash, 1);
  2801. };
  2802. pp.readToken_mult_modulo = function (code) {
  2803. // '%*'
  2804. var next = this.input.charCodeAt(this.pos + 1);
  2805. if (next === 61) return this.finishOp(tt.assign, 2);
  2806. return this.finishOp(code === 42 ? tt.star : tt.modulo, 1);
  2807. };
  2808. pp.readToken_pipe_amp = function (code) {
  2809. // '|&'
  2810. var next = this.input.charCodeAt(this.pos + 1);
  2811. if (next === code) return this.finishOp(code === 124 ? tt.logicalOR : tt.logicalAND, 2);
  2812. if (next === 61) return this.finishOp(tt.assign, 2);
  2813. return this.finishOp(code === 124 ? tt.bitwiseOR : tt.bitwiseAND, 1);
  2814. };
  2815. pp.readToken_caret = function () {
  2816. // '^'
  2817. var next = this.input.charCodeAt(this.pos + 1);
  2818. if (next === 61) return this.finishOp(tt.assign, 2);
  2819. return this.finishOp(tt.bitwiseXOR, 1);
  2820. };
  2821. pp.readToken_plus_min = function (code) {
  2822. // '+-'
  2823. var next = this.input.charCodeAt(this.pos + 1);
  2824. if (next === code) {
  2825. if (next == 45 && this.input.charCodeAt(this.pos + 2) == 62 && lineBreak.test(this.input.slice(this.lastTokEnd, this.pos))) {
  2826. // A `-->` line comment
  2827. this.skipLineComment(3);
  2828. this.skipSpace();
  2829. return this.nextToken();
  2830. }
  2831. return this.finishOp(tt.incDec, 2);
  2832. }
  2833. if (next === 61) return this.finishOp(tt.assign, 2);
  2834. return this.finishOp(tt.plusMin, 1);
  2835. };
  2836. pp.readToken_lt_gt = function (code) {
  2837. // '<>'
  2838. var next = this.input.charCodeAt(this.pos + 1);
  2839. var size = 1;
  2840. if (next === code) {
  2841. size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
  2842. if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1);
  2843. return this.finishOp(tt.bitShift, size);
  2844. }
  2845. if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 && this.input.charCodeAt(this.pos + 3) == 45) {
  2846. if (this.inModule) this.unexpected();
  2847. // `<!--`, an XML-style comment that should be interpreted as a line comment
  2848. this.skipLineComment(4);
  2849. this.skipSpace();
  2850. return this.nextToken();
  2851. }
  2852. if (next === 61) size = this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2;
  2853. return this.finishOp(tt.relational, size);
  2854. };
  2855. pp.readToken_eq_excl = function (code) {
  2856. // '=!'
  2857. var next = this.input.charCodeAt(this.pos + 1);
  2858. if (next === 61) return this.finishOp(tt.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2);
  2859. if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) {
  2860. // '=>'
  2861. this.pos += 2;
  2862. return this.finishToken(tt.arrow);
  2863. }
  2864. return this.finishOp(code === 61 ? tt.eq : tt.prefix, 1);
  2865. };
  2866. pp.getTokenFromCode = function (code) {
  2867. switch (code) {
  2868. // The interpretation of a dot depends on whether it is followed
  2869. // by a digit or another two dots.
  2870. case 46:
  2871. // '.'
  2872. return this.readToken_dot();
  2873. // Punctuation tokens.
  2874. case 40:
  2875. ++this.pos;return this.finishToken(tt.parenL);
  2876. case 41:
  2877. ++this.pos;return this.finishToken(tt.parenR);
  2878. case 59:
  2879. ++this.pos;return this.finishToken(tt.semi);
  2880. case 44:
  2881. ++this.pos;return this.finishToken(tt.comma);
  2882. case 91:
  2883. ++this.pos;return this.finishToken(tt.bracketL);
  2884. case 93:
  2885. ++this.pos;return this.finishToken(tt.bracketR);
  2886. case 123:
  2887. ++this.pos;return this.finishToken(tt.braceL);
  2888. case 125:
  2889. ++this.pos;return this.finishToken(tt.braceR);
  2890. case 58:
  2891. ++this.pos;return this.finishToken(tt.colon);
  2892. case 63:
  2893. ++this.pos;return this.finishToken(tt.question);
  2894. case 96:
  2895. // '`'
  2896. if (this.options.ecmaVersion < 6) break;
  2897. ++this.pos;
  2898. return this.finishToken(tt.backQuote);
  2899. case 48:
  2900. // '0'
  2901. var next = this.input.charCodeAt(this.pos + 1);
  2902. if (next === 120 || next === 88) return this.readRadixNumber(16); // '0x', '0X' - hex number
  2903. if (this.options.ecmaVersion >= 6) {
  2904. if (next === 111 || next === 79) return this.readRadixNumber(8); // '0o', '0O' - octal number
  2905. if (next === 98 || next === 66) return this.readRadixNumber(2); // '0b', '0B' - binary number
  2906. }
  2907. // Anything else beginning with a digit is an integer, octal
  2908. // number, or float.
  2909. case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:
  2910. // 1-9
  2911. return this.readNumber(false);
  2912. // Quotes produce strings.
  2913. case 34:case 39:
  2914. // '"', "'"
  2915. return this.readString(code);
  2916. // Operators are parsed inline in tiny state machines. '=' (61) is
  2917. // often referred to. `finishOp` simply skips the amount of
  2918. // characters it is given as second argument, and returns a token
  2919. // of the type given by its first argument.
  2920. case 47:
  2921. // '/'
  2922. return this.readToken_slash();
  2923. case 37:case 42:
  2924. // '%*'
  2925. return this.readToken_mult_modulo(code);
  2926. case 124:case 38:
  2927. // '|&'
  2928. return this.readToken_pipe_amp(code);
  2929. case 94:
  2930. // '^'
  2931. return this.readToken_caret();
  2932. case 43:case 45:
  2933. // '+-'
  2934. return this.readToken_plus_min(code);
  2935. case 60:case 62:
  2936. // '<>'
  2937. return this.readToken_lt_gt(code);
  2938. case 61:case 33:
  2939. // '=!'
  2940. return this.readToken_eq_excl(code);
  2941. case 126:
  2942. // '~'
  2943. return this.finishOp(tt.prefix, 1);
  2944. }
  2945. this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
  2946. };
  2947. pp.finishOp = function (type, size) {
  2948. var str = this.input.slice(this.pos, this.pos + size);
  2949. this.pos += size;
  2950. return this.finishToken(type, str);
  2951. };
  2952. var regexpUnicodeSupport = false;
  2953. try {
  2954. new RegExp("￿", "u");regexpUnicodeSupport = true;
  2955. } catch (e) {}
  2956. // Parse a regular expression. Some context-awareness is necessary,
  2957. // since a '/' inside a '[]' set does not end the expression.
  2958. pp.readRegexp = function () {
  2959. var escaped = undefined,
  2960. inClass = undefined,
  2961. start = this.pos;
  2962. for (;;) {
  2963. if (this.pos >= this.input.length) this.raise(start, "Unterminated regular expression");
  2964. var ch = this.input.charAt(this.pos);
  2965. if (lineBreak.test(ch)) this.raise(start, "Unterminated regular expression");
  2966. if (!escaped) {
  2967. if (ch === "[") inClass = true;else if (ch === "]" && inClass) inClass = false;else if (ch === "/" && !inClass) break;
  2968. escaped = ch === "\\";
  2969. } else escaped = false;
  2970. ++this.pos;
  2971. }
  2972. var content = this.input.slice(start, this.pos);
  2973. ++this.pos;
  2974. // Need to use `readWord1` because '\uXXXX' sequences are allowed
  2975. // here (don't ask).
  2976. var mods = this.readWord1();
  2977. var tmp = content;
  2978. if (mods) {
  2979. var validFlags = /^[gmsiy]*$/;
  2980. if (this.options.ecmaVersion >= 6) validFlags = /^[gmsiyu]*$/;
  2981. if (!validFlags.test(mods)) this.raise(start, "Invalid regular expression flag");
  2982. if (mods.indexOf("u") >= 0 && !regexpUnicodeSupport) {
  2983. // Replace each astral symbol and every Unicode escape sequence that
  2984. // possibly represents an astral symbol or a paired surrogate with a
  2985. // single ASCII symbol to avoid throwing on regular expressions that
  2986. // are only valid in combination with the `/u` flag.
  2987. // Note: replacing with the ASCII symbol `x` might cause false
  2988. // negatives in unlikely scenarios. For example, `[\u{61}-b]` is a
  2989. // perfectly valid pattern that is equivalent to `[a-b]`, but it would
  2990. // be replaced by `[x-b]` which throws an error.
  2991. tmp = tmp.replace(/\\u([a-fA-F0-9]{4})|\\u\{([0-9a-fA-F]+)\}|[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "x");
  2992. }
  2993. }
  2994. // Detect invalid regular expressions.
  2995. var value = null;
  2996. // Rhino's regular expression parser is flaky and throws uncatchable exceptions,
  2997. // so don't do detection if we are running under Rhino
  2998. if (!isRhino) {
  2999. try {
  3000. new RegExp(tmp);
  3001. } catch (e) {
  3002. if (e instanceof SyntaxError) this.raise(start, "Error parsing regular expression: " + e.message);
  3003. this.raise(e);
  3004. }
  3005. // Get a regular expression object for this pattern-flag pair, or `null` in
  3006. // case the current environment doesn't support the flags it uses.
  3007. try {
  3008. value = new RegExp(content, mods);
  3009. } catch (err) {}
  3010. }
  3011. return this.finishToken(tt.regexp, { pattern: content, flags: mods, value: value });
  3012. };
  3013. // Read an integer in the given radix. Return null if zero digits
  3014. // were read, the integer value otherwise. When `len` is given, this
  3015. // will return `null` unless the integer has exactly `len` digits.
  3016. pp.readInt = function (radix, len) {
  3017. var start = this.pos,
  3018. total = 0;
  3019. for (var i = 0, e = len == null ? Infinity : len; i < e; ++i) {
  3020. var code = this.input.charCodeAt(this.pos),
  3021. val = undefined;
  3022. if (code >= 97) val = code - 97 + 10; // a
  3023. else if (code >= 65) val = code - 65 + 10; // A
  3024. else if (code >= 48 && code <= 57) val = code - 48; // 0-9
  3025. else val = Infinity;
  3026. if (val >= radix) break;
  3027. ++this.pos;
  3028. total = total * radix + val;
  3029. }
  3030. if (this.pos === start || len != null && this.pos - start !== len) return null;
  3031. return total;
  3032. };
  3033. pp.readRadixNumber = function (radix) {
  3034. this.pos += 2; // 0x
  3035. var val = this.readInt(radix);
  3036. if (val == null) this.raise(this.start + 2, "Expected number in radix " + radix);
  3037. if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number");
  3038. return this.finishToken(tt.num, val);
  3039. };
  3040. // Read an integer, octal integer, or floating-point number.
  3041. pp.readNumber = function (startsWithDot) {
  3042. var start = this.pos,
  3043. isFloat = false,
  3044. octal = this.input.charCodeAt(this.pos) === 48;
  3045. if (!startsWithDot && this.readInt(10) === null) this.raise(start, "Invalid number");
  3046. if (this.input.charCodeAt(this.pos) === 46) {
  3047. ++this.pos;
  3048. this.readInt(10);
  3049. isFloat = true;
  3050. }
  3051. var next = this.input.charCodeAt(this.pos);
  3052. if (next === 69 || next === 101) {
  3053. // 'eE'
  3054. next = this.input.charCodeAt(++this.pos);
  3055. if (next === 43 || next === 45) ++this.pos; // '+-'
  3056. if (this.readInt(10) === null) this.raise(start, "Invalid number");
  3057. isFloat = true;
  3058. }
  3059. if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number");
  3060. var str = this.input.slice(start, this.pos),
  3061. val = undefined;
  3062. if (isFloat) val = parseFloat(str);else if (!octal || str.length === 1) val = parseInt(str, 10);else if (/[89]/.test(str) || this.strict) this.raise(start, "Invalid number");else val = parseInt(str, 8);
  3063. return this.finishToken(tt.num, val);
  3064. };
  3065. // Read a string value, interpreting backslash-escapes.
  3066. pp.readCodePoint = function () {
  3067. var ch = this.input.charCodeAt(this.pos),
  3068. code = undefined;
  3069. if (ch === 123) {
  3070. if (this.options.ecmaVersion < 6) this.unexpected();
  3071. ++this.pos;
  3072. code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
  3073. ++this.pos;
  3074. if (code > 1114111) this.unexpected();
  3075. } else {
  3076. code = this.readHexChar(4);
  3077. }
  3078. return code;
  3079. };
  3080. function codePointToString(code) {
  3081. // UTF-16 Decoding
  3082. if (code <= 65535) {
  3083. return String.fromCharCode(code);
  3084. }return String.fromCharCode((code - 65536 >> 10) + 55296, (code - 65536 & 1023) + 56320);
  3085. }
  3086. pp.readString = function (quote) {
  3087. var out = "",
  3088. chunkStart = ++this.pos;
  3089. for (;;) {
  3090. if (this.pos >= this.input.length) this.raise(this.start, "Unterminated string constant");
  3091. var ch = this.input.charCodeAt(this.pos);
  3092. if (ch === quote) break;
  3093. if (ch === 92) {
  3094. // '\'
  3095. out += this.input.slice(chunkStart, this.pos);
  3096. out += this.readEscapedChar();
  3097. chunkStart = this.pos;
  3098. } else {
  3099. if (isNewLine(ch)) this.raise(this.start, "Unterminated string constant");
  3100. ++this.pos;
  3101. }
  3102. }
  3103. out += this.input.slice(chunkStart, this.pos++);
  3104. return this.finishToken(tt.string, out);
  3105. };
  3106. // Reads template string tokens.
  3107. pp.readTmplToken = function () {
  3108. var out = "",
  3109. chunkStart = this.pos;
  3110. for (;;) {
  3111. if (this.pos >= this.input.length) this.raise(this.start, "Unterminated template");
  3112. var ch = this.input.charCodeAt(this.pos);
  3113. if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) {
  3114. // '`', '${'
  3115. if (this.pos === this.start && this.type === tt.template) {
  3116. if (ch === 36) {
  3117. this.pos += 2;
  3118. return this.finishToken(tt.dollarBraceL);
  3119. } else {
  3120. ++this.pos;
  3121. return this.finishToken(tt.backQuote);
  3122. }
  3123. }
  3124. out += this.input.slice(chunkStart, this.pos);
  3125. return this.finishToken(tt.template, out);
  3126. }
  3127. if (ch === 92) {
  3128. // '\'
  3129. out += this.input.slice(chunkStart, this.pos);
  3130. out += this.readEscapedChar();
  3131. chunkStart = this.pos;
  3132. } else if (isNewLine(ch)) {
  3133. out += this.input.slice(chunkStart, this.pos);
  3134. ++this.pos;
  3135. if (ch === 13 && this.input.charCodeAt(this.pos) === 10) {
  3136. ++this.pos;
  3137. out += "\n";
  3138. } else {
  3139. out += String.fromCharCode(ch);
  3140. }
  3141. if (this.options.locations) {
  3142. ++this.curLine;
  3143. this.lineStart = this.pos;
  3144. }
  3145. chunkStart = this.pos;
  3146. } else {
  3147. ++this.pos;
  3148. }
  3149. }
  3150. };
  3151. // Used to read escaped characters
  3152. pp.readEscapedChar = function () {
  3153. var ch = this.input.charCodeAt(++this.pos);
  3154. var octal = /^[0-7]+/.exec(this.input.slice(this.pos, this.pos + 3));
  3155. if (octal) octal = octal[0];
  3156. while (octal && parseInt(octal, 8) > 255) octal = octal.slice(0, -1);
  3157. if (octal === "0") octal = null;
  3158. ++this.pos;
  3159. if (octal) {
  3160. if (this.strict) this.raise(this.pos - 2, "Octal literal in strict mode");
  3161. this.pos += octal.length - 1;
  3162. return String.fromCharCode(parseInt(octal, 8));
  3163. } else {
  3164. switch (ch) {
  3165. case 110:
  3166. return "\n"; // 'n' -> '\n'
  3167. case 114:
  3168. return "\r"; // 'r' -> '\r'
  3169. case 120:
  3170. return String.fromCharCode(this.readHexChar(2)); // 'x'
  3171. case 117:
  3172. return codePointToString(this.readCodePoint()); // 'u'
  3173. case 116:
  3174. return "\t"; // 't' -> '\t'
  3175. case 98:
  3176. return "\b"; // 'b' -> '\b'
  3177. case 118:
  3178. return "\u000b"; // 'v' -> '\u000b'
  3179. case 102:
  3180. return "\f"; // 'f' -> '\f'
  3181. case 48:
  3182. return "\u0000"; // 0 -> '\0'
  3183. case 13:
  3184. if (this.input.charCodeAt(this.pos) === 10) ++this.pos; // '\r\n'
  3185. case 10:
  3186. // ' \n'
  3187. if (this.options.locations) {
  3188. this.lineStart = this.pos;++this.curLine;
  3189. }
  3190. return "";
  3191. default:
  3192. return String.fromCharCode(ch);
  3193. }
  3194. }
  3195. };
  3196. // Used to read character escape sequences ('\x', '\u', '\U').
  3197. pp.readHexChar = function (len) {
  3198. var n = this.readInt(16, len);
  3199. if (n === null) this.raise(this.start, "Bad character escape sequence");
  3200. return n;
  3201. };
  3202. // Used to signal to callers of `readWord1` whether the word
  3203. // contained any escape sequences. This is needed because words with
  3204. // escape sequences must not be interpreted as keywords.
  3205. var containsEsc;
  3206. // Read an identifier, and return it as a string. Sets `containsEsc`
  3207. // to whether the word contained a '\u' escape.
  3208. //
  3209. // Incrementally adds only escaped chars, adding other chunks as-is
  3210. // as a micro-optimization.
  3211. pp.readWord1 = function () {
  3212. containsEsc = false;
  3213. var word = "",
  3214. first = true,
  3215. chunkStart = this.pos;
  3216. var astral = this.options.ecmaVersion >= 6;
  3217. while (this.pos < this.input.length) {
  3218. var ch = this.fullCharCodeAtPos();
  3219. if (isIdentifierChar(ch, astral)) {
  3220. this.pos += ch <= 65535 ? 1 : 2;
  3221. } else if (ch === 92) {
  3222. // "\"
  3223. containsEsc = true;
  3224. word += this.input.slice(chunkStart, this.pos);
  3225. var escStart = this.pos;
  3226. if (this.input.charCodeAt(++this.pos) != 117) // "u"
  3227. this.raise(this.pos, "Expecting Unicode escape sequence \\uXXXX");
  3228. ++this.pos;
  3229. var esc = this.readCodePoint();
  3230. if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral)) this.raise(escStart, "Invalid Unicode escape");
  3231. word += codePointToString(esc);
  3232. chunkStart = this.pos;
  3233. } else {
  3234. break;
  3235. }
  3236. first = false;
  3237. }
  3238. return word + this.input.slice(chunkStart, this.pos);
  3239. };
  3240. // Read an identifier or keyword token. Will check for reserved
  3241. // words when necessary.
  3242. pp.readWord = function () {
  3243. var word = this.readWord1();
  3244. var type = tt.name;
  3245. if ((this.options.ecmaVersion >= 6 || !containsEsc) && this.isKeyword(word)) type = keywordTypes[word];
  3246. return this.finishToken(type, word);
  3247. };
  3248. },{"./identifier":7,"./location":8,"./state":13,"./tokentype":17,"./whitespace":19}],17:[function(_dereq_,module,exports){
  3249. "use strict";
  3250. var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
  3251. exports.__esModule = true;
  3252. // ## Token types
  3253. // The assignment of fine-grained, information-carrying type objects
  3254. // allows the tokenizer to store the information it has about a
  3255. // token in a way that is very cheap for the parser to look up.
  3256. // All token type variables start with an underscore, to make them
  3257. // easy to recognize.
  3258. // The `beforeExpr` property is used to disambiguate between regular
  3259. // expressions and divisions. It is set on all token types that can
  3260. // be followed by an expression (thus, a slash after them would be a
  3261. // regular expression).
  3262. //
  3263. // `isLoop` marks a keyword as starting a loop, which is important
  3264. // to know when parsing a label, in order to allow or disallow
  3265. // continue jumps to that label.
  3266. var TokenType = exports.TokenType = function TokenType(label) {
  3267. var conf = arguments[1] === undefined ? {} : arguments[1];
  3268. _classCallCheck(this, TokenType);
  3269. this.label = label;
  3270. this.keyword = conf.keyword;
  3271. this.beforeExpr = !!conf.beforeExpr;
  3272. this.startsExpr = !!conf.startsExpr;
  3273. this.isLoop = !!conf.isLoop;
  3274. this.isAssign = !!conf.isAssign;
  3275. this.prefix = !!conf.prefix;
  3276. this.postfix = !!conf.postfix;
  3277. this.binop = conf.binop || null;
  3278. this.updateContext = null;
  3279. };
  3280. function binop(name, prec) {
  3281. return new TokenType(name, { beforeExpr: true, binop: prec });
  3282. }
  3283. var beforeExpr = { beforeExpr: true },
  3284. startsExpr = { startsExpr: true };
  3285. var types = {
  3286. num: new TokenType("num", startsExpr),
  3287. regexp: new TokenType("regexp", startsExpr),
  3288. string: new TokenType("string", startsExpr),
  3289. name: new TokenType("name", startsExpr),
  3290. eof: new TokenType("eof"),
  3291. // Punctuation token types.
  3292. bracketL: new TokenType("[", { beforeExpr: true, startsExpr: true }),
  3293. bracketR: new TokenType("]"),
  3294. braceL: new TokenType("{", { beforeExpr: true, startsExpr: true }),
  3295. braceR: new TokenType("}"),
  3296. parenL: new TokenType("(", { beforeExpr: true, startsExpr: true }),
  3297. parenR: new TokenType(")"),
  3298. comma: new TokenType(",", beforeExpr),
  3299. semi: new TokenType(";", beforeExpr),
  3300. colon: new TokenType(":", beforeExpr),
  3301. dot: new TokenType("."),
  3302. question: new TokenType("?", beforeExpr),
  3303. arrow: new TokenType("=>", beforeExpr),
  3304. template: new TokenType("template"),
  3305. ellipsis: new TokenType("...", beforeExpr),
  3306. backQuote: new TokenType("`", startsExpr),
  3307. dollarBraceL: new TokenType("${", { beforeExpr: true, startsExpr: true }),
  3308. // Operators. These carry several kinds of properties to help the
  3309. // parser use them properly (the presence of these properties is
  3310. // what categorizes them as operators).
  3311. //
  3312. // `binop`, when present, specifies that this operator is a binary
  3313. // operator, and will refer to its precedence.
  3314. //
  3315. // `prefix` and `postfix` mark the operator as a prefix or postfix
  3316. // unary operator.
  3317. //
  3318. // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as
  3319. // binary operators with a very low precedence, that should result
  3320. // in AssignmentExpression nodes.
  3321. eq: new TokenType("=", { beforeExpr: true, isAssign: true }),
  3322. assign: new TokenType("_=", { beforeExpr: true, isAssign: true }),
  3323. incDec: new TokenType("++/--", { prefix: true, postfix: true, startsExpr: true }),
  3324. prefix: new TokenType("prefix", { beforeExpr: true, prefix: true, startsExpr: true }),
  3325. logicalOR: binop("||", 1),
  3326. logicalAND: binop("&&", 2),
  3327. bitwiseOR: binop("|", 3),
  3328. bitwiseXOR: binop("^", 4),
  3329. bitwiseAND: binop("&", 5),
  3330. equality: binop("==/!=", 6),
  3331. relational: binop("</>", 7),
  3332. bitShift: binop("<</>>", 8),
  3333. plusMin: new TokenType("+/-", { beforeExpr: true, binop: 9, prefix: true, startsExpr: true }),
  3334. modulo: binop("%", 10),
  3335. star: binop("*", 10),
  3336. slash: binop("/", 10)
  3337. };
  3338. exports.types = types;
  3339. // Map keyword names to token types.
  3340. var keywords = {};
  3341. exports.keywords = keywords;
  3342. // Succinct definitions of keyword token types
  3343. function kw(name) {
  3344. var options = arguments[1] === undefined ? {} : arguments[1];
  3345. options.keyword = name;
  3346. keywords[name] = types["_" + name] = new TokenType(name, options);
  3347. }
  3348. kw("break");
  3349. kw("case", beforeExpr);
  3350. kw("catch");
  3351. kw("continue");
  3352. kw("debugger");
  3353. kw("default");
  3354. kw("do", { isLoop: true });
  3355. kw("else", beforeExpr);
  3356. kw("finally");
  3357. kw("for", { isLoop: true });
  3358. kw("function", startsExpr);
  3359. kw("if");
  3360. kw("return", beforeExpr);
  3361. kw("switch");
  3362. kw("throw", beforeExpr);
  3363. kw("try");
  3364. kw("var");
  3365. kw("let");
  3366. kw("const");
  3367. kw("while", { isLoop: true });
  3368. kw("with");
  3369. kw("new", { beforeExpr: true, startsExpr: true });
  3370. kw("this", startsExpr);
  3371. kw("super", startsExpr);
  3372. kw("class");
  3373. kw("extends", beforeExpr);
  3374. kw("export");
  3375. kw("import");
  3376. kw("yield", { beforeExpr: true, startsExpr: true });
  3377. kw("null", startsExpr);
  3378. kw("true", startsExpr);
  3379. kw("false", startsExpr);
  3380. kw("in", { beforeExpr: true, binop: 7 });
  3381. kw("instanceof", { beforeExpr: true, binop: 7 });
  3382. kw("typeof", { beforeExpr: true, prefix: true, startsExpr: true });
  3383. kw("void", { beforeExpr: true, prefix: true, startsExpr: true });
  3384. kw("delete", { beforeExpr: true, prefix: true, startsExpr: true });
  3385. },{}],18:[function(_dereq_,module,exports){
  3386. "use strict";
  3387. exports.isArray = isArray;
  3388. // Checks if an object has a property.
  3389. exports.has = has;
  3390. exports.__esModule = true;
  3391. function isArray(obj) {
  3392. return Object.prototype.toString.call(obj) === "[object Array]";
  3393. }
  3394. function has(obj, propName) {
  3395. return Object.prototype.hasOwnProperty.call(obj, propName);
  3396. }
  3397. },{}],19:[function(_dereq_,module,exports){
  3398. "use strict";
  3399. exports.isNewLine = isNewLine;
  3400. exports.__esModule = true;
  3401. // Matches a whole line break (where CRLF is considered a single
  3402. // line break). Used to count lines.
  3403. var lineBreak = /\r\n?|\n|\u2028|\u2029/;
  3404. exports.lineBreak = lineBreak;
  3405. var lineBreakG = new RegExp(lineBreak.source, "g");
  3406. exports.lineBreakG = lineBreakG;
  3407. function isNewLine(code) {
  3408. return code === 10 || code === 13 || code === 8232 || code == 8233;
  3409. }
  3410. var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
  3411. exports.nonASCIIwhitespace = nonASCIIwhitespace;
  3412. },{}]},{},[1])(1)
  3413. });