Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

parser.js 130KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929
  1. // @ts-nocheck
  2. /* parser generated by jison 0.6.1-215 */
  3. /*
  4. * Returns a Parser object of the following structure:
  5. *
  6. * Parser: {
  7. * yy: {} The so-called "shared state" or rather the *source* of it;
  8. * the real "shared state" `yy` passed around to
  9. * the rule actions, etc. is a derivative/copy of this one,
  10. * not a direct reference!
  11. * }
  12. *
  13. * Parser.prototype: {
  14. * yy: {},
  15. * EOF: 1,
  16. * TERROR: 2,
  17. *
  18. * trace: function(errorMessage, ...),
  19. *
  20. * JisonParserError: function(msg, hash),
  21. *
  22. * quoteName: function(name),
  23. * Helper function which can be overridden by user code later on: put suitable
  24. * quotes around literal IDs in a description string.
  25. *
  26. * originalQuoteName: function(name),
  27. * The basic quoteName handler provided by JISON.
  28. * `cleanupAfterParse()` will clean up and reset `quoteName()` to reference this function
  29. * at the end of the `parse()`.
  30. *
  31. * describeSymbol: function(symbol),
  32. * Return a more-or-less human-readable description of the given symbol, when
  33. * available, or the symbol itself, serving as its own 'description' for lack
  34. * of something better to serve up.
  35. *
  36. * Return NULL when the symbol is unknown to the parser.
  37. *
  38. * symbols_: {associative list: name ==> number},
  39. * terminals_: {associative list: number ==> name},
  40. * nonterminals: {associative list: rule-name ==> {associative list: number ==> rule-alt}},
  41. * terminal_descriptions_: (if there are any) {associative list: number ==> description},
  42. * productions_: [...],
  43. *
  44. * performAction: function parser__performAction(yytext, yyleng, yylineno, yyloc, yystate, yysp, yyvstack, yylstack, yystack, yysstack),
  45. *
  46. * The function parameters and `this` have the following value/meaning:
  47. * - `this` : reference to the `yyval` internal object, which has members (`$` and `_$`)
  48. * to store/reference the rule value `$$` and location info `@$`.
  49. *
  50. * One important thing to note about `this` a.k.a. `yyval`: every *reduce* action gets
  51. * to see the same object via the `this` reference, i.e. if you wish to carry custom
  52. * data from one reduce action through to the next within a single parse run, then you
  53. * may get nasty and use `yyval` a.k.a. `this` for storing you own semi-permanent data.
  54. *
  55. * `this.yy` is a direct reference to the `yy` shared state object.
  56. *
  57. * `%parse-param`-specified additional `parse()` arguments have been added to this `yy`
  58. * object at `parse()` start and are therefore available to the action code via the
  59. * same named `yy.xxxx` attributes (where `xxxx` represents a identifier name from
  60. * the %parse-param` list.
  61. *
  62. * - `yytext` : reference to the lexer value which belongs to the last lexer token used
  63. * to match this rule. This is *not* the look-ahead token, but the last token
  64. * that's actually part of this rule.
  65. *
  66. * Formulated another way, `yytext` is the value of the token immediately preceeding
  67. * the current look-ahead token.
  68. * Caveats apply for rules which don't require look-ahead, such as epsilon rules.
  69. *
  70. * - `yyleng` : ditto as `yytext`, only now for the lexer.yyleng value.
  71. *
  72. * - `yylineno`: ditto as `yytext`, only now for the lexer.yylineno value.
  73. *
  74. * - `yyloc` : ditto as `yytext`, only now for the lexer.yylloc lexer token location info.
  75. *
  76. * WARNING: since jison 0.4.18-186 this entry may be NULL/UNDEFINED instead
  77. * of an empty object when no suitable location info can be provided.
  78. *
  79. * - `yystate` : the current parser state number, used internally for dispatching and
  80. * executing the action code chunk matching the rule currently being reduced.
  81. *
  82. * - `yysp` : the current state stack position (a.k.a. 'stack pointer')
  83. *
  84. * This one comes in handy when you are going to do advanced things to the parser
  85. * stacks, all of which are accessible from your action code (see the next entries below).
  86. *
  87. * Also note that you can access this and other stack index values using the new double-hash
  88. * syntax, i.e. `##$ === ##0 === yysp`, while `##1` is the stack index for all things
  89. * related to the first rule term, just like you have `$1`, `@1` and `#1`.
  90. * This is made available to write very advanced grammar action rules, e.g. when you want
  91. * to investigate the parse state stack in your action code, which would, for example,
  92. * be relevant when you wish to implement error diagnostics and reporting schemes similar
  93. * to the work described here:
  94. *
  95. * + Pottier, F., 2016. Reachability and error diagnosis in LR(1) automata.
  96. * In Journées Francophones des Languages Applicatifs.
  97. *
  98. * + Jeffery, C.L., 2003. Generating LR syntax error messages from examples.
  99. * ACM Transactions on Programming Languages and Systems (TOPLAS), 25(5), pp.631–640.
  100. *
  101. * - `yyrulelength`: the current rule's term count, i.e. the number of entries occupied on the stack.
  102. *
  103. * This one comes in handy when you are going to do advanced things to the parser
  104. * stacks, all of which are accessible from your action code (see the next entries below).
  105. *
  106. * - `yyvstack`: reference to the parser value stack. Also accessed via the `$1` etc.
  107. * constructs.
  108. *
  109. * - `yylstack`: reference to the parser token location stack. Also accessed via
  110. * the `@1` etc. constructs.
  111. *
  112. * WARNING: since jison 0.4.18-186 this array MAY contain slots which are
  113. * UNDEFINED rather than an empty (location) object, when the lexer/parser
  114. * action code did not provide a suitable location info object when such a
  115. * slot was filled!
  116. *
  117. * - `yystack` : reference to the parser token id stack. Also accessed via the
  118. * `#1` etc. constructs.
  119. *
  120. * Note: this is a bit of a **white lie** as we can statically decode any `#n` reference to
  121. * its numeric token id value, hence that code wouldn't need the `yystack` but *you* might
  122. * want access this array for your own purposes, such as error analysis as mentioned above!
  123. *
  124. * Note that this stack stores the current stack of *tokens*, that is the sequence of
  125. * already parsed=reduced *nonterminals* (tokens representing rules) and *terminals*
  126. * (lexer tokens *shifted* onto the stack until the rule they belong to is found and
  127. * *reduced*.
  128. *
  129. * - `yysstack`: reference to the parser state stack. This one carries the internal parser
  130. * *states* such as the one in `yystate`, which are used to represent
  131. * the parser state machine in the *parse table*. *Very* *internal* stuff,
  132. * what can I say? If you access this one, you're clearly doing wicked things
  133. *
  134. * - `...` : the extra arguments you specified in the `%parse-param` statement in your
  135. * grammar definition file.
  136. *
  137. * table: [...],
  138. * State transition table
  139. * ----------------------
  140. *
  141. * index levels are:
  142. * - `state` --> hash table
  143. * - `symbol` --> action (number or array)
  144. *
  145. * If the `action` is an array, these are the elements' meaning:
  146. * - index [0]: 1 = shift, 2 = reduce, 3 = accept
  147. * - index [1]: GOTO `state`
  148. *
  149. * If the `action` is a number, it is the GOTO `state`
  150. *
  151. * defaultActions: {...},
  152. *
  153. * parseError: function(str, hash, ExceptionClass),
  154. * yyError: function(str, ...),
  155. * yyRecovering: function(),
  156. * yyErrOk: function(),
  157. * yyClearIn: function(),
  158. *
  159. * constructParseErrorInfo: function(error_message, exception_object, expected_token_set, is_recoverable),
  160. * Helper function **which will be set up during the first invocation of the `parse()` method**.
  161. * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.
  162. * See it's use in this parser kernel in many places; example usage:
  163. *
  164. * var infoObj = parser.constructParseErrorInfo('fail!', null,
  165. * parser.collect_expected_token_set(state), true);
  166. * var retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError);
  167. *
  168. * originalParseError: function(str, hash, ExceptionClass),
  169. * The basic `parseError` handler provided by JISON.
  170. * `cleanupAfterParse()` will clean up and reset `parseError()` to reference this function
  171. * at the end of the `parse()`.
  172. *
  173. * options: { ... parser %options ... },
  174. *
  175. * parse: function(input[, args...]),
  176. * Parse the given `input` and return the parsed value (or `true` when none was provided by
  177. * the root action, in which case the parser is acting as a *matcher*).
  178. * You MAY use the additional `args...` parameters as per `%parse-param` spec of this grammar:
  179. * these extra `args...` are added verbatim to the `yy` object reference as member variables.
  180. *
  181. * WARNING:
  182. * Parser's additional `args...` parameters (via `%parse-param`) MAY conflict with
  183. * any attributes already added to `yy` by the jison run-time;
  184. * when such a collision is detected an exception is thrown to prevent the generated run-time
  185. * from silently accepting this confusing and potentially hazardous situation!
  186. *
  187. * The lexer MAY add its own set of additional parameters (via the `%parse-param` line in
  188. * the lexer section of the grammar spec): these will be inserted in the `yy` shared state
  189. * object and any collision with those will be reported by the lexer via a thrown exception.
  190. *
  191. * cleanupAfterParse: function(resultValue, invoke_post_methods, do_not_nuke_errorinfos),
  192. * Helper function **which will be set up during the first invocation of the `parse()` method**.
  193. * This helper API is invoked at the end of the `parse()` call, unless an exception was thrown
  194. * and `%options no-try-catch` has been defined for this grammar: in that case this helper MAY
  195. * be invoked by calling user code to ensure the `post_parse` callbacks are invoked and
  196. * the internal parser gets properly garbage collected under these particular circumstances.
  197. *
  198. * yyMergeLocationInfo: function(first_index, last_index, first_yylloc, last_yylloc, dont_look_back),
  199. * Helper function **which will be set up during the first invocation of the `parse()` method**.
  200. * This helper API can be invoked to calculate a spanning `yylloc` location info object.
  201. *
  202. * Note: %epsilon rules MAY specify no `first_index` and `first_yylloc`, in which case
  203. * this function will attempt to obtain a suitable location marker by inspecting the location stack
  204. * backwards.
  205. *
  206. * For more info see the documentation comment further below, immediately above this function's
  207. * implementation.
  208. *
  209. * lexer: {
  210. * yy: {...}, A reference to the so-called "shared state" `yy` once
  211. * received via a call to the `.setInput(input, yy)` lexer API.
  212. * EOF: 1,
  213. * ERROR: 2,
  214. * JisonLexerError: function(msg, hash),
  215. * parseError: function(str, hash, ExceptionClass),
  216. * setInput: function(input, [yy]),
  217. * input: function(),
  218. * unput: function(str),
  219. * more: function(),
  220. * reject: function(),
  221. * less: function(n),
  222. * pastInput: function(n),
  223. * upcomingInput: function(n),
  224. * showPosition: function(),
  225. * test_match: function(regex_match_array, rule_index, ...),
  226. * next: function(...),
  227. * lex: function(...),
  228. * begin: function(condition),
  229. * pushState: function(condition),
  230. * popState: function(),
  231. * topState: function(),
  232. * _currentRules: function(),
  233. * stateStackSize: function(),
  234. * cleanupAfterLex: function()
  235. *
  236. * options: { ... lexer %options ... },
  237. *
  238. * performAction: function(yy, yy_, $avoiding_name_collisions, YY_START, ...),
  239. * rules: [...],
  240. * conditions: {associative list: name ==> set},
  241. * }
  242. * }
  243. *
  244. *
  245. * token location info (@$, _$, etc.): {
  246. * first_line: n,
  247. * last_line: n,
  248. * first_column: n,
  249. * last_column: n,
  250. * range: [start_number, end_number]
  251. * (where the numbers are indexes into the input string, zero-based)
  252. * }
  253. *
  254. * ---
  255. *
  256. * The `parseError` function receives a 'hash' object with these members for lexer and
  257. * parser errors:
  258. *
  259. * {
  260. * text: (matched text)
  261. * token: (the produced terminal token, if any)
  262. * token_id: (the produced terminal token numeric ID, if any)
  263. * line: (yylineno)
  264. * loc: (yylloc)
  265. * }
  266. *
  267. * parser (grammar) errors will also provide these additional members:
  268. *
  269. * {
  270. * expected: (array describing the set of expected tokens;
  271. * may be UNDEFINED when we cannot easily produce such a set)
  272. * state: (integer (or array when the table includes grammar collisions);
  273. * represents the current internal state of the parser kernel.
  274. * can, for example, be used to pass to the `collect_expected_token_set()`
  275. * API to obtain the expected token set)
  276. * action: (integer; represents the current internal action which will be executed)
  277. * new_state: (integer; represents the next/planned internal state, once the current
  278. * action has executed)
  279. * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule
  280. * available for this particular error)
  281. * state_stack: (array: the current parser LALR/LR internal state stack; this can be used,
  282. * for instance, for advanced error analysis and reporting)
  283. * value_stack: (array: the current parser LALR/LR internal `$$` value stack; this can be used,
  284. * for instance, for advanced error analysis and reporting)
  285. * location_stack: (array: the current parser LALR/LR internal location stack; this can be used,
  286. * for instance, for advanced error analysis and reporting)
  287. * yy: (object: the current parser internal "shared state" `yy`
  288. * as is also available in the rule actions; this can be used,
  289. * for instance, for advanced error analysis and reporting)
  290. * lexer: (reference to the current lexer instance used by the parser)
  291. * parser: (reference to the current parser instance)
  292. * }
  293. *
  294. * while `this` will reference the current parser instance.
  295. *
  296. * When `parseError` is invoked by the lexer, `this` will still reference the related *parser*
  297. * instance, while these additional `hash` fields will also be provided:
  298. *
  299. * {
  300. * lexer: (reference to the current lexer instance which reported the error)
  301. * }
  302. *
  303. * When `parseError` is invoked by the parser due to a **JavaScript exception** being fired
  304. * from either the parser or lexer, `this` will still reference the related *parser*
  305. * instance, while these additional `hash` fields will also be provided:
  306. *
  307. * {
  308. * exception: (reference to the exception thrown)
  309. * }
  310. *
  311. * Please do note that in the latter situation, the `expected` field will be omitted as
  312. * this type of failure is assumed not to be due to *parse errors* but rather due to user
  313. * action code in either parser or lexer failing unexpectedly.
  314. *
  315. * ---
  316. *
  317. * You can specify parser options by setting / modifying the `.yy` object of your Parser instance.
  318. * These options are available:
  319. *
  320. * ### options which are global for all parser instances
  321. *
  322. * Parser.pre_parse: function(yy)
  323. * optional: you can specify a pre_parse() function in the chunk following
  324. * the grammar, i.e. after the last `%%`.
  325. * Parser.post_parse: function(yy, retval, parseInfo) { return retval; }
  326. * optional: you can specify a post_parse() function in the chunk following
  327. * the grammar, i.e. after the last `%%`. When it does not return any value,
  328. * the parser will return the original `retval`.
  329. *
  330. * ### options which can be set up per parser instance
  331. *
  332. * yy: {
  333. * pre_parse: function(yy)
  334. * optional: is invoked before the parse cycle starts (and before the first
  335. * invocation of `lex()`) but immediately after the invocation of
  336. * `parser.pre_parse()`).
  337. * post_parse: function(yy, retval, parseInfo) { return retval; }
  338. * optional: is invoked when the parse terminates due to success ('accept')
  339. * or failure (even when exceptions are thrown).
  340. * `retval` contains the return value to be produced by `Parser.parse()`;
  341. * this function can override the return value by returning another.
  342. * When it does not return any value, the parser will return the original
  343. * `retval`.
  344. * This function is invoked immediately before `parser.post_parse()`.
  345. *
  346. * parseError: function(str, hash, ExceptionClass)
  347. * optional: overrides the default `parseError` function.
  348. * quoteName: function(name),
  349. * optional: overrides the default `quoteName` function.
  350. * }
  351. *
  352. * parser.lexer.options: {
  353. * pre_lex: function()
  354. * optional: is invoked before the lexer is invoked to produce another token.
  355. * `this` refers to the Lexer object.
  356. * post_lex: function(token) { return token; }
  357. * optional: is invoked when the lexer has produced a token `token`;
  358. * this function can override the returned token value by returning another.
  359. * When it does not return any (truthy) value, the lexer will return
  360. * the original `token`.
  361. * `this` refers to the Lexer object.
  362. *
  363. * ranges: boolean
  364. * optional: `true` ==> token location info will include a .range[] member.
  365. * flex: boolean
  366. * optional: `true` ==> flex-like lexing behaviour where the rules are tested
  367. * exhaustively to find the longest match.
  368. * backtrack_lexer: boolean
  369. * optional: `true` ==> lexer regexes are tested in order and for invoked;
  370. * the lexer terminates the scan when a token is returned by the action code.
  371. * xregexp: boolean
  372. * optional: `true` ==> lexer rule regexes are "extended regex format" requiring the
  373. * `XRegExp` library. When this `%option` has not been specified at compile time, all lexer
  374. * rule regexes have been written as standard JavaScript RegExp expressions.
  375. * }
  376. */
  377. var parser = (function () {
  378. // See also:
  379. // http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508
  380. // but we keep the prototype.constructor and prototype.name assignment lines too for compatibility
  381. // with userland code which might access the derived class in a 'classic' way.
  382. function JisonParserError(msg, hash) {
  383. Object.defineProperty(this, 'name', {
  384. enumerable: false,
  385. writable: false,
  386. value: 'JisonParserError'
  387. });
  388. if (msg == null) msg = '???';
  389. Object.defineProperty(this, 'message', {
  390. enumerable: false,
  391. writable: true,
  392. value: msg
  393. });
  394. this.hash = hash;
  395. var stacktrace;
  396. if (hash && hash.exception instanceof Error) {
  397. var ex2 = hash.exception;
  398. this.message = ex2.message || msg;
  399. stacktrace = ex2.stack;
  400. }
  401. if (!stacktrace) {
  402. if (Error.hasOwnProperty('captureStackTrace')) { // V8/Chrome engine
  403. Error.captureStackTrace(this, this.constructor);
  404. } else {
  405. stacktrace = (new Error(msg)).stack;
  406. }
  407. }
  408. if (stacktrace) {
  409. Object.defineProperty(this, 'stack', {
  410. enumerable: false,
  411. writable: false,
  412. value: stacktrace
  413. });
  414. }
  415. }
  416. if (typeof Object.setPrototypeOf === 'function') {
  417. Object.setPrototypeOf(JisonParserError.prototype, Error.prototype);
  418. } else {
  419. JisonParserError.prototype = Object.create(Error.prototype);
  420. }
  421. JisonParserError.prototype.constructor = JisonParserError;
  422. JisonParserError.prototype.name = 'JisonParserError';
  423. // helper: reconstruct the productions[] table
  424. function bp(s) {
  425. var rv = [];
  426. var p = s.pop;
  427. var r = s.rule;
  428. for (var i = 0, l = p.length; i < l; i++) {
  429. rv.push([
  430. p[i],
  431. r[i]
  432. ]);
  433. }
  434. return rv;
  435. }
  436. // helper: reconstruct the defaultActions[] table
  437. function bda(s) {
  438. var rv = {};
  439. var d = s.idx;
  440. var g = s.goto;
  441. for (var i = 0, l = d.length; i < l; i++) {
  442. var j = d[i];
  443. rv[j] = g[i];
  444. }
  445. return rv;
  446. }
  447. // helper: reconstruct the 'goto' table
  448. function bt(s) {
  449. var rv = [];
  450. var d = s.len;
  451. var y = s.symbol;
  452. var t = s.type;
  453. var a = s.state;
  454. var m = s.mode;
  455. var g = s.goto;
  456. for (var i = 0, l = d.length; i < l; i++) {
  457. var n = d[i];
  458. var q = {};
  459. for (var j = 0; j < n; j++) {
  460. var z = y.shift();
  461. switch (t.shift()) {
  462. case 2:
  463. q[z] = [
  464. m.shift(),
  465. g.shift()
  466. ];
  467. break;
  468. case 0:
  469. q[z] = a.shift();
  470. break;
  471. default:
  472. // type === 1: accept
  473. q[z] = [
  474. 3
  475. ];
  476. }
  477. }
  478. rv.push(q);
  479. }
  480. return rv;
  481. }
  482. // helper: runlength encoding with increment step: code, length: step (default step = 0)
  483. // `this` references an array
  484. function s(c, l, a) {
  485. a = a || 0;
  486. for (var i = 0; i < l; i++) {
  487. this.push(c);
  488. c += a;
  489. }
  490. }
  491. // helper: duplicate sequence from *relative* offset and length.
  492. // `this` references an array
  493. function c(i, l) {
  494. i = this.length - i;
  495. for (l += i; i < l; i++) {
  496. this.push(this[i]);
  497. }
  498. }
  499. // helper: unpack an array using helpers and data, all passed in an array argument 'a'.
  500. function u(a) {
  501. var rv = [];
  502. for (var i = 0, l = a.length; i < l; i++) {
  503. var e = a[i];
  504. // Is this entry a helper function?
  505. if (typeof e === 'function') {
  506. i++;
  507. e.apply(rv, a[i]);
  508. } else {
  509. rv.push(e);
  510. }
  511. }
  512. return rv;
  513. }
  514. var parser = {
  515. // Code Generator Information Report
  516. // ---------------------------------
  517. //
  518. // Options:
  519. //
  520. // default action mode: ............. ["classic","merge"]
  521. // test-compile action mode: ........ "parser:*,lexer:*"
  522. // try..catch: ...................... true
  523. // default resolve on conflict: ..... true
  524. // on-demand look-ahead: ............ false
  525. // error recovery token skip maximum: 3
  526. // yyerror in parse actions is: ..... NOT recoverable,
  527. // yyerror in lexer actions and other non-fatal lexer are:
  528. // .................................. NOT recoverable,
  529. // debug grammar/output: ............ false
  530. // has partial LR conflict upgrade: true
  531. // rudimentary token-stack support: false
  532. // parser table compression mode: ... 2
  533. // export debug tables: ............. false
  534. // export *all* tables: ............. false
  535. // module type: ..................... commonjs
  536. // parser engine type: .............. lalr
  537. // output main() in the module: ..... true
  538. // has user-specified main(): ....... false
  539. // has user-specified require()/import modules for main():
  540. // .................................. false
  541. // number of expected conflicts: .... 0
  542. //
  543. //
  544. // Parser Analysis flags:
  545. //
  546. // no significant actions (parser is a language matcher only):
  547. // .................................. false
  548. // uses yyleng: ..................... false
  549. // uses yylineno: ................... false
  550. // uses yytext: ..................... false
  551. // uses yylloc: ..................... false
  552. // uses ParseError API: ............. false
  553. // uses YYERROR: .................... false
  554. // uses YYRECOVERING: ............... false
  555. // uses YYERROK: .................... false
  556. // uses YYCLEARIN: .................. false
  557. // tracks rule values: .............. true
  558. // assigns rule values: ............. true
  559. // uses location tracking: .......... true
  560. // assigns location: ................ true
  561. // uses yystack: .................... false
  562. // uses yysstack: ................... false
  563. // uses yysp: ....................... true
  564. // uses yyrulelength: ............... false
  565. // uses yyMergeLocationInfo API: .... true
  566. // has error recovery: .............. false
  567. // has error reporting: ............. false
  568. //
  569. // --------- END OF REPORT -----------
  570. trace: function no_op_trace() { },
  571. JisonParserError: JisonParserError,
  572. yy: {},
  573. options: {
  574. type: "lalr",
  575. hasPartialLrUpgradeOnConflict: true,
  576. errorRecoveryTokenDiscardCount: 3,
  577. caseInsensitive: true
  578. },
  579. symbols_: {
  580. "$accept": 0,
  581. "$end": 1,
  582. "ADD": 6,
  583. "ANGLE": 13,
  584. "CALC": 3,
  585. "DIV": 9,
  586. "EOF": 1,
  587. "FREQ": 15,
  588. "FUNCTION": 11,
  589. "LENGTH": 12,
  590. "LPAREN": 4,
  591. "MUL": 8,
  592. "NUMBER": 10,
  593. "PERCENTAGE": 17,
  594. "RES": 16,
  595. "RPAREN": 5,
  596. "SUB": 7,
  597. "TIME": 14,
  598. "UNKNOWN": 18,
  599. "css_value": 23,
  600. "error": 2,
  601. "expression": 19,
  602. "function": 22,
  603. "math_expression": 20,
  604. "value": 21
  605. },
  606. terminals_: {
  607. 1: "EOF",
  608. 2: "error",
  609. 3: "CALC",
  610. 4: "LPAREN",
  611. 5: "RPAREN",
  612. 6: "ADD",
  613. 7: "SUB",
  614. 8: "MUL",
  615. 9: "DIV",
  616. 10: "NUMBER",
  617. 11: "FUNCTION",
  618. 12: "LENGTH",
  619. 13: "ANGLE",
  620. 14: "TIME",
  621. 15: "FREQ",
  622. 16: "RES",
  623. 17: "PERCENTAGE",
  624. 18: "UNKNOWN"
  625. },
  626. TERROR: 2,
  627. EOF: 1,
  628. // internals: defined here so the object *structure* doesn't get modified by parse() et al,
  629. // thus helping JIT compilers like Chrome V8.
  630. originalQuoteName: null,
  631. originalParseError: null,
  632. cleanupAfterParse: null,
  633. constructParseErrorInfo: null,
  634. yyMergeLocationInfo: null,
  635. __reentrant_call_depth: 0, // INTERNAL USE ONLY
  636. __error_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup
  637. __error_recovery_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup
  638. // APIs which will be set up depending on user action code analysis:
  639. //yyRecovering: 0,
  640. //yyErrOk: 0,
  641. //yyClearIn: 0,
  642. // Helper APIs
  643. // -----------
  644. // Helper function which can be overridden by user code later on: put suitable quotes around
  645. // literal IDs in a description string.
  646. quoteName: function parser_quoteName(id_str) {
  647. return '"' + id_str + '"';
  648. },
  649. // Return the name of the given symbol (terminal or non-terminal) as a string, when available.
  650. //
  651. // Return NULL when the symbol is unknown to the parser.
  652. getSymbolName: function parser_getSymbolName(symbol) {
  653. if (this.terminals_[symbol]) {
  654. return this.terminals_[symbol];
  655. }
  656. // Otherwise... this might refer to a RULE token i.e. a non-terminal: see if we can dig that one up.
  657. //
  658. // An example of this may be where a rule's action code contains a call like this:
  659. //
  660. // parser.getSymbolName(#$)
  661. //
  662. // to obtain a human-readable name of the current grammar rule.
  663. var s = this.symbols_;
  664. for (var key in s) {
  665. if (s[key] === symbol) {
  666. return key;
  667. }
  668. }
  669. return null;
  670. },
  671. // Return a more-or-less human-readable description of the given symbol, when available,
  672. // or the symbol itself, serving as its own 'description' for lack of something better to serve up.
  673. //
  674. // Return NULL when the symbol is unknown to the parser.
  675. describeSymbol: function parser_describeSymbol(symbol) {
  676. if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) {
  677. return this.terminal_descriptions_[symbol];
  678. }
  679. else if (symbol === this.EOF) {
  680. return 'end of input';
  681. }
  682. var id = this.getSymbolName(symbol);
  683. if (id) {
  684. return this.quoteName(id);
  685. }
  686. return null;
  687. },
  688. // Produce a (more or less) human-readable list of expected tokens at the point of failure.
  689. //
  690. // The produced list may contain token or token set descriptions instead of the tokens
  691. // themselves to help turning this output into something that easier to read by humans
  692. // unless `do_not_describe` parameter is set, in which case a list of the raw, *numeric*,
  693. // expected terminals and nonterminals is produced.
  694. //
  695. // The returned list (array) will not contain any duplicate entries.
  696. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) {
  697. var TERROR = this.TERROR;
  698. var tokenset = [];
  699. var check = {};
  700. // Has this (error?) state been outfitted with a custom expectations description text for human consumption?
  701. // If so, use that one instead of the less palatable token set.
  702. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) {
  703. return [
  704. this.state_descriptions_[state]
  705. ];
  706. }
  707. for (var p in this.table[state]) {
  708. p = +p;
  709. if (p !== TERROR) {
  710. var d = do_not_describe ? p : this.describeSymbol(p);
  711. if (d && !check[d]) {
  712. tokenset.push(d);
  713. check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries.
  714. }
  715. }
  716. }
  717. return tokenset;
  718. },
  719. productions_: bp({
  720. pop: u([
  721. 19,
  722. s,
  723. [20, 11],
  724. 21,
  725. 22,
  726. s,
  727. [23, 7]
  728. ]),
  729. rule: u([
  730. 2,
  731. 4,
  732. s,
  733. [3, 4],
  734. 2,
  735. 2,
  736. 3,
  737. s,
  738. [1, 12]
  739. ])
  740. }),
  741. performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yysp, yyvstack, yylstack) {
  742. /* this == yyval */
  743. // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code!
  744. var yy = this.yy;
  745. var yyparser = yy.parser;
  746. var yylexer = yy.lexer;
  747. switch (yystate) {
  748. case 0:
  749. /*! Production:: $accept : expression $end */
  750. // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-):
  751. this.$ = yyvstack[yysp - 1];
  752. this._$ = yylstack[yysp - 1];
  753. // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-)
  754. break;
  755. case 1:
  756. /*! Production:: expression : math_expression EOF */
  757. // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-):
  758. this.$ = yyvstack[yysp - 1];
  759. this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
  760. // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-)
  761. return yyvstack[yysp - 1];
  762. break;
  763. case 2:
  764. /*! Production:: math_expression : CALC LPAREN math_expression RPAREN */
  765. // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-):
  766. this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp);
  767. // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-)
  768. this.$ = yyvstack[yysp - 1];
  769. this.$.source.start = { index: yylstack[yysp - 3].range[0] };
  770. this.$.source.end = { index: yylstack[yysp].range[1] };
  771. break;
  772. case 3:
  773. /*! Production:: math_expression : math_expression ADD math_expression */
  774. case 4:
  775. /*! Production:: math_expression : math_expression SUB math_expression */
  776. case 5:
  777. /*! Production:: math_expression : math_expression MUL math_expression */
  778. case 6:
  779. /*! Production:: math_expression : math_expression DIV math_expression */
  780. // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-):
  781. this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
  782. // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-)
  783. this.$ = {
  784. type: 'MathExpression', operator: yyvstack[yysp - 1], left: yyvstack[yysp - 2], right: yyvstack[yysp],
  785. source: {
  786. start: yyvstack[yysp - 2].source.start, end: yyvstack[yysp].source.end,
  787. operator: { start: { index: yylstack[yysp - 1].range[0] }, end: { index: yylstack[yysp - 1].range[1] } }
  788. }
  789. };
  790. break;
  791. case 7:
  792. /*! Production:: math_expression : SUB math_expression */
  793. // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
  794. this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
  795. // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
  796. if (yylstack[yysp - 1].range[1] !== yyvstack[yysp].source.start.index) {
  797. throw new Error('Unexpected spaces was found between sign and value');
  798. }
  799. if (typeof yyvstack[yysp].value !== 'number') {
  800. throw new Error('Unexpected sign');
  801. }
  802. if (yyvstack[yysp].sign) {
  803. throw new Error('Unexpected continuous sign');
  804. }
  805. this.$ = yyvstack[yysp];
  806. this.$.sign = '-'
  807. this.$.value = -yyvstack[yysp].value;
  808. this.$.source.start.index = yylstack[yysp - 1].range[0];
  809. break;
  810. case 8:
  811. /*! Production:: math_expression : ADD math_expression */
  812. // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
  813. this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
  814. // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
  815. if (yylstack[yysp - 1].range[1] !== yyvstack[yysp].source.start.index) {
  816. throw new Error('Unexpected spaces was found between sign and value');
  817. }
  818. if (typeof yyvstack[yysp].value !== 'number') {
  819. throw new Error('Unexpected sign');
  820. }
  821. if (yyvstack[yysp].sign) {
  822. throw new Error('Unexpected continuous sign');
  823. }
  824. this.$ = yyvstack[yysp];
  825. this.$.sign = '+'
  826. this.$.source.start.index = yylstack[yysp - 1].range[0];
  827. break;
  828. case 9:
  829. /*! Production:: math_expression : LPAREN math_expression RPAREN */
  830. // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-):
  831. this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
  832. // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-)
  833. this.$ = yyvstack[yysp - 1];
  834. this.$.source.start = { index: yylstack[yysp - 2].range[0] };
  835. this.$.source.end = { index: yylstack[yysp].range[1] };
  836. break;
  837. case 10:
  838. /*! Production:: math_expression : function */
  839. case 11:
  840. /*! Production:: math_expression : css_value */
  841. case 12:
  842. /*! Production:: math_expression : value */
  843. // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
  844. this._$ = yylstack[yysp];
  845. // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
  846. this.$ = yyvstack[yysp];
  847. break;
  848. case 13:
  849. /*! Production:: value : NUMBER */
  850. // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
  851. this._$ = yylstack[yysp];
  852. // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
  853. this.$ = { type: 'Value', value: parseFloat(yyvstack[yysp]), source: { start: { index: yylstack[yysp].range[0] }, end: { index: yylstack[yysp].range[1] } } };
  854. break;
  855. case 14:
  856. /*! Production:: function : FUNCTION */
  857. // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
  858. this._$ = yylstack[yysp];
  859. // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
  860. this.$ = { type: 'Function', value: yyvstack[yysp], source: { start: { index: yylstack[yysp].range[0] }, end: { index: yylstack[yysp].range[1] } } };
  861. break;
  862. case 15:
  863. /*! Production:: css_value : LENGTH */
  864. // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
  865. this._$ = yylstack[yysp];
  866. // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
  867. this.$ = { type: 'LengthValue', value: parseFloat(yyvstack[yysp]), unit: /[a-z]+/i.exec(yyvstack[yysp])[0], source: { start: { index: yylstack[yysp].range[0] }, end: { index: yylstack[yysp].range[1] } } };
  868. break;
  869. case 16:
  870. /*! Production:: css_value : ANGLE */
  871. // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
  872. this._$ = yylstack[yysp];
  873. // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
  874. this.$ = { type: 'AngleValue', value: parseFloat(yyvstack[yysp]), unit: /[a-z]+/i.exec(yyvstack[yysp])[0], source: { start: { index: yylstack[yysp].range[0] }, end: { index: yylstack[yysp].range[1] } } };
  875. break;
  876. case 17:
  877. /*! Production:: css_value : TIME */
  878. // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
  879. this._$ = yylstack[yysp];
  880. // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
  881. this.$ = { type: 'TimeValue', value: parseFloat(yyvstack[yysp]), unit: /[a-z]+/i.exec(yyvstack[yysp])[0], source: { start: { index: yylstack[yysp].range[0] }, end: { index: yylstack[yysp].range[1] } } };
  882. break;
  883. case 18:
  884. /*! Production:: css_value : FREQ */
  885. // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
  886. this._$ = yylstack[yysp];
  887. // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
  888. this.$ = { type: 'FrequencyValue', value: parseFloat(yyvstack[yysp]), unit: /[a-z]+/i.exec(yyvstack[yysp])[0], source: { start: { index: yylstack[yysp].range[0] }, end: { index: yylstack[yysp].range[1] } } };
  889. break;
  890. case 19:
  891. /*! Production:: css_value : RES */
  892. // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
  893. this._$ = yylstack[yysp];
  894. // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
  895. this.$ = { type: 'ResolutionValue', value: parseFloat(yyvstack[yysp]), unit: /[a-z]+/i.exec(yyvstack[yysp])[0], source: { start: { index: yylstack[yysp].range[0] }, end: { index: yylstack[yysp].range[1] } } };
  896. break;
  897. case 20:
  898. /*! Production:: css_value : PERCENTAGE */
  899. // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
  900. this._$ = yylstack[yysp];
  901. // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
  902. this.$ = { type: 'PercentageValue', value: parseFloat(yyvstack[yysp]), unit: '%', source: { start: { index: yylstack[yysp].range[0] }, end: { index: yylstack[yysp].range[1] } } };
  903. break;
  904. case 21:
  905. /*! Production:: css_value : UNKNOWN */
  906. // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
  907. this._$ = yylstack[yysp];
  908. // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
  909. this.$ = { type: 'UnknownValue', value: yyvstack[yysp], unit: '', source: { start: { index: yylstack[yysp].range[0] }, end: { index: yylstack[yysp].range[1] } } };
  910. break;
  911. }
  912. },
  913. table: bt({
  914. len: u([
  915. 18,
  916. 1,
  917. 5,
  918. 1,
  919. s,
  920. [17, 3],
  921. s,
  922. [0, 13],
  923. s,
  924. [17, 5],
  925. 0,
  926. 0,
  927. 5,
  928. 6,
  929. 6,
  930. c,
  931. [5, 3],
  932. 0,
  933. 0
  934. ]),
  935. symbol: u([
  936. 3,
  937. 4,
  938. 6,
  939. 7,
  940. s,
  941. [10, 14, 1],
  942. 1,
  943. 1,
  944. s,
  945. [6, 4, 1],
  946. 4,
  947. c,
  948. [25, 13],
  949. c,
  950. [24, 4],
  951. c,
  952. [17, 119],
  953. s,
  954. [5, 5, 1],
  955. 1,
  956. c,
  957. [6, 11],
  958. c,
  959. [5, 5]
  960. ]),
  961. type: u([
  962. s,
  963. [2, 13],
  964. s,
  965. [0, 5],
  966. 1,
  967. s,
  968. [2, 19],
  969. s,
  970. [0, 4],
  971. c,
  972. [17, 132],
  973. s,
  974. [2, 9]
  975. ]),
  976. state: u([
  977. 1,
  978. 2,
  979. 9,
  980. 7,
  981. 8,
  982. 25,
  983. c,
  984. [4, 3],
  985. 26,
  986. c,
  987. [4, 3],
  988. 27,
  989. c,
  990. [4, 3],
  991. 28,
  992. c,
  993. [4, 3],
  994. 29,
  995. c,
  996. [4, 3],
  997. 30,
  998. c,
  999. [4, 3],
  1000. 31,
  1001. c,
  1002. [4, 3],
  1003. 32,
  1004. c,
  1005. [4, 3]
  1006. ]),
  1007. mode: u([
  1008. s,
  1009. [1, 128],
  1010. s,
  1011. [2, 4],
  1012. c,
  1013. [6, 8],
  1014. s,
  1015. [1, 5]
  1016. ]),
  1017. goto: u([
  1018. 3,
  1019. 6,
  1020. 5,
  1021. 4,
  1022. 18,
  1023. s,
  1024. [10, 8, 1],
  1025. s,
  1026. [19, 6, 1],
  1027. c,
  1028. [19, 13],
  1029. c,
  1030. [13, 91],
  1031. 33,
  1032. c,
  1033. [110, 4],
  1034. s,
  1035. [3, 4],
  1036. 22,
  1037. 23,
  1038. s,
  1039. [4, 4],
  1040. 22,
  1041. 23,
  1042. 34,
  1043. c,
  1044. [17, 4]
  1045. ])
  1046. }),
  1047. defaultActions: bda({
  1048. idx: u([
  1049. s,
  1050. [7, 13, 1],
  1051. 25,
  1052. 26,
  1053. 30,
  1054. 31,
  1055. 33,
  1056. 34
  1057. ]),
  1058. goto: u([
  1059. 10,
  1060. 11,
  1061. 12,
  1062. s,
  1063. [14, 8, 1],
  1064. 13,
  1065. 1,
  1066. 7,
  1067. 8,
  1068. 5,
  1069. 6,
  1070. 9,
  1071. 2
  1072. ])
  1073. }),
  1074. parseError: function parseError(str, hash, ExceptionClass) {
  1075. if (hash.recoverable) {
  1076. if (typeof this.trace === 'function') {
  1077. this.trace(str);
  1078. }
  1079. hash.destroy(); // destroy... well, *almost*!
  1080. } else {
  1081. if (typeof this.trace === 'function') {
  1082. this.trace(str);
  1083. }
  1084. if (!ExceptionClass) {
  1085. ExceptionClass = this.JisonParserError;
  1086. }
  1087. throw new ExceptionClass(str, hash);
  1088. }
  1089. },
  1090. parse: function parse(input) {
  1091. var self = this;
  1092. var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage)
  1093. var sstack = new Array(128); // state stack: stores states (column storage)
  1094. var vstack = new Array(128); // semantic value stack
  1095. var lstack = new Array(128); // location stack
  1096. var table = this.table;
  1097. var sp = 0; // 'stack pointer': index into the stacks
  1098. var yyloc;
  1099. var symbol = 0;
  1100. var TERROR = this.TERROR;
  1101. var EOF = this.EOF;
  1102. var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3;
  1103. var NO_ACTION = [0, 35 /* === table.length :: ensures that anyone using this new state will fail dramatically! */];
  1104. var lexer;
  1105. if (this.__lexer__) {
  1106. lexer = this.__lexer__;
  1107. } else {
  1108. lexer = this.__lexer__ = Object.create(this.lexer);
  1109. }
  1110. var sharedState_yy = {
  1111. parseError: undefined,
  1112. quoteName: undefined,
  1113. lexer: undefined,
  1114. parser: undefined,
  1115. pre_parse: undefined,
  1116. post_parse: undefined,
  1117. pre_lex: undefined,
  1118. post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes!
  1119. };
  1120. var ASSERT;
  1121. if (typeof assert !== 'function') {
  1122. ASSERT = function JisonAssert(cond, msg) {
  1123. if (!cond) {
  1124. throw new Error('assertion failed: ' + (msg || '***'));
  1125. }
  1126. };
  1127. } else {
  1128. ASSERT = assert;
  1129. }
  1130. this.yyGetSharedState = function yyGetSharedState() {
  1131. return sharedState_yy;
  1132. };
  1133. // shallow clone objects, straight copy of simple `src` values
  1134. // e.g. `lexer.yytext` MAY be a complex value object,
  1135. // rather than a simple string/value.
  1136. function shallow_copy(src) {
  1137. if (typeof src === 'object') {
  1138. var dst = {};
  1139. for (var k in src) {
  1140. if (Object.prototype.hasOwnProperty.call(src, k)) {
  1141. dst[k] = src[k];
  1142. }
  1143. }
  1144. return dst;
  1145. }
  1146. return src;
  1147. }
  1148. function shallow_copy_noclobber(dst, src) {
  1149. for (var k in src) {
  1150. if (typeof dst[k] === 'undefined' && Object.prototype.hasOwnProperty.call(src, k)) {
  1151. dst[k] = src[k];
  1152. }
  1153. }
  1154. }
  1155. function copy_yylloc(loc) {
  1156. var rv = shallow_copy(loc);
  1157. if (rv && rv.range) {
  1158. rv.range = rv.range.slice(0);
  1159. }
  1160. return rv;
  1161. }
  1162. // copy state
  1163. shallow_copy_noclobber(sharedState_yy, this.yy);
  1164. sharedState_yy.lexer = lexer;
  1165. sharedState_yy.parser = this;
  1166. // Does the shared state override the default `parseError` that already comes with this instance?
  1167. if (typeof sharedState_yy.parseError === 'function') {
  1168. this.parseError = function parseErrorAlt(str, hash, ExceptionClass) {
  1169. if (!ExceptionClass) {
  1170. ExceptionClass = this.JisonParserError;
  1171. }
  1172. return sharedState_yy.parseError.call(this, str, hash, ExceptionClass);
  1173. };
  1174. } else {
  1175. this.parseError = this.originalParseError;
  1176. }
  1177. // Does the shared state override the default `quoteName` that already comes with this instance?
  1178. if (typeof sharedState_yy.quoteName === 'function') {
  1179. this.quoteName = function quoteNameAlt(id_str) {
  1180. return sharedState_yy.quoteName.call(this, id_str);
  1181. };
  1182. } else {
  1183. this.quoteName = this.originalQuoteName;
  1184. }
  1185. // set up the cleanup function; make it an API so that external code can re-use this one in case of
  1186. // calamities or when the `%options no-try-catch` option has been specified for the grammar, in which
  1187. // case this parse() API method doesn't come with a `finally { ... }` block any more!
  1188. //
  1189. // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,
  1190. // or else your `sharedState`, etc. references will be *wrong*!
  1191. this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) {
  1192. var rv;
  1193. if (invoke_post_methods) {
  1194. var hash;
  1195. if (sharedState_yy.post_parse || this.post_parse) {
  1196. // create an error hash info instance: we re-use this API in a **non-error situation**
  1197. // as this one delivers all parser internals ready for access by userland code.
  1198. hash = this.constructParseErrorInfo(null /* no error! */, null /* no exception! */, null, false);
  1199. }
  1200. if (sharedState_yy.post_parse) {
  1201. rv = sharedState_yy.post_parse.call(this, sharedState_yy, resultValue, hash);
  1202. if (typeof rv !== 'undefined') resultValue = rv;
  1203. }
  1204. if (this.post_parse) {
  1205. rv = this.post_parse.call(this, sharedState_yy, resultValue, hash);
  1206. if (typeof rv !== 'undefined') resultValue = rv;
  1207. }
  1208. // cleanup:
  1209. if (hash && hash.destroy) {
  1210. hash.destroy();
  1211. }
  1212. }
  1213. if (this.__reentrant_call_depth > 1) return resultValue; // do not (yet) kill the sharedState when this is a reentrant run.
  1214. // clean up the lingering lexer structures as well:
  1215. if (lexer.cleanupAfterLex) {
  1216. lexer.cleanupAfterLex(do_not_nuke_errorinfos);
  1217. }
  1218. // prevent lingering circular references from causing memory leaks:
  1219. if (sharedState_yy) {
  1220. sharedState_yy.lexer = undefined;
  1221. sharedState_yy.parser = undefined;
  1222. if (lexer.yy === sharedState_yy) {
  1223. lexer.yy = undefined;
  1224. }
  1225. }
  1226. sharedState_yy = undefined;
  1227. this.parseError = this.originalParseError;
  1228. this.quoteName = this.originalQuoteName;
  1229. // nuke the vstack[] array at least as that one will still reference obsoleted user values.
  1230. // To be safe, we nuke the other internal stack columns as well...
  1231. stack.length = 0; // fastest way to nuke an array without overly bothering the GC
  1232. sstack.length = 0;
  1233. lstack.length = 0;
  1234. vstack.length = 0;
  1235. sp = 0;
  1236. // nuke the error hash info instances created during this run.
  1237. // Userland code must COPY any data/references
  1238. // in the error hash instance(s) it is more permanently interested in.
  1239. if (!do_not_nuke_errorinfos) {
  1240. for (var i = this.__error_infos.length - 1; i >= 0; i--) {
  1241. var el = this.__error_infos[i];
  1242. if (el && typeof el.destroy === 'function') {
  1243. el.destroy();
  1244. }
  1245. }
  1246. this.__error_infos.length = 0;
  1247. }
  1248. return resultValue;
  1249. };
  1250. // merge yylloc info into a new yylloc instance.
  1251. //
  1252. // `first_index` and `last_index` MAY be UNDEFINED/NULL or these are indexes into the `lstack[]` location stack array.
  1253. //
  1254. // `first_yylloc` and `last_yylloc` MAY be UNDEFINED/NULL or explicit (custom or regular) `yylloc` instances, in which
  1255. // case these override the corresponding first/last indexes.
  1256. //
  1257. // `dont_look_back` is an optional flag (default: FALSE), which instructs this merge operation NOT to search
  1258. // through the parse location stack for a location, which would otherwise be used to construct the new (epsilon!)
  1259. // yylloc info.
  1260. //
  1261. // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL.
  1262. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) {
  1263. var i1 = first_index | 0,
  1264. i2 = last_index | 0;
  1265. var l1 = first_yylloc,
  1266. l2 = last_yylloc;
  1267. var rv;
  1268. // rules:
  1269. // - first/last yylloc entries override first/last indexes
  1270. if (!l1) {
  1271. if (first_index != null) {
  1272. for (var i = i1; i <= i2; i++) {
  1273. l1 = lstack[i];
  1274. if (l1) {
  1275. break;
  1276. }
  1277. }
  1278. }
  1279. }
  1280. if (!l2) {
  1281. if (last_index != null) {
  1282. for (var i = i2; i >= i1; i--) {
  1283. l2 = lstack[i];
  1284. if (l2) {
  1285. break;
  1286. }
  1287. }
  1288. }
  1289. }
  1290. // - detect if an epsilon rule is being processed and act accordingly:
  1291. if (!l1 && first_index == null) {
  1292. // epsilon rule span merger. With optional look-ahead in l2.
  1293. if (!dont_look_back) {
  1294. for (var i = (i1 || sp) - 1; i >= 0; i--) {
  1295. l1 = lstack[i];
  1296. if (l1) {
  1297. break;
  1298. }
  1299. }
  1300. }
  1301. if (!l1) {
  1302. if (!l2) {
  1303. // when we still don't have any valid yylloc info, we're looking at an epsilon rule
  1304. // without look-ahead and no preceding terms and/or `dont_look_back` set:
  1305. // in that case we ca do nothing but return NULL/UNDEFINED:
  1306. return undefined;
  1307. } else {
  1308. // shallow-copy L2: after all, we MAY be looking
  1309. // at unconventional yylloc info objects...
  1310. rv = shallow_copy(l2);
  1311. if (rv.range) {
  1312. // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries:
  1313. rv.range = rv.range.slice(0);
  1314. }
  1315. return rv;
  1316. }
  1317. } else {
  1318. // shallow-copy L1, then adjust first col/row 1 column past the end.
  1319. rv = shallow_copy(l1);
  1320. rv.first_line = rv.last_line;
  1321. rv.first_column = rv.last_column;
  1322. if (rv.range) {
  1323. // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries:
  1324. rv.range = rv.range.slice(0);
  1325. rv.range[0] = rv.range[1];
  1326. }
  1327. if (l2) {
  1328. // shallow-mixin L2, then adjust last col/row accordingly.
  1329. shallow_copy_noclobber(rv, l2);
  1330. rv.last_line = l2.last_line;
  1331. rv.last_column = l2.last_column;
  1332. if (rv.range && l2.range) {
  1333. rv.range[1] = l2.range[1];
  1334. }
  1335. }
  1336. return rv;
  1337. }
  1338. }
  1339. if (!l1) {
  1340. l1 = l2;
  1341. l2 = null;
  1342. }
  1343. if (!l1) {
  1344. return undefined;
  1345. }
  1346. // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking
  1347. // at unconventional yylloc info objects...
  1348. rv = shallow_copy(l1);
  1349. // first_line: ...,
  1350. // first_column: ...,
  1351. // last_line: ...,
  1352. // last_column: ...,
  1353. if (rv.range) {
  1354. // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries:
  1355. rv.range = rv.range.slice(0);
  1356. }
  1357. if (l2) {
  1358. shallow_copy_noclobber(rv, l2);
  1359. rv.last_line = l2.last_line;
  1360. rv.last_column = l2.last_column;
  1361. if (rv.range && l2.range) {
  1362. rv.range[1] = l2.range[1];
  1363. }
  1364. }
  1365. return rv;
  1366. };
  1367. // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,
  1368. // or else your `lexer`, `sharedState`, etc. references will be *wrong*!
  1369. this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) {
  1370. var pei = {
  1371. errStr: msg,
  1372. exception: ex,
  1373. text: lexer.match,
  1374. value: lexer.yytext,
  1375. token: this.describeSymbol(symbol) || symbol,
  1376. token_id: symbol,
  1377. line: lexer.yylineno,
  1378. loc: copy_yylloc(lexer.yylloc),
  1379. expected: expected,
  1380. recoverable: recoverable,
  1381. state: state,
  1382. action: action,
  1383. new_state: newState,
  1384. symbol_stack: stack,
  1385. state_stack: sstack,
  1386. value_stack: vstack,
  1387. location_stack: lstack,
  1388. stack_pointer: sp,
  1389. yy: sharedState_yy,
  1390. lexer: lexer,
  1391. parser: this,
  1392. // and make sure the error info doesn't stay due to potential
  1393. // ref cycle via userland code manipulations.
  1394. // These would otherwise all be memory leak opportunities!
  1395. //
  1396. // Note that only array and object references are nuked as those
  1397. // constitute the set of elements which can produce a cyclic ref.
  1398. // The rest of the members is kept intact as they are harmless.
  1399. destroy: function destructParseErrorInfo() {
  1400. // remove cyclic references added to error info:
  1401. // info.yy = null;
  1402. // info.lexer = null;
  1403. // info.value = null;
  1404. // info.value_stack = null;
  1405. // ...
  1406. var rec = !!this.recoverable;
  1407. for (var key in this) {
  1408. if (this.hasOwnProperty(key) && typeof key === 'object') {
  1409. this[key] = undefined;
  1410. }
  1411. }
  1412. this.recoverable = rec;
  1413. }
  1414. };
  1415. // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!
  1416. this.__error_infos.push(pei);
  1417. return pei;
  1418. };
  1419. function getNonTerminalFromCode(symbol) {
  1420. var tokenName = self.getSymbolName(symbol);
  1421. if (!tokenName) {
  1422. tokenName = symbol;
  1423. }
  1424. return tokenName;
  1425. }
  1426. function stdLex() {
  1427. var token = lexer.lex();
  1428. // if token isn't its numeric value, convert
  1429. if (typeof token !== 'number') {
  1430. token = self.symbols_[token] || token;
  1431. }
  1432. return token || EOF;
  1433. }
  1434. function fastLex() {
  1435. var token = lexer.fastLex();
  1436. // if token isn't its numeric value, convert
  1437. if (typeof token !== 'number') {
  1438. token = self.symbols_[token] || token;
  1439. }
  1440. return token || EOF;
  1441. }
  1442. var lex = stdLex;
  1443. var state, action, r, t;
  1444. var yyval = {
  1445. $: true,
  1446. _$: undefined,
  1447. yy: sharedState_yy
  1448. };
  1449. var p;
  1450. var yyrulelen;
  1451. var this_production;
  1452. var newState;
  1453. var retval = false;
  1454. try {
  1455. this.__reentrant_call_depth++;
  1456. lexer.setInput(input, sharedState_yy);
  1457. // NOTE: we *assume* no lexer pre/post handlers are set up *after*
  1458. // this initial `setInput()` call: hence we can now check and decide
  1459. // whether we'll go with the standard, slower, lex() API or the
  1460. // `fast_lex()` one:
  1461. if (typeof lexer.canIUse === 'function') {
  1462. var lexerInfo = lexer.canIUse();
  1463. if (lexerInfo.fastLex && typeof fastLex === 'function') {
  1464. lex = fastLex;
  1465. }
  1466. }
  1467. yyloc = lexer.yylloc;
  1468. lstack[sp] = yyloc;
  1469. vstack[sp] = null;
  1470. sstack[sp] = 0;
  1471. stack[sp] = 0;
  1472. ++sp;
  1473. if (this.pre_parse) {
  1474. this.pre_parse.call(this, sharedState_yy);
  1475. }
  1476. if (sharedState_yy.pre_parse) {
  1477. sharedState_yy.pre_parse.call(this, sharedState_yy);
  1478. }
  1479. newState = sstack[sp - 1];
  1480. for (;;) {
  1481. // retrieve state number from top of stack
  1482. state = newState; // sstack[sp - 1];
  1483. // use default actions if available
  1484. if (this.defaultActions[state]) {
  1485. action = 2;
  1486. newState = this.defaultActions[state];
  1487. } else {
  1488. // The single `==` condition below covers both these `===` comparisons in a single
  1489. // operation:
  1490. //
  1491. // if (symbol === null || typeof symbol === 'undefined') ...
  1492. if (!symbol) {
  1493. symbol = lex();
  1494. }
  1495. // read action for current state and first input
  1496. t = (table[state] && table[state][symbol]) || NO_ACTION;
  1497. newState = t[1];
  1498. action = t[0];
  1499. // handle parse error
  1500. if (!action) {
  1501. var errStr;
  1502. var errSymbolDescr = (this.describeSymbol(symbol) || symbol);
  1503. var expected = this.collect_expected_token_set(state);
  1504. // Report error
  1505. if (typeof lexer.yylineno === 'number') {
  1506. errStr = 'Parse error on line ' + (lexer.yylineno + 1) + ': ';
  1507. } else {
  1508. errStr = 'Parse error: ';
  1509. }
  1510. if (typeof lexer.showPosition === 'function') {
  1511. errStr += '\n' + lexer.showPosition(79 - 10, 10) + '\n';
  1512. }
  1513. if (expected.length) {
  1514. errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;
  1515. } else {
  1516. errStr += 'Unexpected ' + errSymbolDescr;
  1517. }
  1518. // we cannot recover from the error!
  1519. p = this.constructParseErrorInfo(errStr, null, expected, false);
  1520. r = this.parseError(p.errStr, p, this.JisonParserError);
  1521. if (typeof r !== 'undefined') {
  1522. retval = r;
  1523. }
  1524. break;
  1525. }
  1526. }
  1527. switch (action) {
  1528. // catch misc. parse failures:
  1529. default:
  1530. // this shouldn't happen, unless resolve defaults are off
  1531. if (action instanceof Array) {
  1532. p = this.constructParseErrorInfo('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol, null, null, false);
  1533. r = this.parseError(p.errStr, p, this.JisonParserError);
  1534. if (typeof r !== 'undefined') {
  1535. retval = r;
  1536. }
  1537. break;
  1538. }
  1539. // Another case of better safe than sorry: in case state transitions come out of another error recovery process
  1540. // or a buggy LUT (LookUp Table):
  1541. p = this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.', null, null, false);
  1542. r = this.parseError(p.errStr, p, this.JisonParserError);
  1543. if (typeof r !== 'undefined') {
  1544. retval = r;
  1545. }
  1546. break;
  1547. // shift:
  1548. case 1:
  1549. stack[sp] = symbol;
  1550. vstack[sp] = lexer.yytext;
  1551. lstack[sp] = copy_yylloc(lexer.yylloc);
  1552. sstack[sp] = newState; // push state
  1553. ++sp;
  1554. symbol = 0;
  1555. // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:
  1556. yyloc = lexer.yylloc;
  1557. continue;
  1558. // reduce:
  1559. case 2:
  1560. this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...
  1561. yyrulelen = this_production[1];
  1562. r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack);
  1563. if (typeof r !== 'undefined') {
  1564. retval = r;
  1565. break;
  1566. }
  1567. // pop off stack
  1568. sp -= yyrulelen;
  1569. // don't overwrite the `symbol` variable: use a local var to speed things up:
  1570. var ntsymbol = this_production[0]; // push nonterminal (reduce)
  1571. stack[sp] = ntsymbol;
  1572. vstack[sp] = yyval.$;
  1573. lstack[sp] = yyval._$;
  1574. // goto new state = table[STATE][NONTERMINAL]
  1575. newState = table[sstack[sp - 1]][ntsymbol];
  1576. sstack[sp] = newState;
  1577. ++sp;
  1578. continue;
  1579. // accept:
  1580. case 3:
  1581. if (sp !== -2) {
  1582. retval = true;
  1583. // Return the `$accept` rule's `$$` result, if available.
  1584. //
  1585. // Also note that JISON always adds this top-most `$accept` rule (with implicit,
  1586. // default, action):
  1587. //
  1588. // $accept: <startSymbol> $end
  1589. // %{ $$ = $1; @$ = @1; %}
  1590. //
  1591. // which, combined with the parse kernel's `$accept` state behaviour coded below,
  1592. // will produce the `$$` value output of the <startSymbol> rule as the parse result,
  1593. // IFF that result is *not* `undefined`. (See also the parser kernel code.)
  1594. //
  1595. // In code:
  1596. //
  1597. // %{
  1598. // @$ = @1; // if location tracking support is included
  1599. // if (typeof $1 !== 'undefined')
  1600. // return $1;
  1601. // else
  1602. // return true; // the default parse result if the rule actions don't produce anything
  1603. // %}
  1604. sp--;
  1605. if (typeof vstack[sp] !== 'undefined') {
  1606. retval = vstack[sp];
  1607. }
  1608. }
  1609. break;
  1610. }
  1611. // break out of loop: we accept or fail with error
  1612. break;
  1613. }
  1614. } catch (ex) {
  1615. // report exceptions through the parseError callback too, but keep the exception intact
  1616. // if it is a known parser or lexer error which has been thrown by parseError() already:
  1617. if (ex instanceof this.JisonParserError) {
  1618. throw ex;
  1619. }
  1620. else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) {
  1621. throw ex;
  1622. }
  1623. p = this.constructParseErrorInfo('Parsing aborted due to exception.', ex, null, false);
  1624. retval = false;
  1625. r = this.parseError(p.errStr, p, this.JisonParserError);
  1626. if (typeof r !== 'undefined') {
  1627. retval = r;
  1628. }
  1629. } finally {
  1630. retval = this.cleanupAfterParse(retval, true, true);
  1631. this.__reentrant_call_depth--;
  1632. } // /finally
  1633. return retval;
  1634. }
  1635. };
  1636. parser.originalParseError = parser.parseError;
  1637. parser.originalQuoteName = parser.quoteName;
  1638. /* lexer generated by jison-lex 0.6.1-215 */
  1639. /*
  1640. * Returns a Lexer object of the following structure:
  1641. *
  1642. * Lexer: {
  1643. * yy: {} The so-called "shared state" or rather the *source* of it;
  1644. * the real "shared state" `yy` passed around to
  1645. * the rule actions, etc. is a direct reference!
  1646. *
  1647. * This "shared context" object was passed to the lexer by way of
  1648. * the `lexer.setInput(str, yy)` API before you may use it.
  1649. *
  1650. * This "shared context" object is passed to the lexer action code in `performAction()`
  1651. * so userland code in the lexer actions may communicate with the outside world
  1652. * and/or other lexer rules' actions in more or less complex ways.
  1653. *
  1654. * }
  1655. *
  1656. * Lexer.prototype: {
  1657. * EOF: 1,
  1658. * ERROR: 2,
  1659. *
  1660. * yy: The overall "shared context" object reference.
  1661. *
  1662. * JisonLexerError: function(msg, hash),
  1663. *
  1664. * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),
  1665. *
  1666. * The function parameters and `this` have the following value/meaning:
  1667. * - `this` : reference to the `lexer` instance.
  1668. * `yy_` is an alias for `this` lexer instance reference used internally.
  1669. *
  1670. * - `yy` : a reference to the `yy` "shared state" object which was passed to the lexer
  1671. * by way of the `lexer.setInput(str, yy)` API before.
  1672. *
  1673. * Note:
  1674. * The extra arguments you specified in the `%parse-param` statement in your
  1675. * **parser** grammar definition file are passed to the lexer via this object
  1676. * reference as member variables.
  1677. *
  1678. * - `yyrulenumber` : index of the matched lexer rule (regex), used internally.
  1679. *
  1680. * - `YY_START`: the current lexer "start condition" state.
  1681. *
  1682. * parseError: function(str, hash, ExceptionClass),
  1683. *
  1684. * constructLexErrorInfo: function(error_message, is_recoverable),
  1685. * Helper function.
  1686. * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.
  1687. * See it's use in this lexer kernel in many places; example usage:
  1688. *
  1689. * var infoObj = lexer.constructParseErrorInfo('fail!', true);
  1690. * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);
  1691. *
  1692. * options: { ... lexer %options ... },
  1693. *
  1694. * lex: function(),
  1695. * Produce one token of lexed input, which was passed in earlier via the `lexer.setInput()` API.
  1696. * You MAY use the additional `args...` parameters as per `%parse-param` spec of the **lexer** grammar:
  1697. * these extra `args...` are added verbatim to the `yy` object reference as member variables.
  1698. *
  1699. * WARNING:
  1700. * Lexer's additional `args...` parameters (via lexer's `%parse-param`) MAY conflict with
  1701. * any attributes already added to `yy` by the **parser** or the jison run-time;
  1702. * when such a collision is detected an exception is thrown to prevent the generated run-time
  1703. * from silently accepting this confusing and potentially hazardous situation!
  1704. *
  1705. * cleanupAfterLex: function(do_not_nuke_errorinfos),
  1706. * Helper function.
  1707. *
  1708. * This helper API is invoked when the **parse process** has completed: it is the responsibility
  1709. * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.
  1710. *
  1711. * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.
  1712. *
  1713. * setInput: function(input, [yy]),
  1714. *
  1715. *
  1716. * input: function(),
  1717. *
  1718. *
  1719. * unput: function(str),
  1720. *
  1721. *
  1722. * more: function(),
  1723. *
  1724. *
  1725. * reject: function(),
  1726. *
  1727. *
  1728. * less: function(n),
  1729. *
  1730. *
  1731. * pastInput: function(n),
  1732. *
  1733. *
  1734. * upcomingInput: function(n),
  1735. *
  1736. *
  1737. * showPosition: function(),
  1738. *
  1739. *
  1740. * test_match: function(regex_match_array, rule_index),
  1741. *
  1742. *
  1743. * next: function(),
  1744. *
  1745. *
  1746. * begin: function(condition),
  1747. *
  1748. *
  1749. * pushState: function(condition),
  1750. *
  1751. *
  1752. * popState: function(),
  1753. *
  1754. *
  1755. * topState: function(),
  1756. *
  1757. *
  1758. * _currentRules: function(),
  1759. *
  1760. *
  1761. * stateStackSize: function(),
  1762. *
  1763. *
  1764. * performAction: function(yy, yy_, yyrulenumber, YY_START),
  1765. *
  1766. *
  1767. * rules: [...],
  1768. *
  1769. *
  1770. * conditions: {associative list: name ==> set},
  1771. * }
  1772. *
  1773. *
  1774. * token location info (`yylloc`): {
  1775. * first_line: n,
  1776. * last_line: n,
  1777. * first_column: n,
  1778. * last_column: n,
  1779. * range: [start_number, end_number]
  1780. * (where the numbers are indexes into the input string, zero-based)
  1781. * }
  1782. *
  1783. * ---
  1784. *
  1785. * The `parseError` function receives a 'hash' object with these members for lexer errors:
  1786. *
  1787. * {
  1788. * text: (matched text)
  1789. * token: (the produced terminal token, if any)
  1790. * token_id: (the produced terminal token numeric ID, if any)
  1791. * line: (yylineno)
  1792. * loc: (yylloc)
  1793. * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule
  1794. * available for this particular error)
  1795. * yy: (object: the current parser internal "shared state" `yy`
  1796. * as is also available in the rule actions; this can be used,
  1797. * for instance, for advanced error analysis and reporting)
  1798. * lexer: (reference to the current lexer instance used by the parser)
  1799. * }
  1800. *
  1801. * while `this` will reference the current lexer instance.
  1802. *
  1803. * When `parseError` is invoked by the lexer, the default implementation will
  1804. * attempt to invoke `yy.parser.parseError()`; when this callback is not provided
  1805. * it will try to invoke `yy.parseError()` instead. When that callback is also not
  1806. * provided, a `JisonLexerError` exception will be thrown containing the error
  1807. * message and `hash`, as constructed by the `constructLexErrorInfo()` API.
  1808. *
  1809. * Note that the lexer's `JisonLexerError` error class is passed via the
  1810. * `ExceptionClass` argument, which is invoked to construct the exception
  1811. * instance to be thrown, so technically `parseError` will throw the object
  1812. * produced by the `new ExceptionClass(str, hash)` JavaScript expression.
  1813. *
  1814. * ---
  1815. *
  1816. * You can specify lexer options by setting / modifying the `.options` object of your Lexer instance.
  1817. * These options are available:
  1818. *
  1819. * (Options are permanent.)
  1820. *
  1821. * yy: {
  1822. * parseError: function(str, hash, ExceptionClass)
  1823. * optional: overrides the default `parseError` function.
  1824. * }
  1825. *
  1826. * lexer.options: {
  1827. * pre_lex: function()
  1828. * optional: is invoked before the lexer is invoked to produce another token.
  1829. * `this` refers to the Lexer object.
  1830. * post_lex: function(token) { return token; }
  1831. * optional: is invoked when the lexer has produced a token `token`;
  1832. * this function can override the returned token value by returning another.
  1833. * When it does not return any (truthy) value, the lexer will return
  1834. * the original `token`.
  1835. * `this` refers to the Lexer object.
  1836. *
  1837. * WARNING: the next set of options are not meant to be changed. They echo the abilities of
  1838. * the lexer as per when it was compiled!
  1839. *
  1840. * ranges: boolean
  1841. * optional: `true` ==> token location info will include a .range[] member.
  1842. * flex: boolean
  1843. * optional: `true` ==> flex-like lexing behaviour where the rules are tested
  1844. * exhaustively to find the longest match.
  1845. * backtrack_lexer: boolean
  1846. * optional: `true` ==> lexer regexes are tested in order and for invoked;
  1847. * the lexer terminates the scan when a token is returned by the action code.
  1848. * xregexp: boolean
  1849. * optional: `true` ==> lexer rule regexes are "extended regex format" requiring the
  1850. * `XRegExp` library. When this %option has not been specified at compile time, all lexer
  1851. * rule regexes have been written as standard JavaScript RegExp expressions.
  1852. * }
  1853. */
  1854. var lexer = function() {
  1855. /**
  1856. * See also:
  1857. * http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508
  1858. * but we keep the prototype.constructor and prototype.name assignment lines too for compatibility
  1859. * with userland code which might access the derived class in a 'classic' way.
  1860. *
  1861. * @public
  1862. * @constructor
  1863. * @nocollapse
  1864. */
  1865. function JisonLexerError(msg, hash) {
  1866. Object.defineProperty(this, 'name', {
  1867. enumerable: false,
  1868. writable: false,
  1869. value: 'JisonLexerError'
  1870. });
  1871. if (msg == null)
  1872. msg = '???';
  1873. Object.defineProperty(this, 'message', {
  1874. enumerable: false,
  1875. writable: true,
  1876. value: msg
  1877. });
  1878. this.hash = hash;
  1879. var stacktrace;
  1880. if (hash && hash.exception instanceof Error) {
  1881. var ex2 = hash.exception;
  1882. this.message = ex2.message || msg;
  1883. stacktrace = ex2.stack;
  1884. }
  1885. if (!stacktrace) {
  1886. if (Error.hasOwnProperty('captureStackTrace')) {
  1887. // V8
  1888. Error.captureStackTrace(this, this.constructor);
  1889. } else {
  1890. stacktrace = new Error(msg).stack;
  1891. }
  1892. }
  1893. if (stacktrace) {
  1894. Object.defineProperty(this, 'stack', {
  1895. enumerable: false,
  1896. writable: false,
  1897. value: stacktrace
  1898. });
  1899. }
  1900. }
  1901. if (typeof Object.setPrototypeOf === 'function') {
  1902. Object.setPrototypeOf(JisonLexerError.prototype, Error.prototype);
  1903. } else {
  1904. JisonLexerError.prototype = Object.create(Error.prototype);
  1905. }
  1906. JisonLexerError.prototype.constructor = JisonLexerError;
  1907. JisonLexerError.prototype.name = 'JisonLexerError';
  1908. var lexer = {
  1909. // Code Generator Information Report
  1910. // ---------------------------------
  1911. //
  1912. // Options:
  1913. //
  1914. // backtracking: .................... false
  1915. // location.ranges: ................. false
  1916. // location line+column tracking: ... true
  1917. //
  1918. //
  1919. // Forwarded Parser Analysis flags:
  1920. //
  1921. // uses yyleng: ..................... false
  1922. // uses yylineno: ................... false
  1923. // uses yytext: ..................... false
  1924. // uses yylloc: ..................... false
  1925. // uses lexer values: ............... true / true
  1926. // location tracking: ............... true
  1927. // location assignment: ............. true
  1928. //
  1929. //
  1930. // Lexer Analysis flags:
  1931. //
  1932. // uses yyleng: ..................... ???
  1933. // uses yylineno: ................... ???
  1934. // uses yytext: ..................... ???
  1935. // uses yylloc: ..................... ???
  1936. // uses ParseError API: ............. ???
  1937. // uses yyerror: .................... ???
  1938. // uses location tracking & editing: ???
  1939. // uses more() API: ................. ???
  1940. // uses unput() API: ................ ???
  1941. // uses reject() API: ............... ???
  1942. // uses less() API: ................. ???
  1943. // uses display APIs pastInput(), upcomingInput(), showPosition():
  1944. // ............................. ???
  1945. // uses describeYYLLOC() API: ....... ???
  1946. //
  1947. // --------- END OF REPORT -----------
  1948. EOF: 1,
  1949. ERROR: 2,
  1950. // JisonLexerError: JisonLexerError, /// <-- injected by the code generator
  1951. // options: {}, /// <-- injected by the code generator
  1952. // yy: ..., /// <-- injected by setInput()
  1953. __currentRuleSet__: null, /// INTERNAL USE ONLY: internal rule set cache for the current lexer state
  1954. __error_infos: [], /// INTERNAL USE ONLY: the set of lexErrorInfo objects created since the last cleanup
  1955. __decompressed: false, /// INTERNAL USE ONLY: mark whether the lexer instance has been 'unfolded' completely and is now ready for use
  1956. done: false, /// INTERNAL USE ONLY
  1957. _backtrack: false, /// INTERNAL USE ONLY
  1958. _input: '', /// INTERNAL USE ONLY
  1959. _more: false, /// INTERNAL USE ONLY
  1960. _signaled_error_token: false, /// INTERNAL USE ONLY
  1961. conditionStack: [], /// INTERNAL USE ONLY; managed via `pushState()`, `popState()`, `topState()` and `stateStackSize()`
  1962. match: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction. `match` is identical to `yytext` except that this one still contains the matched input string after `lexer.performAction()` has been invoked, where userland code MAY have changed/replaced the `yytext` value entirely!
  1963. matched: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks entire input which has been matched so far
  1964. matches: false, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks RE match result for last (successful) match attempt
  1965. yytext: '', /// ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction; this value is transferred to the parser as the 'token value' when the parser consumes the lexer token produced through a call to the `lex()` API.
  1966. offset: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks the 'cursor position' in the input string, i.e. the number of characters matched so far
  1967. yyleng: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: length of matched input for the token under construction (`yytext`)
  1968. yylineno: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: 'line number' at which the token under construction is located
  1969. yylloc: null, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks location info (lines + columns) for the token under construction
  1970. /**
  1971. * INTERNAL USE: construct a suitable error info hash object instance for `parseError`.
  1972. *
  1973. * @public
  1974. * @this {RegExpLexer}
  1975. */
  1976. constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) {
  1977. msg = '' + msg;
  1978. // heuristic to determine if the error message already contains a (partial) source code dump
  1979. // as produced by either `showPosition()` or `prettyPrintRange()`:
  1980. if (show_input_position == undefined) {
  1981. show_input_position = !(msg.indexOf('\n') > 0 && msg.indexOf('^') > 0);
  1982. }
  1983. if (this.yylloc && show_input_position) {
  1984. if (typeof this.prettyPrintRange === 'function') {
  1985. var pretty_src = this.prettyPrintRange(this.yylloc);
  1986. if (!/\n\s*$/.test(msg)) {
  1987. msg += '\n';
  1988. }
  1989. msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc);
  1990. } else if (typeof this.showPosition === 'function') {
  1991. var pos_str = this.showPosition();
  1992. if (pos_str) {
  1993. if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') {
  1994. msg += '\n' + pos_str;
  1995. } else {
  1996. msg += pos_str;
  1997. }
  1998. }
  1999. }
  2000. }
  2001. /** @constructor */
  2002. var pei = {
  2003. errStr: msg,
  2004. recoverable: !!recoverable,
  2005. text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'...
  2006. token: null,
  2007. line: this.yylineno,
  2008. loc: this.yylloc,
  2009. yy: this.yy,
  2010. lexer: this,
  2011. /**
  2012. * and make sure the error info doesn't stay due to potential
  2013. * ref cycle via userland code manipulations.
  2014. * These would otherwise all be memory leak opportunities!
  2015. *
  2016. * Note that only array and object references are nuked as those
  2017. * constitute the set of elements which can produce a cyclic ref.
  2018. * The rest of the members is kept intact as they are harmless.
  2019. *
  2020. * @public
  2021. * @this {LexErrorInfo}
  2022. */
  2023. destroy: function destructLexErrorInfo() {
  2024. // remove cyclic references added to error info:
  2025. // info.yy = null;
  2026. // info.lexer = null;
  2027. // ...
  2028. var rec = !!this.recoverable;
  2029. for (var key in this) {
  2030. if (this.hasOwnProperty(key) && typeof key === 'object') {
  2031. this[key] = undefined;
  2032. }
  2033. }
  2034. this.recoverable = rec;
  2035. }
  2036. };
  2037. // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!
  2038. this.__error_infos.push(pei);
  2039. return pei;
  2040. },
  2041. /**
  2042. * handler which is invoked when a lexer error occurs.
  2043. *
  2044. * @public
  2045. * @this {RegExpLexer}
  2046. */
  2047. parseError: function lexer_parseError(str, hash, ExceptionClass) {
  2048. if (!ExceptionClass) {
  2049. ExceptionClass = this.JisonLexerError;
  2050. }
  2051. if (this.yy) {
  2052. if (this.yy.parser && typeof this.yy.parser.parseError === 'function') {
  2053. return this.yy.parser.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;
  2054. } else if (typeof this.yy.parseError === 'function') {
  2055. return this.yy.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;
  2056. }
  2057. }
  2058. throw new ExceptionClass(str, hash);
  2059. },
  2060. /**
  2061. * method which implements `yyerror(str, ...args)` functionality for use inside lexer actions.
  2062. *
  2063. * @public
  2064. * @this {RegExpLexer}
  2065. */
  2066. yyerror: function yyError(str /*, ...args */) {
  2067. var lineno_msg = '';
  2068. if (this.yylloc) {
  2069. lineno_msg = ' on line ' + (this.yylineno + 1);
  2070. }
  2071. var p = this.constructLexErrorInfo(
  2072. 'Lexical error' + lineno_msg + ': ' + str,
  2073. this.options.lexerErrorsAreRecoverable
  2074. );
  2075. // Add any extra args to the hash under the name `extra_error_attributes`:
  2076. var args = Array.prototype.slice.call(arguments, 1);
  2077. if (args.length) {
  2078. p.extra_error_attributes = args;
  2079. }
  2080. return this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR;
  2081. },
  2082. /**
  2083. * final cleanup function for when we have completed lexing the input;
  2084. * make it an API so that external code can use this one once userland
  2085. * code has decided it's time to destroy any lingering lexer error
  2086. * hash object instances and the like: this function helps to clean
  2087. * up these constructs, which *may* carry cyclic references which would
  2088. * otherwise prevent the instances from being properly and timely
  2089. * garbage-collected, i.e. this function helps prevent memory leaks!
  2090. *
  2091. * @public
  2092. * @this {RegExpLexer}
  2093. */
  2094. cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) {
  2095. // prevent lingering circular references from causing memory leaks:
  2096. this.setInput('', {});
  2097. // nuke the error hash info instances created during this run.
  2098. // Userland code must COPY any data/references
  2099. // in the error hash instance(s) it is more permanently interested in.
  2100. if (!do_not_nuke_errorinfos) {
  2101. for (var i = this.__error_infos.length - 1; i >= 0; i--) {
  2102. var el = this.__error_infos[i];
  2103. if (el && typeof el.destroy === 'function') {
  2104. el.destroy();
  2105. }
  2106. }
  2107. this.__error_infos.length = 0;
  2108. }
  2109. return this;
  2110. },
  2111. /**
  2112. * clear the lexer token context; intended for internal use only
  2113. *
  2114. * @public
  2115. * @this {RegExpLexer}
  2116. */
  2117. clear: function lexer_clear() {
  2118. this.yytext = '';
  2119. this.yyleng = 0;
  2120. this.match = '';
  2121. // - DO NOT reset `this.matched`
  2122. this.matches = false;
  2123. this._more = false;
  2124. this._backtrack = false;
  2125. var col = (this.yylloc ? this.yylloc.last_column : 0);
  2126. this.yylloc = {
  2127. first_line: this.yylineno + 1,
  2128. first_column: col,
  2129. last_line: this.yylineno + 1,
  2130. last_column: col,
  2131. range: [this.offset, this.offset]
  2132. };
  2133. },
  2134. /**
  2135. * resets the lexer, sets new input
  2136. *
  2137. * @public
  2138. * @this {RegExpLexer}
  2139. */
  2140. setInput: function lexer_setInput(input, yy) {
  2141. this.yy = yy || this.yy || {};
  2142. // also check if we've fully initialized the lexer instance,
  2143. // including expansion work to be done to go from a loaded
  2144. // lexer to a usable lexer:
  2145. if (!this.__decompressed) {
  2146. // step 1: decompress the regex list:
  2147. var rules = this.rules;
  2148. for (var i = 0, len = rules.length; i < len; i++) {
  2149. var rule_re = rules[i];
  2150. // compression: is the RE an xref to another RE slot in the rules[] table?
  2151. if (typeof rule_re === 'number') {
  2152. rules[i] = rules[rule_re];
  2153. }
  2154. }
  2155. // step 2: unfold the conditions[] set to make these ready for use:
  2156. var conditions = this.conditions;
  2157. for (var k in conditions) {
  2158. var spec = conditions[k];
  2159. var rule_ids = spec.rules;
  2160. var len = rule_ids.length;
  2161. var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple!
  2162. var rule_new_ids = new Array(len + 1);
  2163. for (var i = 0; i < len; i++) {
  2164. var idx = rule_ids[i];
  2165. var rule_re = rules[idx];
  2166. rule_regexes[i + 1] = rule_re;
  2167. rule_new_ids[i + 1] = idx;
  2168. }
  2169. spec.rules = rule_new_ids;
  2170. spec.__rule_regexes = rule_regexes;
  2171. spec.__rule_count = len;
  2172. }
  2173. this.__decompressed = true;
  2174. }
  2175. this._input = input || '';
  2176. this.clear();
  2177. this._signaled_error_token = false;
  2178. this.done = false;
  2179. this.yylineno = 0;
  2180. this.matched = '';
  2181. this.conditionStack = ['INITIAL'];
  2182. this.__currentRuleSet__ = null;
  2183. this.yylloc = {
  2184. first_line: 1,
  2185. first_column: 0,
  2186. last_line: 1,
  2187. last_column: 0,
  2188. range: [0, 0]
  2189. };
  2190. this.offset = 0;
  2191. return this;
  2192. },
  2193. /**
  2194. * edit the remaining input via user-specified callback.
  2195. * This can be used to forward-adjust the input-to-parse,
  2196. * e.g. inserting macro expansions and alike in the
  2197. * input which has yet to be lexed.
  2198. * The behaviour of this API contrasts the `unput()` et al
  2199. * APIs as those act on the *consumed* input, while this
  2200. * one allows one to manipulate the future, without impacting
  2201. * the current `yyloc` cursor location or any history.
  2202. *
  2203. * Use this API to help implement C-preprocessor-like
  2204. * `#include` statements, etc.
  2205. *
  2206. * The provided callback must be synchronous and is
  2207. * expected to return the edited input (string).
  2208. *
  2209. * The `cpsArg` argument value is passed to the callback
  2210. * as-is.
  2211. *
  2212. * `callback` interface:
  2213. * `function callback(input, cpsArg)`
  2214. *
  2215. * - `input` will carry the remaining-input-to-lex string
  2216. * from the lexer.
  2217. * - `cpsArg` is `cpsArg` passed into this API.
  2218. *
  2219. * The `this` reference for the callback will be set to
  2220. * reference this lexer instance so that userland code
  2221. * in the callback can easily and quickly access any lexer
  2222. * API.
  2223. *
  2224. * When the callback returns a non-string-type falsey value,
  2225. * we assume the callback did not edit the input and we
  2226. * will using the input as-is.
  2227. *
  2228. * When the callback returns a non-string-type value, it
  2229. * is converted to a string for lexing via the `"" + retval`
  2230. * operation. (See also why: http://2ality.com/2012/03/converting-to-string.html
  2231. * -- that way any returned object's `toValue()` and `toString()`
  2232. * methods will be invoked in a proper/desirable order.)
  2233. *
  2234. * @public
  2235. * @this {RegExpLexer}
  2236. */
  2237. editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) {
  2238. var rv = callback.call(this, this._input, cpsArg);
  2239. if (typeof rv !== 'string') {
  2240. if (rv) {
  2241. this._input = '' + rv;
  2242. }
  2243. // else: keep `this._input` as is.
  2244. } else {
  2245. this._input = rv;
  2246. }
  2247. return this;
  2248. },
  2249. /**
  2250. * consumes and returns one char from the input
  2251. *
  2252. * @public
  2253. * @this {RegExpLexer}
  2254. */
  2255. input: function lexer_input() {
  2256. if (!this._input) {
  2257. //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <<EOF>> tokens and perform user action code for a <<EOF>> match, but only does so *once*)
  2258. return null;
  2259. }
  2260. var ch = this._input[0];
  2261. this.yytext += ch;
  2262. this.yyleng++;
  2263. this.offset++;
  2264. this.match += ch;
  2265. this.matched += ch;
  2266. // Count the linenumber up when we hit the LF (or a stand-alone CR).
  2267. // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo
  2268. // and we advance immediately past the LF as well, returning both together as if
  2269. // it was all a single 'character' only.
  2270. var slice_len = 1;
  2271. var lines = false;
  2272. if (ch === '\n') {
  2273. lines = true;
  2274. } else if (ch === '\r') {
  2275. lines = true;
  2276. var ch2 = this._input[1];
  2277. if (ch2 === '\n') {
  2278. slice_len++;
  2279. ch += ch2;
  2280. this.yytext += ch2;
  2281. this.yyleng++;
  2282. this.offset++;
  2283. this.match += ch2;
  2284. this.matched += ch2;
  2285. this.yylloc.range[1]++;
  2286. }
  2287. }
  2288. if (lines) {
  2289. this.yylineno++;
  2290. this.yylloc.last_line++;
  2291. this.yylloc.last_column = 0;
  2292. } else {
  2293. this.yylloc.last_column++;
  2294. }
  2295. this.yylloc.range[1]++;
  2296. this._input = this._input.slice(slice_len);
  2297. return ch;
  2298. },
  2299. /**
  2300. * unshifts one char (or an entire string) into the input
  2301. *
  2302. * @public
  2303. * @this {RegExpLexer}
  2304. */
  2305. unput: function lexer_unput(ch) {
  2306. var len = ch.length;
  2307. var lines = ch.split(/(?:\r\n?|\n)/g);
  2308. this._input = ch + this._input;
  2309. this.yytext = this.yytext.substr(0, this.yytext.length - len);
  2310. this.yyleng = this.yytext.length;
  2311. this.offset -= len;
  2312. this.match = this.match.substr(0, this.match.length - len);
  2313. this.matched = this.matched.substr(0, this.matched.length - len);
  2314. if (lines.length > 1) {
  2315. this.yylineno -= lines.length - 1;
  2316. this.yylloc.last_line = this.yylineno + 1;
  2317. // Get last entirely matched line into the `pre_lines[]` array's
  2318. // last index slot; we don't mind when other previously
  2319. // matched lines end up in the array too.
  2320. var pre = this.match;
  2321. var pre_lines = pre.split(/(?:\r\n?|\n)/g);
  2322. if (pre_lines.length === 1) {
  2323. pre = this.matched;
  2324. pre_lines = pre.split(/(?:\r\n?|\n)/g);
  2325. }
  2326. this.yylloc.last_column = pre_lines[pre_lines.length - 1].length;
  2327. } else {
  2328. this.yylloc.last_column -= len;
  2329. }
  2330. this.yylloc.range[1] = this.yylloc.range[0] + this.yyleng;
  2331. this.done = false;
  2332. return this;
  2333. },
  2334. /**
  2335. * cache matched text and append it on next action
  2336. *
  2337. * @public
  2338. * @this {RegExpLexer}
  2339. */
  2340. more: function lexer_more() {
  2341. this._more = true;
  2342. return this;
  2343. },
  2344. /**
  2345. * signal the lexer that this rule fails to match the input, so the
  2346. * next matching rule (regex) should be tested instead.
  2347. *
  2348. * @public
  2349. * @this {RegExpLexer}
  2350. */
  2351. reject: function lexer_reject() {
  2352. if (this.options.backtrack_lexer) {
  2353. this._backtrack = true;
  2354. } else {
  2355. // when the `parseError()` call returns, we MUST ensure that the error is registered.
  2356. // We accomplish this by signaling an 'error' token to be produced for the current
  2357. // `.lex()` run.
  2358. var lineno_msg = '';
  2359. if (this.yylloc) {
  2360. lineno_msg = ' on line ' + (this.yylineno + 1);
  2361. }
  2362. var p = this.constructLexErrorInfo(
  2363. 'Lexical error' + lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',
  2364. false
  2365. );
  2366. this._signaled_error_token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR;
  2367. }
  2368. return this;
  2369. },
  2370. /**
  2371. * retain first n characters of the match
  2372. *
  2373. * @public
  2374. * @this {RegExpLexer}
  2375. */
  2376. less: function lexer_less(n) {
  2377. return this.unput(this.match.slice(n));
  2378. },
  2379. /**
  2380. * return (part of the) already matched input, i.e. for error
  2381. * messages.
  2382. *
  2383. * Limit the returned string length to `maxSize` (default: 20).
  2384. *
  2385. * Limit the returned string to the `maxLines` number of lines of
  2386. * input (default: 1).
  2387. *
  2388. * Negative limit values equal *unlimited*.
  2389. *
  2390. * @public
  2391. * @this {RegExpLexer}
  2392. */
  2393. pastInput: function lexer_pastInput(maxSize, maxLines) {
  2394. var past = this.matched.substring(0, this.matched.length - this.match.length);
  2395. if (maxSize < 0)
  2396. maxSize = past.length;
  2397. else if (!maxSize)
  2398. maxSize = 20;
  2399. if (maxLines < 0)
  2400. maxLines = past.length; // can't ever have more input lines than this!
  2401. else if (!maxLines)
  2402. maxLines = 1;
  2403. // `substr` anticipation: treat \r\n as a single character and take a little
  2404. // more than necessary so that we can still properly check against maxSize
  2405. // after we've transformed and limited the newLines in here:
  2406. past = past.substr(-maxSize * 2 - 2);
  2407. // now that we have a significantly reduced string to process, transform the newlines
  2408. // and chop them, then limit them:
  2409. var a = past.replace(/\r\n|\r/g, '\n').split('\n');
  2410. a = a.slice(-maxLines);
  2411. past = a.join('\n');
  2412. // When, after limiting to maxLines, we still have too much to return,
  2413. // do add an ellipsis prefix...
  2414. if (past.length > maxSize) {
  2415. past = '...' + past.substr(-maxSize);
  2416. }
  2417. return past;
  2418. },
  2419. /**
  2420. * return (part of the) upcoming input, i.e. for error messages.
  2421. *
  2422. * Limit the returned string length to `maxSize` (default: 20).
  2423. *
  2424. * Limit the returned string to the `maxLines` number of lines of input (default: 1).
  2425. *
  2426. * Negative limit values equal *unlimited*.
  2427. *
  2428. * > ### NOTE ###
  2429. * >
  2430. * > *"upcoming input"* is defined as the whole of the both
  2431. * > the *currently lexed* input, together with any remaining input
  2432. * > following that. *"currently lexed"* input is the input
  2433. * > already recognized by the lexer but not yet returned with
  2434. * > the lexer token. This happens when you are invoking this API
  2435. * > from inside any lexer rule action code block.
  2436. * >
  2437. *
  2438. * @public
  2439. * @this {RegExpLexer}
  2440. */
  2441. upcomingInput: function lexer_upcomingInput(maxSize, maxLines) {
  2442. var next = this.match;
  2443. if (maxSize < 0)
  2444. maxSize = next.length + this._input.length;
  2445. else if (!maxSize)
  2446. maxSize = 20;
  2447. if (maxLines < 0)
  2448. maxLines = maxSize; // can't ever have more input lines than this!
  2449. else if (!maxLines)
  2450. maxLines = 1;
  2451. // `substring` anticipation: treat \r\n as a single character and take a little
  2452. // more than necessary so that we can still properly check against maxSize
  2453. // after we've transformed and limited the newLines in here:
  2454. if (next.length < maxSize * 2 + 2) {
  2455. next += this._input.substring(0, maxSize * 2 + 2); // substring is faster on Chrome/V8
  2456. }
  2457. // now that we have a significantly reduced string to process, transform the newlines
  2458. // and chop them, then limit them:
  2459. var a = next.replace(/\r\n|\r/g, '\n').split('\n');
  2460. a = a.slice(0, maxLines);
  2461. next = a.join('\n');
  2462. // When, after limiting to maxLines, we still have too much to return,
  2463. // do add an ellipsis postfix...
  2464. if (next.length > maxSize) {
  2465. next = next.substring(0, maxSize) + '...';
  2466. }
  2467. return next;
  2468. },
  2469. /**
  2470. * return a string which displays the character position where the
  2471. * lexing error occurred, i.e. for error messages
  2472. *
  2473. * @public
  2474. * @this {RegExpLexer}
  2475. */
  2476. showPosition: function lexer_showPosition(maxPrefix, maxPostfix) {
  2477. var pre = this.pastInput(maxPrefix).replace(/\s/g, ' ');
  2478. var c = new Array(pre.length + 1).join('-');
  2479. return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^';
  2480. },
  2481. /**
  2482. * return an YYLLOC info object derived off the given context (actual, preceding, following, current).
  2483. * Use this method when the given `actual` location is not guaranteed to exist (i.e. when
  2484. * it MAY be NULL) and you MUST have a valid location info object anyway:
  2485. * then we take the given context of the `preceding` and `following` locations, IFF those are available,
  2486. * and reconstruct the `actual` location info from those.
  2487. * If this fails, the heuristic is to take the `current` location, IFF available.
  2488. * If this fails as well, we assume the sought location is at/around the current lexer position
  2489. * and then produce that one as a response. DO NOTE that these heuristic/derived location info
  2490. * values MAY be inaccurate!
  2491. *
  2492. * NOTE: `deriveLocationInfo()` ALWAYS produces a location info object *copy* of `actual`, not just
  2493. * a *reference* hence all input location objects can be assumed to be 'constant' (function has no side-effects).
  2494. *
  2495. * @public
  2496. * @this {RegExpLexer}
  2497. */
  2498. deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) {
  2499. var loc = {
  2500. first_line: 1,
  2501. first_column: 0,
  2502. last_line: 1,
  2503. last_column: 0,
  2504. range: [0, 0]
  2505. };
  2506. if (actual) {
  2507. loc.first_line = actual.first_line | 0;
  2508. loc.last_line = actual.last_line | 0;
  2509. loc.first_column = actual.first_column | 0;
  2510. loc.last_column = actual.last_column | 0;
  2511. if (actual.range) {
  2512. loc.range[0] = actual.range[0] | 0;
  2513. loc.range[1] = actual.range[1] | 0;
  2514. }
  2515. }
  2516. if (loc.first_line <= 0 || loc.last_line < loc.first_line) {
  2517. // plan B: heuristic using preceding and following:
  2518. if (loc.first_line <= 0 && preceding) {
  2519. loc.first_line = preceding.last_line | 0;
  2520. loc.first_column = preceding.last_column | 0;
  2521. if (preceding.range) {
  2522. loc.range[0] = actual.range[1] | 0;
  2523. }
  2524. }
  2525. if ((loc.last_line <= 0 || loc.last_line < loc.first_line) && following) {
  2526. loc.last_line = following.first_line | 0;
  2527. loc.last_column = following.first_column | 0;
  2528. if (following.range) {
  2529. loc.range[1] = actual.range[0] | 0;
  2530. }
  2531. }
  2532. // plan C?: see if the 'current' location is useful/sane too:
  2533. if (loc.first_line <= 0 && current && (loc.last_line <= 0 || current.last_line <= loc.last_line)) {
  2534. loc.first_line = current.first_line | 0;
  2535. loc.first_column = current.first_column | 0;
  2536. if (current.range) {
  2537. loc.range[0] = current.range[0] | 0;
  2538. }
  2539. }
  2540. if (loc.last_line <= 0 && current && (loc.first_line <= 0 || current.first_line >= loc.first_line)) {
  2541. loc.last_line = current.last_line | 0;
  2542. loc.last_column = current.last_column | 0;
  2543. if (current.range) {
  2544. loc.range[1] = current.range[1] | 0;
  2545. }
  2546. }
  2547. }
  2548. // sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter
  2549. // or plan D heuristics to produce a 'sensible' last_line value:
  2550. if (loc.last_line <= 0) {
  2551. if (loc.first_line <= 0) {
  2552. loc.first_line = this.yylloc.first_line;
  2553. loc.last_line = this.yylloc.last_line;
  2554. loc.first_column = this.yylloc.first_column;
  2555. loc.last_column = this.yylloc.last_column;
  2556. loc.range[0] = this.yylloc.range[0];
  2557. loc.range[1] = this.yylloc.range[1];
  2558. } else {
  2559. loc.last_line = this.yylloc.last_line;
  2560. loc.last_column = this.yylloc.last_column;
  2561. loc.range[1] = this.yylloc.range[1];
  2562. }
  2563. }
  2564. if (loc.first_line <= 0) {
  2565. loc.first_line = loc.last_line;
  2566. loc.first_column = 0; // loc.last_column;
  2567. loc.range[1] = loc.range[0];
  2568. }
  2569. if (loc.first_column < 0) {
  2570. loc.first_column = 0;
  2571. }
  2572. if (loc.last_column < 0) {
  2573. loc.last_column = (loc.first_column > 0 ? loc.first_column : 80);
  2574. }
  2575. return loc;
  2576. },
  2577. /**
  2578. * return a string which displays the lines & columns of input which are referenced
  2579. * by the given location info range, plus a few lines of context.
  2580. *
  2581. * This function pretty-prints the indicated section of the input, with line numbers
  2582. * and everything!
  2583. *
  2584. * This function is very useful to provide highly readable error reports, while
  2585. * the location range may be specified in various flexible ways:
  2586. *
  2587. * - `loc` is the location info object which references the area which should be
  2588. * displayed and 'marked up': these lines & columns of text are marked up by `^`
  2589. * characters below each character in the entire input range.
  2590. *
  2591. * - `context_loc` is the *optional* location info object which instructs this
  2592. * pretty-printer how much *leading* context should be displayed alongside
  2593. * the area referenced by `loc`. This can help provide context for the displayed
  2594. * error, etc.
  2595. *
  2596. * When this location info is not provided, a default context of 3 lines is
  2597. * used.
  2598. *
  2599. * - `context_loc2` is another *optional* location info object, which serves
  2600. * a similar purpose to `context_loc`: it specifies the amount of *trailing*
  2601. * context lines to display in the pretty-print output.
  2602. *
  2603. * When this location info is not provided, a default context of 1 line only is
  2604. * used.
  2605. *
  2606. * Special Notes:
  2607. *
  2608. * - when the `loc`-indicated range is very large (about 5 lines or more), then
  2609. * only the first and last few lines of this block are printed while a
  2610. * `...continued...` message will be printed between them.
  2611. *
  2612. * This serves the purpose of not printing a huge amount of text when the `loc`
  2613. * range happens to be huge: this way a manageable & readable output results
  2614. * for arbitrary large ranges.
  2615. *
  2616. * - this function can display lines of input which whave not yet been lexed.
  2617. * `prettyPrintRange()` can access the entire input!
  2618. *
  2619. * @public
  2620. * @this {RegExpLexer}
  2621. */
  2622. prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) {
  2623. loc = this.deriveLocationInfo(loc, context_loc, context_loc2);
  2624. const CONTEXT = 3;
  2625. const CONTEXT_TAIL = 1;
  2626. const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2;
  2627. var input = this.matched + this._input;
  2628. var lines = input.split('\n');
  2629. var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT));
  2630. var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL));
  2631. var lineno_display_width = 1 + Math.log10(l1 | 1) | 0;
  2632. var ws_prefix = new Array(lineno_display_width).join(' ');
  2633. var nonempty_line_indexes = [];
  2634. var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) {
  2635. var lno = index + l0;
  2636. var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width);
  2637. var rv = lno_pfx + ': ' + line;
  2638. var errpfx = new Array(lineno_display_width + 1).join('^');
  2639. var offset = 2 + 1;
  2640. var len = 0;
  2641. if (lno === loc.first_line) {
  2642. offset += loc.first_column;
  2643. len = Math.max(
  2644. 2,
  2645. ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1
  2646. );
  2647. } else if (lno === loc.last_line) {
  2648. len = Math.max(2, loc.last_column + 1);
  2649. } else if (lno > loc.first_line && lno < loc.last_line) {
  2650. len = Math.max(2, line.length + 1);
  2651. }
  2652. if (len) {
  2653. var lead = new Array(offset).join('.');
  2654. var mark = new Array(len).join('^');
  2655. rv += '\n' + errpfx + lead + mark;
  2656. if (line.trim().length > 0) {
  2657. nonempty_line_indexes.push(index);
  2658. }
  2659. }
  2660. rv = rv.replace(/\t/g, ' ');
  2661. return rv;
  2662. });
  2663. // now make sure we don't print an overly large amount of error area: limit it
  2664. // to the top and bottom line count:
  2665. if (nonempty_line_indexes.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) {
  2666. var clip_start = nonempty_line_indexes[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1;
  2667. var clip_end = nonempty_line_indexes[nonempty_line_indexes.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1;
  2668. var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)';
  2669. intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)';
  2670. rv.splice(clip_start, clip_end - clip_start + 1, intermediate_line);
  2671. }
  2672. return rv.join('\n');
  2673. },
  2674. /**
  2675. * helper function, used to produce a human readable description as a string, given
  2676. * the input `yylloc` location object.
  2677. *
  2678. * Set `display_range_too` to TRUE to include the string character index position(s)
  2679. * in the description if the `yylloc.range` is available.
  2680. *
  2681. * @public
  2682. * @this {RegExpLexer}
  2683. */
  2684. describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) {
  2685. var l1 = yylloc.first_line;
  2686. var l2 = yylloc.last_line;
  2687. var c1 = yylloc.first_column;
  2688. var c2 = yylloc.last_column;
  2689. var dl = l2 - l1;
  2690. var dc = c2 - c1;
  2691. var rv;
  2692. if (dl === 0) {
  2693. rv = 'line ' + l1 + ', ';
  2694. if (dc <= 1) {
  2695. rv += 'column ' + c1;
  2696. } else {
  2697. rv += 'columns ' + c1 + ' .. ' + c2;
  2698. }
  2699. } else {
  2700. rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')';
  2701. }
  2702. if (yylloc.range && display_range_too) {
  2703. var r1 = yylloc.range[0];
  2704. var r2 = yylloc.range[1] - 1;
  2705. if (r2 <= r1) {
  2706. rv += ' {String Offset: ' + r1 + '}';
  2707. } else {
  2708. rv += ' {String Offset range: ' + r1 + ' .. ' + r2 + '}';
  2709. }
  2710. }
  2711. return rv;
  2712. },
  2713. /**
  2714. * test the lexed token: return FALSE when not a match, otherwise return token.
  2715. *
  2716. * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]`
  2717. * contains the actually matched text string.
  2718. *
  2719. * Also move the input cursor forward and update the match collectors:
  2720. *
  2721. * - `yytext`
  2722. * - `yyleng`
  2723. * - `match`
  2724. * - `matches`
  2725. * - `yylloc`
  2726. * - `offset`
  2727. *
  2728. * @public
  2729. * @this {RegExpLexer}
  2730. */
  2731. test_match: function lexer_test_match(match, indexed_rule) {
  2732. var token, lines, backup, match_str, match_str_len;
  2733. if (this.options.backtrack_lexer) {
  2734. // save context
  2735. backup = {
  2736. yylineno: this.yylineno,
  2737. yylloc: {
  2738. first_line: this.yylloc.first_line,
  2739. last_line: this.yylloc.last_line,
  2740. first_column: this.yylloc.first_column,
  2741. last_column: this.yylloc.last_column,
  2742. range: this.yylloc.range.slice(0)
  2743. },
  2744. yytext: this.yytext,
  2745. match: this.match,
  2746. matches: this.matches,
  2747. matched: this.matched,
  2748. yyleng: this.yyleng,
  2749. offset: this.offset,
  2750. _more: this._more,
  2751. _input: this._input,
  2752. //_signaled_error_token: this._signaled_error_token,
  2753. yy: this.yy,
  2754. conditionStack: this.conditionStack.slice(0),
  2755. done: this.done
  2756. };
  2757. }
  2758. match_str = match[0];
  2759. match_str_len = match_str.length;
  2760. // if (match_str.indexOf('\n') !== -1 || match_str.indexOf('\r') !== -1) {
  2761. lines = match_str.split(/(?:\r\n?|\n)/g);
  2762. if (lines.length > 1) {
  2763. this.yylineno += lines.length - 1;
  2764. this.yylloc.last_line = this.yylineno + 1;
  2765. this.yylloc.last_column = lines[lines.length - 1].length;
  2766. } else {
  2767. this.yylloc.last_column += match_str_len;
  2768. }
  2769. // }
  2770. this.yytext += match_str;
  2771. this.match += match_str;
  2772. this.matched += match_str;
  2773. this.matches = match;
  2774. this.yyleng = this.yytext.length;
  2775. this.yylloc.range[1] += match_str_len;
  2776. // previous lex rules MAY have invoked the `more()` API rather than producing a token:
  2777. // those rules will already have moved this `offset` forward matching their match lengths,
  2778. // hence we must only add our own match length now:
  2779. this.offset += match_str_len;
  2780. this._more = false;
  2781. this._backtrack = false;
  2782. this._input = this._input.slice(match_str_len);
  2783. // calling this method:
  2784. //
  2785. // function lexer__performAction(yy, yyrulenumber, YY_START) {...}
  2786. token = this.performAction.call(
  2787. this,
  2788. this.yy,
  2789. indexed_rule,
  2790. this.conditionStack[this.conditionStack.length - 1] /* = YY_START */
  2791. );
  2792. // otherwise, when the action codes are all simple return token statements:
  2793. //token = this.simpleCaseActionClusters[indexed_rule];
  2794. if (this.done && this._input) {
  2795. this.done = false;
  2796. }
  2797. if (token) {
  2798. return token;
  2799. } else if (this._backtrack) {
  2800. // recover context
  2801. for (var k in backup) {
  2802. this[k] = backup[k];
  2803. }
  2804. this.__currentRuleSet__ = null;
  2805. return false; // rule action called reject() implying the next rule should be tested instead.
  2806. } else if (this._signaled_error_token) {
  2807. // produce one 'error' token as `.parseError()` in `reject()`
  2808. // did not guarantee a failure signal by throwing an exception!
  2809. token = this._signaled_error_token;
  2810. this._signaled_error_token = false;
  2811. return token;
  2812. }
  2813. return false;
  2814. },
  2815. /**
  2816. * return next match in input
  2817. *
  2818. * @public
  2819. * @this {RegExpLexer}
  2820. */
  2821. next: function lexer_next() {
  2822. if (this.done) {
  2823. this.clear();
  2824. return this.EOF;
  2825. }
  2826. if (!this._input) {
  2827. this.done = true;
  2828. }
  2829. var token, match, tempMatch, index;
  2830. if (!this._more) {
  2831. this.clear();
  2832. }
  2833. var spec = this.__currentRuleSet__;
  2834. if (!spec) {
  2835. // Update the ruleset cache as we apparently encountered a state change or just started lexing.
  2836. // The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will
  2837. // invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps
  2838. // speed up those activities a tiny bit.
  2839. spec = this.__currentRuleSet__ = this._currentRules();
  2840. // Check whether a *sane* condition has been pushed before: this makes the lexer robust against
  2841. // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19
  2842. if (!spec || !spec.rules) {
  2843. var lineno_msg = '';
  2844. if (this.options.trackPosition) {
  2845. lineno_msg = ' on line ' + (this.yylineno + 1);
  2846. }
  2847. var p = this.constructLexErrorInfo(
  2848. 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!',
  2849. false
  2850. );
  2851. // produce one 'error' token until this situation has been resolved, most probably by parse termination!
  2852. return this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR;
  2853. }
  2854. }
  2855. var rule_ids = spec.rules;
  2856. var regexes = spec.__rule_regexes;
  2857. var len = spec.__rule_count;
  2858. // Note: the arrays are 1-based, while `len` itself is a valid index,
  2859. // hence the non-standard less-or-equal check in the next loop condition!
  2860. for (var i = 1; i <= len; i++) {
  2861. tempMatch = this._input.match(regexes[i]);
  2862. if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
  2863. match = tempMatch;
  2864. index = i;
  2865. if (this.options.backtrack_lexer) {
  2866. token = this.test_match(tempMatch, rule_ids[i]);
  2867. if (token !== false) {
  2868. return token;
  2869. } else if (this._backtrack) {
  2870. match = undefined;
  2871. continue; // rule action called reject() implying a rule MISmatch.
  2872. } else {
  2873. // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
  2874. return false;
  2875. }
  2876. } else if (!this.options.flex) {
  2877. break;
  2878. }
  2879. }
  2880. }
  2881. if (match) {
  2882. token = this.test_match(match, rule_ids[index]);
  2883. if (token !== false) {
  2884. return token;
  2885. }
  2886. // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
  2887. return false;
  2888. }
  2889. if (!this._input) {
  2890. this.done = true;
  2891. this.clear();
  2892. return this.EOF;
  2893. } else {
  2894. var lineno_msg = '';
  2895. if (this.options.trackPosition) {
  2896. lineno_msg = ' on line ' + (this.yylineno + 1);
  2897. }
  2898. var p = this.constructLexErrorInfo(
  2899. 'Lexical error' + lineno_msg + ': Unrecognized text.',
  2900. this.options.lexerErrorsAreRecoverable
  2901. );
  2902. var pendingInput = this._input;
  2903. var activeCondition = this.topState();
  2904. var conditionStackDepth = this.conditionStack.length;
  2905. token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR;
  2906. if (token === this.ERROR) {
  2907. // we can try to recover from a lexer error that `parseError()` did not 'recover' for us
  2908. // by moving forward at least one character at a time IFF the (user-specified?) `parseError()`
  2909. // has not consumed/modified any pending input or changed state in the error handler:
  2910. if (!this.matches && // and make sure the input has been modified/consumed ...
  2911. pendingInput === this._input && // ...or the lexer state has been modified significantly enough
  2912. // to merit a non-consuming error handling action right now.
  2913. activeCondition === this.topState() && conditionStackDepth === this.conditionStack.length) {
  2914. this.input();
  2915. }
  2916. }
  2917. return token;
  2918. }
  2919. },
  2920. /**
  2921. * return next match that has a token
  2922. *
  2923. * @public
  2924. * @this {RegExpLexer}
  2925. */
  2926. lex: function lexer_lex() {
  2927. var r;
  2928. // allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer:
  2929. if (typeof this.pre_lex === 'function') {
  2930. r = this.pre_lex.call(this, 0);
  2931. }
  2932. if (typeof this.options.pre_lex === 'function') {
  2933. // (also account for a userdef function which does not return any value: keep the token as is)
  2934. r = this.options.pre_lex.call(this, r) || r;
  2935. }
  2936. if (this.yy && typeof this.yy.pre_lex === 'function') {
  2937. // (also account for a userdef function which does not return any value: keep the token as is)
  2938. r = this.yy.pre_lex.call(this, r) || r;
  2939. }
  2940. while (!r) {
  2941. r = this.next();
  2942. }
  2943. if (this.yy && typeof this.yy.post_lex === 'function') {
  2944. // (also account for a userdef function which does not return any value: keep the token as is)
  2945. r = this.yy.post_lex.call(this, r) || r;
  2946. }
  2947. if (typeof this.options.post_lex === 'function') {
  2948. // (also account for a userdef function which does not return any value: keep the token as is)
  2949. r = this.options.post_lex.call(this, r) || r;
  2950. }
  2951. if (typeof this.post_lex === 'function') {
  2952. // (also account for a userdef function which does not return any value: keep the token as is)
  2953. r = this.post_lex.call(this, r) || r;
  2954. }
  2955. return r;
  2956. },
  2957. /**
  2958. * return next match that has a token. Identical to the `lex()` API but does not invoke any of the
  2959. * `pre_lex()` nor any of the `post_lex()` callbacks.
  2960. *
  2961. * @public
  2962. * @this {RegExpLexer}
  2963. */
  2964. fastLex: function lexer_fastLex() {
  2965. var r;
  2966. while (!r) {
  2967. r = this.next();
  2968. }
  2969. return r;
  2970. },
  2971. /**
  2972. * return info about the lexer state that can help a parser or other lexer API user to use the
  2973. * most efficient means available. This API is provided to aid run-time performance for larger
  2974. * systems which employ this lexer.
  2975. *
  2976. * @public
  2977. * @this {RegExpLexer}
  2978. */
  2979. canIUse: function lexer_canIUse() {
  2980. var rv = {
  2981. fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function'
  2982. };
  2983. return rv;
  2984. },
  2985. /**
  2986. * backwards compatible alias for `pushState()`;
  2987. * the latter is symmetrical with `popState()` and we advise to use
  2988. * those APIs in any modern lexer code, rather than `begin()`.
  2989. *
  2990. * @public
  2991. * @this {RegExpLexer}
  2992. */
  2993. begin: function lexer_begin(condition) {
  2994. return this.pushState(condition);
  2995. },
  2996. /**
  2997. * activates a new lexer condition state (pushes the new lexer
  2998. * condition state onto the condition stack)
  2999. *
  3000. * @public
  3001. * @this {RegExpLexer}
  3002. */
  3003. pushState: function lexer_pushState(condition) {
  3004. this.conditionStack.push(condition);
  3005. this.__currentRuleSet__ = null;
  3006. return this;
  3007. },
  3008. /**
  3009. * pop the previously active lexer condition state off the condition
  3010. * stack
  3011. *
  3012. * @public
  3013. * @this {RegExpLexer}
  3014. */
  3015. popState: function lexer_popState() {
  3016. var n = this.conditionStack.length - 1;
  3017. if (n > 0) {
  3018. this.__currentRuleSet__ = null;
  3019. return this.conditionStack.pop();
  3020. } else {
  3021. return this.conditionStack[0];
  3022. }
  3023. },
  3024. /**
  3025. * return the currently active lexer condition state; when an index
  3026. * argument is provided it produces the N-th previous condition state,
  3027. * if available
  3028. *
  3029. * @public
  3030. * @this {RegExpLexer}
  3031. */
  3032. topState: function lexer_topState(n) {
  3033. n = this.conditionStack.length - 1 - Math.abs(n || 0);
  3034. if (n >= 0) {
  3035. return this.conditionStack[n];
  3036. } else {
  3037. return 'INITIAL';
  3038. }
  3039. },
  3040. /**
  3041. * (internal) determine the lexer rule set which is active for the
  3042. * currently active lexer condition state
  3043. *
  3044. * @public
  3045. * @this {RegExpLexer}
  3046. */
  3047. _currentRules: function lexer__currentRules() {
  3048. if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
  3049. return this.conditions[this.conditionStack[this.conditionStack.length - 1]];
  3050. } else {
  3051. return this.conditions['INITIAL'];
  3052. }
  3053. },
  3054. /**
  3055. * return the number of states currently on the stack
  3056. *
  3057. * @public
  3058. * @this {RegExpLexer}
  3059. */
  3060. stateStackSize: function lexer_stateStackSize() {
  3061. return this.conditionStack.length;
  3062. },
  3063. options: {
  3064. trackPosition: true,
  3065. caseInsensitive: true
  3066. },
  3067. JisonLexerError: JisonLexerError,
  3068. performAction: function lexer__performAction(yy, yyrulenumber, YY_START) {
  3069. var yy_ = this;
  3070. var YYSTATE = YY_START;
  3071. switch (yyrulenumber) {
  3072. case 0:
  3073. /*! Conditions:: INITIAL */
  3074. /*! Rule:: \s+ */
  3075. /* skip whitespace */
  3076. break;
  3077. case 7:
  3078. /*! Conditions:: INITIAL */
  3079. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)em\b */
  3080. return 12; // em
  3081. break;
  3082. case 8:
  3083. /*! Conditions:: INITIAL */
  3084. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)ex\b */
  3085. return 12; // ex
  3086. break;
  3087. case 9:
  3088. /*! Conditions:: INITIAL */
  3089. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)ch\b */
  3090. return 12; // ch
  3091. break;
  3092. case 10:
  3093. /*! Conditions:: INITIAL */
  3094. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)rem\b */
  3095. return 12; // rem
  3096. break;
  3097. case 11:
  3098. /*! Conditions:: INITIAL */
  3099. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)vw\b */
  3100. return 12; // vw
  3101. break;
  3102. case 12:
  3103. /*! Conditions:: INITIAL */
  3104. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)vh\b */
  3105. return 12; // vh
  3106. break;
  3107. case 13:
  3108. /*! Conditions:: INITIAL */
  3109. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)vmin\b */
  3110. return 12; // vmin
  3111. break;
  3112. case 14:
  3113. /*! Conditions:: INITIAL */
  3114. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)vmax\b */
  3115. return 12; // vmax
  3116. break;
  3117. case 15:
  3118. /*! Conditions:: INITIAL */
  3119. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)vm\b */
  3120. return 12; // vm (non-standard name)
  3121. break;
  3122. case 16:
  3123. /*! Conditions:: INITIAL */
  3124. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)px\b */
  3125. return 12; // px
  3126. break;
  3127. case 17:
  3128. /*! Conditions:: INITIAL */
  3129. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)mm\b */
  3130. return 12; // mm
  3131. break;
  3132. case 18:
  3133. /*! Conditions:: INITIAL */
  3134. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)cm\b */
  3135. return 12; // cm
  3136. break;
  3137. case 19:
  3138. /*! Conditions:: INITIAL */
  3139. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)in\b */
  3140. return 12; // in
  3141. break;
  3142. case 20:
  3143. /*! Conditions:: INITIAL */
  3144. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)pt\b */
  3145. return 12; // pt
  3146. break;
  3147. case 21:
  3148. /*! Conditions:: INITIAL */
  3149. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)pc\b */
  3150. return 12; // pc
  3151. break;
  3152. case 22:
  3153. /*! Conditions:: INITIAL */
  3154. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)Q\b */
  3155. return 12; // Q
  3156. break;
  3157. case 23:
  3158. /*! Conditions:: INITIAL */
  3159. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)fr\b */
  3160. return 12; // fr
  3161. break;
  3162. case 24:
  3163. /*! Conditions:: INITIAL */
  3164. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)deg\b */
  3165. return 13; // deg
  3166. break;
  3167. case 25:
  3168. /*! Conditions:: INITIAL */
  3169. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)grad\b */
  3170. return 13; // grad
  3171. break;
  3172. case 26:
  3173. /*! Conditions:: INITIAL */
  3174. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)turn\b */
  3175. return 13; // turn
  3176. break;
  3177. case 27:
  3178. /*! Conditions:: INITIAL */
  3179. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)rad\b */
  3180. return 13; // rad
  3181. break;
  3182. case 28:
  3183. /*! Conditions:: INITIAL */
  3184. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)s\b */
  3185. return 14; // s
  3186. break;
  3187. case 29:
  3188. /*! Conditions:: INITIAL */
  3189. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)ms\b */
  3190. return 14; // ms
  3191. break;
  3192. case 30:
  3193. /*! Conditions:: INITIAL */
  3194. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)Hz\b */
  3195. return 15; // Hz
  3196. break;
  3197. case 31:
  3198. /*! Conditions:: INITIAL */
  3199. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)kHz\b */
  3200. return 15; // kHz
  3201. break;
  3202. case 32:
  3203. /*! Conditions:: INITIAL */
  3204. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)dpi\b */
  3205. return 16; // dpi
  3206. break;
  3207. case 33:
  3208. /*! Conditions:: INITIAL */
  3209. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)dpcm\b */
  3210. return 16; // dpcm
  3211. break;
  3212. case 34:
  3213. /*! Conditions:: INITIAL */
  3214. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)dppx\b */
  3215. return 16; // dppm
  3216. break;
  3217. case 39:
  3218. /*! Conditions:: INITIAL */
  3219. /*! Rule:: #\{([\s\S]*?)\} */
  3220. return 18; // scss variable
  3221. break;
  3222. case 40:
  3223. /*! Conditions:: INITIAL */
  3224. /*! Rule:: @\{([\s\S]*?)\} */
  3225. return 18; // less variable
  3226. break;
  3227. default:
  3228. return this.simpleCaseActionClusters[yyrulenumber];
  3229. }
  3230. },
  3231. simpleCaseActionClusters: {
  3232. /*! Conditions:: INITIAL */
  3233. /*! Rule:: (-(webkit|moz)-)?calc\b */
  3234. 1: 3,
  3235. /*! Conditions:: INITIAL */
  3236. /*! Rule:: [a-z][a-z0-9-]*\s*\((?:(?:"(?:\\.|[^\"\\])*"|'(?:\\.|[^\'\\])*')|\([^)]*\)|[^\(\)]*)*\) */
  3237. 2: 11,
  3238. /*! Conditions:: INITIAL */
  3239. /*! Rule:: \* */
  3240. 3: 8,
  3241. /*! Conditions:: INITIAL */
  3242. /*! Rule:: \/ */
  3243. 4: 9,
  3244. /*! Conditions:: INITIAL */
  3245. /*! Rule:: \+ */
  3246. 5: 6,
  3247. /*! Conditions:: INITIAL */
  3248. /*! Rule:: - */
  3249. 6: 7,
  3250. /*! Conditions:: INITIAL */
  3251. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)% */
  3252. 35: 17,
  3253. /*! Conditions:: INITIAL */
  3254. /*! Rule:: ([0-9]+(\.[0-9]+)?|\.[0-9]+)\b */
  3255. 36: 10,
  3256. /*! Conditions:: INITIAL */
  3257. /*! Rule:: \( */
  3258. 37: 4,
  3259. /*! Conditions:: INITIAL */
  3260. /*! Rule:: \) */
  3261. 38: 5,
  3262. /*! Conditions:: INITIAL */
  3263. /*! Rule:: \S[^\s()*\/+-]* */
  3264. 41: 18,
  3265. /*! Conditions:: INITIAL */
  3266. /*! Rule:: $ */
  3267. 42: 1
  3268. },
  3269. rules: [
  3270. /* 0: */ /^(?:\s+)/i,
  3271. /* 1: */ /^(?:(-(webkit|moz)-)?calc\b)/i,
  3272. /* 2: */ /^(?:[a-z][\d\-a-z]*\s*\((?:(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')|\([^)]*\)|[^()]*)*\))/i,
  3273. /* 3: */ /^(?:\*)/i,
  3274. /* 4: */ /^(?:\/)/i,
  3275. /* 5: */ /^(?:\+)/i,
  3276. /* 6: */ /^(?:-)/i,
  3277. /* 7: */ /^(?:(\d+(\.\d+)?|\.\d+)em\b)/i,
  3278. /* 8: */ /^(?:(\d+(\.\d+)?|\.\d+)ex\b)/i,
  3279. /* 9: */ /^(?:(\d+(\.\d+)?|\.\d+)ch\b)/i,
  3280. /* 10: */ /^(?:(\d+(\.\d+)?|\.\d+)rem\b)/i,
  3281. /* 11: */ /^(?:(\d+(\.\d+)?|\.\d+)vw\b)/i,
  3282. /* 12: */ /^(?:(\d+(\.\d+)?|\.\d+)vh\b)/i,
  3283. /* 13: */ /^(?:(\d+(\.\d+)?|\.\d+)vmin\b)/i,
  3284. /* 14: */ /^(?:(\d+(\.\d+)?|\.\d+)vmax\b)/i,
  3285. /* 15: */ /^(?:(\d+(\.\d+)?|\.\d+)vm\b)/i,
  3286. /* 16: */ /^(?:(\d+(\.\d+)?|\.\d+)px\b)/i,
  3287. /* 17: */ /^(?:(\d+(\.\d+)?|\.\d+)mm\b)/i,
  3288. /* 18: */ /^(?:(\d+(\.\d+)?|\.\d+)cm\b)/i,
  3289. /* 19: */ /^(?:(\d+(\.\d+)?|\.\d+)in\b)/i,
  3290. /* 20: */ /^(?:(\d+(\.\d+)?|\.\d+)pt\b)/i,
  3291. /* 21: */ /^(?:(\d+(\.\d+)?|\.\d+)pc\b)/i,
  3292. /* 22: */ /^(?:(\d+(\.\d+)?|\.\d+)Q\b)/i,
  3293. /* 23: */ /^(?:(\d+(\.\d+)?|\.\d+)fr\b)/i,
  3294. /* 24: */ /^(?:(\d+(\.\d+)?|\.\d+)deg\b)/i,
  3295. /* 25: */ /^(?:(\d+(\.\d+)?|\.\d+)grad\b)/i,
  3296. /* 26: */ /^(?:(\d+(\.\d+)?|\.\d+)turn\b)/i,
  3297. /* 27: */ /^(?:(\d+(\.\d+)?|\.\d+)rad\b)/i,
  3298. /* 28: */ /^(?:(\d+(\.\d+)?|\.\d+)s\b)/i,
  3299. /* 29: */ /^(?:(\d+(\.\d+)?|\.\d+)ms\b)/i,
  3300. /* 30: */ /^(?:(\d+(\.\d+)?|\.\d+)Hz\b)/i,
  3301. /* 31: */ /^(?:(\d+(\.\d+)?|\.\d+)kHz\b)/i,
  3302. /* 32: */ /^(?:(\d+(\.\d+)?|\.\d+)dpi\b)/i,
  3303. /* 33: */ /^(?:(\d+(\.\d+)?|\.\d+)dpcm\b)/i,
  3304. /* 34: */ /^(?:(\d+(\.\d+)?|\.\d+)dppx\b)/i,
  3305. /* 35: */ /^(?:(\d+(\.\d+)?|\.\d+)%)/i,
  3306. /* 36: */ /^(?:(\d+(\.\d+)?|\.\d+)\b)/i,
  3307. /* 37: */ /^(?:\()/i,
  3308. /* 38: */ /^(?:\))/i,
  3309. /* 39: */ /^(?:#\{([\s\S]*?)\})/i,
  3310. /* 40: */ /^(?:@\{([\s\S]*?)\})/i,
  3311. /* 41: */ /^(?:\S[^\s()*\/+-]*)/i,
  3312. /* 42: */ /^(?:$)/i
  3313. ],
  3314. conditions: {
  3315. 'INITIAL': {
  3316. rules: [
  3317. 0,
  3318. 1,
  3319. 2,
  3320. 3,
  3321. 4,
  3322. 5,
  3323. 6,
  3324. 7,
  3325. 8,
  3326. 9,
  3327. 10,
  3328. 11,
  3329. 12,
  3330. 13,
  3331. 14,
  3332. 15,
  3333. 16,
  3334. 17,
  3335. 18,
  3336. 19,
  3337. 20,
  3338. 21,
  3339. 22,
  3340. 23,
  3341. 24,
  3342. 25,
  3343. 26,
  3344. 27,
  3345. 28,
  3346. 29,
  3347. 30,
  3348. 31,
  3349. 32,
  3350. 33,
  3351. 34,
  3352. 35,
  3353. 36,
  3354. 37,
  3355. 38,
  3356. 39,
  3357. 40,
  3358. 41,
  3359. 42
  3360. ],
  3361. inclusive: true
  3362. }
  3363. }
  3364. };
  3365. return lexer;
  3366. }();
  3367. parser.lexer = lexer;
  3368. function Parser() {
  3369. this.yy = {};
  3370. }
  3371. Parser.prototype = parser;
  3372. parser.Parser = Parser;
  3373. return new Parser();
  3374. })();
  3375. if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
  3376. exports.parser = parser;
  3377. exports.Parser = parser.Parser;
  3378. exports.parse = function () {
  3379. return parser.parse.apply(parser, arguments);
  3380. };
  3381. }