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.

3755 lines
118 KiB

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