jsep.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. /* This file is automatically rebuilt by the Cesium build process. */
  2. import { c as createCommonjsModule } from './_commonjsHelpers-3aae1032.js';
  3. var jsep = createCommonjsModule(function (module, exports) {
  4. // JavaScript Expression Parser (JSEP) 0.3.5
  5. // JSEP may be freely distributed under the MIT License
  6. // https://ericsmekens.github.io/jsep/
  7. /*global module: true, exports: true, console: true */
  8. (function (root) {
  9. // Node Types
  10. // ----------
  11. // This is the full set of types that any JSEP node can be.
  12. // Store them here to save space when minified
  13. var COMPOUND = 'Compound',
  14. IDENTIFIER = 'Identifier',
  15. MEMBER_EXP = 'MemberExpression',
  16. LITERAL = 'Literal',
  17. THIS_EXP = 'ThisExpression',
  18. CALL_EXP = 'CallExpression',
  19. UNARY_EXP = 'UnaryExpression',
  20. BINARY_EXP = 'BinaryExpression',
  21. LOGICAL_EXP = 'LogicalExpression',
  22. CONDITIONAL_EXP = 'ConditionalExpression',
  23. ARRAY_EXP = 'ArrayExpression',
  24. PERIOD_CODE = 46, // '.'
  25. COMMA_CODE = 44, // ','
  26. SQUOTE_CODE = 39, // single quote
  27. DQUOTE_CODE = 34, // double quotes
  28. OPAREN_CODE = 40, // (
  29. CPAREN_CODE = 41, // )
  30. OBRACK_CODE = 91, // [
  31. CBRACK_CODE = 93, // ]
  32. QUMARK_CODE = 63, // ?
  33. SEMCOL_CODE = 59, // ;
  34. COLON_CODE = 58, // :
  35. throwError = function(message, index) {
  36. var error = new Error(message + ' at character ' + index);
  37. error.index = index;
  38. error.description = message;
  39. throw error;
  40. },
  41. // Operations
  42. // ----------
  43. // Set `t` to `true` to save space (when minified, not gzipped)
  44. t = true,
  45. // Use a quickly-accessible map to store all of the unary operators
  46. // Values are set to `true` (it really doesn't matter)
  47. unary_ops = {'-': t, '!': t, '~': t, '+': t},
  48. // Also use a map for the binary operations but set their values to their
  49. // binary precedence for quick reference:
  50. // see [Order of operations](http://en.wikipedia.org/wiki/Order_of_operations#Programming_language)
  51. binary_ops = {
  52. '||': 1, '&&': 2, '|': 3, '^': 4, '&': 5,
  53. '==': 6, '!=': 6, '===': 6, '!==': 6,
  54. '<': 7, '>': 7, '<=': 7, '>=': 7,
  55. '<<':8, '>>': 8, '>>>': 8,
  56. '+': 9, '-': 9,
  57. '*': 10, '/': 10, '%': 10
  58. },
  59. // Get return the longest key length of any object
  60. getMaxKeyLen = function(obj) {
  61. var max_len = 0, len;
  62. for(var key in obj) {
  63. if((len = key.length) > max_len && obj.hasOwnProperty(key)) {
  64. max_len = len;
  65. }
  66. }
  67. return max_len;
  68. },
  69. max_unop_len = getMaxKeyLen(unary_ops),
  70. max_binop_len = getMaxKeyLen(binary_ops),
  71. // Literals
  72. // ----------
  73. // Store the values to return for the various literals we may encounter
  74. literals = {
  75. 'true': true,
  76. 'false': false,
  77. 'null': null
  78. },
  79. // Except for `this`, which is special. This could be changed to something like `'self'` as well
  80. this_str = 'this',
  81. // Returns the precedence of a binary operator or `0` if it isn't a binary operator
  82. binaryPrecedence = function(op_val) {
  83. return binary_ops[op_val] || 0;
  84. },
  85. // Utility function (gets called from multiple places)
  86. // Also note that `a && b` and `a || b` are *logical* expressions, not binary expressions
  87. createBinaryExpression = function (operator, left, right) {
  88. var type = (operator === '||' || operator === '&&') ? LOGICAL_EXP : BINARY_EXP;
  89. return {
  90. type: type,
  91. operator: operator,
  92. left: left,
  93. right: right
  94. };
  95. },
  96. // `ch` is a character code in the next three functions
  97. isDecimalDigit = function(ch) {
  98. return (ch >= 48 && ch <= 57); // 0...9
  99. },
  100. isIdentifierStart = function(ch) {
  101. return (ch === 36) || (ch === 95) || // `$` and `_`
  102. (ch >= 65 && ch <= 90) || // A...Z
  103. (ch >= 97 && ch <= 122) || // a...z
  104. (ch >= 128 && !binary_ops[String.fromCharCode(ch)]); // any non-ASCII that is not an operator
  105. },
  106. isIdentifierPart = function(ch) {
  107. return (ch === 36) || (ch === 95) || // `$` and `_`
  108. (ch >= 65 && ch <= 90) || // A...Z
  109. (ch >= 97 && ch <= 122) || // a...z
  110. (ch >= 48 && ch <= 57) || // 0...9
  111. (ch >= 128 && !binary_ops[String.fromCharCode(ch)]); // any non-ASCII that is not an operator
  112. },
  113. // Parsing
  114. // -------
  115. // `expr` is a string with the passed in expression
  116. jsep = function(expr) {
  117. // `index` stores the character number we are currently at while `length` is a constant
  118. // All of the gobbles below will modify `index` as we move along
  119. var index = 0,
  120. charAtFunc = expr.charAt,
  121. charCodeAtFunc = expr.charCodeAt,
  122. exprI = function(i) { return charAtFunc.call(expr, i); },
  123. exprICode = function(i) { return charCodeAtFunc.call(expr, i); },
  124. length = expr.length,
  125. // Push `index` up to the next non-space character
  126. gobbleSpaces = function() {
  127. var ch = exprICode(index);
  128. // space or tab
  129. while(ch === 32 || ch === 9 || ch === 10 || ch === 13) {
  130. ch = exprICode(++index);
  131. }
  132. },
  133. // The main parsing function. Much of this code is dedicated to ternary expressions
  134. gobbleExpression = function() {
  135. var test = gobbleBinaryExpression(),
  136. consequent, alternate;
  137. gobbleSpaces();
  138. if(exprICode(index) === QUMARK_CODE) {
  139. // Ternary expression: test ? consequent : alternate
  140. index++;
  141. consequent = gobbleExpression();
  142. if(!consequent) {
  143. throwError('Expected expression', index);
  144. }
  145. gobbleSpaces();
  146. if(exprICode(index) === COLON_CODE) {
  147. index++;
  148. alternate = gobbleExpression();
  149. if(!alternate) {
  150. throwError('Expected expression', index);
  151. }
  152. return {
  153. type: CONDITIONAL_EXP,
  154. test: test,
  155. consequent: consequent,
  156. alternate: alternate
  157. };
  158. } else {
  159. throwError('Expected :', index);
  160. }
  161. } else {
  162. return test;
  163. }
  164. },
  165. // Search for the operation portion of the string (e.g. `+`, `===`)
  166. // Start by taking the longest possible binary operations (3 characters: `===`, `!==`, `>>>`)
  167. // and move down from 3 to 2 to 1 character until a matching binary operation is found
  168. // then, return that binary operation
  169. gobbleBinaryOp = function() {
  170. gobbleSpaces();
  171. var to_check = expr.substr(index, max_binop_len), tc_len = to_check.length;
  172. while(tc_len > 0) {
  173. // Don't accept a binary op when it is an identifier.
  174. // Binary ops that start with a identifier-valid character must be followed
  175. // by a non identifier-part valid character
  176. if(binary_ops.hasOwnProperty(to_check) && (
  177. !isIdentifierStart(exprICode(index)) ||
  178. (index+to_check.length< expr.length && !isIdentifierPart(exprICode(index+to_check.length)))
  179. )) {
  180. index += tc_len;
  181. return to_check;
  182. }
  183. to_check = to_check.substr(0, --tc_len);
  184. }
  185. return false;
  186. },
  187. // This function is responsible for gobbling an individual expression,
  188. // e.g. `1`, `1+2`, `a+(b*2)-Math.sqrt(2)`
  189. gobbleBinaryExpression = function() {
  190. var node, biop, prec, stack, biop_info, left, right, i, cur_biop;
  191. // First, try to get the leftmost thing
  192. // Then, check to see if there's a binary operator operating on that leftmost thing
  193. left = gobbleToken();
  194. biop = gobbleBinaryOp();
  195. // If there wasn't a binary operator, just return the leftmost node
  196. if(!biop) {
  197. return left;
  198. }
  199. // Otherwise, we need to start a stack to properly place the binary operations in their
  200. // precedence structure
  201. biop_info = { value: biop, prec: binaryPrecedence(biop)};
  202. right = gobbleToken();
  203. if(!right) {
  204. throwError("Expected expression after " + biop, index);
  205. }
  206. stack = [left, biop_info, right];
  207. // Properly deal with precedence using [recursive descent](http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm)
  208. while((biop = gobbleBinaryOp())) {
  209. prec = binaryPrecedence(biop);
  210. if(prec === 0) {
  211. break;
  212. }
  213. biop_info = { value: biop, prec: prec };
  214. cur_biop = biop;
  215. // Reduce: make a binary expression from the three topmost entries.
  216. while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) {
  217. right = stack.pop();
  218. biop = stack.pop().value;
  219. left = stack.pop();
  220. node = createBinaryExpression(biop, left, right);
  221. stack.push(node);
  222. }
  223. node = gobbleToken();
  224. if(!node) {
  225. throwError("Expected expression after " + cur_biop, index);
  226. }
  227. stack.push(biop_info, node);
  228. }
  229. i = stack.length - 1;
  230. node = stack[i];
  231. while(i > 1) {
  232. node = createBinaryExpression(stack[i - 1].value, stack[i - 2], node);
  233. i -= 2;
  234. }
  235. return node;
  236. },
  237. // An individual part of a binary expression:
  238. // e.g. `foo.bar(baz)`, `1`, `"abc"`, `(a % 2)` (because it's in parenthesis)
  239. gobbleToken = function() {
  240. var ch, to_check, tc_len;
  241. gobbleSpaces();
  242. ch = exprICode(index);
  243. if(isDecimalDigit(ch) || ch === PERIOD_CODE) {
  244. // Char code 46 is a dot `.` which can start off a numeric literal
  245. return gobbleNumericLiteral();
  246. } else if(ch === SQUOTE_CODE || ch === DQUOTE_CODE) {
  247. // Single or double quotes
  248. return gobbleStringLiteral();
  249. } else if (ch === OBRACK_CODE) {
  250. return gobbleArray();
  251. } else {
  252. to_check = expr.substr(index, max_unop_len);
  253. tc_len = to_check.length;
  254. while(tc_len > 0) {
  255. // Don't accept an unary op when it is an identifier.
  256. // Unary ops that start with a identifier-valid character must be followed
  257. // by a non identifier-part valid character
  258. if(unary_ops.hasOwnProperty(to_check) && (
  259. !isIdentifierStart(exprICode(index)) ||
  260. (index+to_check.length < expr.length && !isIdentifierPart(exprICode(index+to_check.length)))
  261. )) {
  262. index += tc_len;
  263. return {
  264. type: UNARY_EXP,
  265. operator: to_check,
  266. argument: gobbleToken(),
  267. prefix: true
  268. };
  269. }
  270. to_check = to_check.substr(0, --tc_len);
  271. }
  272. if (isIdentifierStart(ch) || ch === OPAREN_CODE) { // open parenthesis
  273. // `foo`, `bar.baz`
  274. return gobbleVariable();
  275. }
  276. }
  277. return false;
  278. },
  279. // Parse simple numeric literals: `12`, `3.4`, `.5`. Do this by using a string to
  280. // keep track of everything in the numeric literal and then calling `parseFloat` on that string
  281. gobbleNumericLiteral = function() {
  282. var number = '', ch, chCode;
  283. while(isDecimalDigit(exprICode(index))) {
  284. number += exprI(index++);
  285. }
  286. if(exprICode(index) === PERIOD_CODE) { // can start with a decimal marker
  287. number += exprI(index++);
  288. while(isDecimalDigit(exprICode(index))) {
  289. number += exprI(index++);
  290. }
  291. }
  292. ch = exprI(index);
  293. if(ch === 'e' || ch === 'E') { // exponent marker
  294. number += exprI(index++);
  295. ch = exprI(index);
  296. if(ch === '+' || ch === '-') { // exponent sign
  297. number += exprI(index++);
  298. }
  299. while(isDecimalDigit(exprICode(index))) { //exponent itself
  300. number += exprI(index++);
  301. }
  302. if(!isDecimalDigit(exprICode(index-1)) ) {
  303. throwError('Expected exponent (' + number + exprI(index) + ')', index);
  304. }
  305. }
  306. chCode = exprICode(index);
  307. // Check to make sure this isn't a variable name that start with a number (123abc)
  308. if(isIdentifierStart(chCode)) {
  309. throwError('Variable names cannot start with a number (' +
  310. number + exprI(index) + ')', index);
  311. } else if(chCode === PERIOD_CODE) {
  312. throwError('Unexpected period', index);
  313. }
  314. return {
  315. type: LITERAL,
  316. value: parseFloat(number),
  317. raw: number
  318. };
  319. },
  320. // Parses a string literal, staring with single or double quotes with basic support for escape codes
  321. // e.g. `"hello world"`, `'this is\nJSEP'`
  322. gobbleStringLiteral = function() {
  323. var str = '', quote = exprI(index++), closed = false, ch;
  324. while(index < length) {
  325. ch = exprI(index++);
  326. if(ch === quote) {
  327. closed = true;
  328. break;
  329. } else if(ch === '\\') {
  330. // Check for all of the common escape codes
  331. ch = exprI(index++);
  332. switch(ch) {
  333. case 'n': str += '\n'; break;
  334. case 'r': str += '\r'; break;
  335. case 't': str += '\t'; break;
  336. case 'b': str += '\b'; break;
  337. case 'f': str += '\f'; break;
  338. case 'v': str += '\x0B'; break;
  339. default : str += ch;
  340. }
  341. } else {
  342. str += ch;
  343. }
  344. }
  345. if(!closed) {
  346. throwError('Unclosed quote after "'+str+'"', index);
  347. }
  348. return {
  349. type: LITERAL,
  350. value: str,
  351. raw: quote + str + quote
  352. };
  353. },
  354. // Gobbles only identifiers
  355. // e.g.: `foo`, `_value`, `$x1`
  356. // Also, this function checks if that identifier is a literal:
  357. // (e.g. `true`, `false`, `null`) or `this`
  358. gobbleIdentifier = function() {
  359. var ch = exprICode(index), start = index, identifier;
  360. if(isIdentifierStart(ch)) {
  361. index++;
  362. } else {
  363. throwError('Unexpected ' + exprI(index), index);
  364. }
  365. while(index < length) {
  366. ch = exprICode(index);
  367. if(isIdentifierPart(ch)) {
  368. index++;
  369. } else {
  370. break;
  371. }
  372. }
  373. identifier = expr.slice(start, index);
  374. if(literals.hasOwnProperty(identifier)) {
  375. return {
  376. type: LITERAL,
  377. value: literals[identifier],
  378. raw: identifier
  379. };
  380. } else if(identifier === this_str) {
  381. return { type: THIS_EXP };
  382. } else {
  383. return {
  384. type: IDENTIFIER,
  385. name: identifier
  386. };
  387. }
  388. },
  389. // Gobbles a list of arguments within the context of a function call
  390. // or array literal. This function also assumes that the opening character
  391. // `(` or `[` has already been gobbled, and gobbles expressions and commas
  392. // until the terminator character `)` or `]` is encountered.
  393. // e.g. `foo(bar, baz)`, `my_func()`, or `[bar, baz]`
  394. gobbleArguments = function(termination) {
  395. var ch_i, args = [], node, closed = false;
  396. var separator_count = 0;
  397. while(index < length) {
  398. gobbleSpaces();
  399. ch_i = exprICode(index);
  400. if(ch_i === termination) { // done parsing
  401. closed = true;
  402. index++;
  403. if(termination === CPAREN_CODE && separator_count && separator_count >= args.length){
  404. throwError('Unexpected token ' + String.fromCharCode(termination), index);
  405. }
  406. break;
  407. } else if (ch_i === COMMA_CODE) { // between expressions
  408. index++;
  409. separator_count++;
  410. if(separator_count !== args.length) { // missing argument
  411. if(termination === CPAREN_CODE) {
  412. throwError('Unexpected token ,', index);
  413. }
  414. else if(termination === CBRACK_CODE) {
  415. for(var arg = args.length; arg< separator_count; arg++) {
  416. args.push(null);
  417. }
  418. }
  419. }
  420. } else {
  421. node = gobbleExpression();
  422. if(!node || node.type === COMPOUND) {
  423. throwError('Expected comma', index);
  424. }
  425. args.push(node);
  426. }
  427. }
  428. if (!closed) {
  429. throwError('Expected ' + String.fromCharCode(termination), index);
  430. }
  431. return args;
  432. },
  433. // Gobble a non-literal variable name. This variable name may include properties
  434. // e.g. `foo`, `bar.baz`, `foo['bar'].baz`
  435. // It also gobbles function calls:
  436. // e.g. `Math.acos(obj.angle)`
  437. gobbleVariable = function() {
  438. var ch_i, node;
  439. ch_i = exprICode(index);
  440. if(ch_i === OPAREN_CODE) {
  441. node = gobbleGroup();
  442. } else {
  443. node = gobbleIdentifier();
  444. }
  445. gobbleSpaces();
  446. ch_i = exprICode(index);
  447. while(ch_i === PERIOD_CODE || ch_i === OBRACK_CODE || ch_i === OPAREN_CODE) {
  448. index++;
  449. if(ch_i === PERIOD_CODE) {
  450. gobbleSpaces();
  451. node = {
  452. type: MEMBER_EXP,
  453. computed: false,
  454. object: node,
  455. property: gobbleIdentifier()
  456. };
  457. } else if(ch_i === OBRACK_CODE) {
  458. node = {
  459. type: MEMBER_EXP,
  460. computed: true,
  461. object: node,
  462. property: gobbleExpression()
  463. };
  464. gobbleSpaces();
  465. ch_i = exprICode(index);
  466. if(ch_i !== CBRACK_CODE) {
  467. throwError('Unclosed [', index);
  468. }
  469. index++;
  470. } else if(ch_i === OPAREN_CODE) {
  471. // A function call is being made; gobble all the arguments
  472. node = {
  473. type: CALL_EXP,
  474. 'arguments': gobbleArguments(CPAREN_CODE),
  475. callee: node
  476. };
  477. }
  478. gobbleSpaces();
  479. ch_i = exprICode(index);
  480. }
  481. return node;
  482. },
  483. // Responsible for parsing a group of things within parentheses `()`
  484. // This function assumes that it needs to gobble the opening parenthesis
  485. // and then tries to gobble everything within that parenthesis, assuming
  486. // that the next thing it should see is the close parenthesis. If not,
  487. // then the expression probably doesn't have a `)`
  488. gobbleGroup = function() {
  489. index++;
  490. var node = gobbleExpression();
  491. gobbleSpaces();
  492. if(exprICode(index) === CPAREN_CODE) {
  493. index++;
  494. return node;
  495. } else {
  496. throwError('Unclosed (', index);
  497. }
  498. },
  499. // Responsible for parsing Array literals `[1, 2, 3]`
  500. // This function assumes that it needs to gobble the opening bracket
  501. // and then tries to gobble the expressions as arguments.
  502. gobbleArray = function() {
  503. index++;
  504. return {
  505. type: ARRAY_EXP,
  506. elements: gobbleArguments(CBRACK_CODE)
  507. };
  508. },
  509. nodes = [], ch_i, node;
  510. while(index < length) {
  511. ch_i = exprICode(index);
  512. // Expressions can be separated by semicolons, commas, or just inferred without any
  513. // separators
  514. if(ch_i === SEMCOL_CODE || ch_i === COMMA_CODE) {
  515. index++; // ignore separators
  516. } else {
  517. // Try to gobble each expression individually
  518. if((node = gobbleExpression())) {
  519. nodes.push(node);
  520. // If we weren't able to find a binary expression and are out of room, then
  521. // the expression passed in probably has too much
  522. } else if(index < length) {
  523. throwError('Unexpected "' + exprI(index) + '"', index);
  524. }
  525. }
  526. }
  527. // If there's only one expression just try returning the expression
  528. if(nodes.length === 1) {
  529. return nodes[0];
  530. } else {
  531. return {
  532. type: COMPOUND,
  533. body: nodes
  534. };
  535. }
  536. };
  537. // To be filled in by the template
  538. jsep.version = '0.3.5';
  539. jsep.toString = function() { return 'JavaScript Expression Parser (JSEP) v' + jsep.version; };
  540. /**
  541. * @method jsep.addUnaryOp
  542. * @param {string} op_name The name of the unary op to add
  543. * @return jsep
  544. */
  545. jsep.addUnaryOp = function(op_name) {
  546. max_unop_len = Math.max(op_name.length, max_unop_len);
  547. unary_ops[op_name] = t; return this;
  548. };
  549. /**
  550. * @method jsep.addBinaryOp
  551. * @param {string} op_name The name of the binary op to add
  552. * @param {number} precedence The precedence of the binary op (can be a float)
  553. * @return jsep
  554. */
  555. jsep.addBinaryOp = function(op_name, precedence) {
  556. max_binop_len = Math.max(op_name.length, max_binop_len);
  557. binary_ops[op_name] = precedence;
  558. return this;
  559. };
  560. /**
  561. * @method jsep.addLiteral
  562. * @param {string} literal_name The name of the literal to add
  563. * @param {*} literal_value The value of the literal
  564. * @return jsep
  565. */
  566. jsep.addLiteral = function(literal_name, literal_value) {
  567. literals[literal_name] = literal_value;
  568. return this;
  569. };
  570. /**
  571. * @method jsep.removeUnaryOp
  572. * @param {string} op_name The name of the unary op to remove
  573. * @return jsep
  574. */
  575. jsep.removeUnaryOp = function(op_name) {
  576. delete unary_ops[op_name];
  577. if(op_name.length === max_unop_len) {
  578. max_unop_len = getMaxKeyLen(unary_ops);
  579. }
  580. return this;
  581. };
  582. /**
  583. * @method jsep.removeAllUnaryOps
  584. * @return jsep
  585. */
  586. jsep.removeAllUnaryOps = function() {
  587. unary_ops = {};
  588. max_unop_len = 0;
  589. return this;
  590. };
  591. /**
  592. * @method jsep.removeBinaryOp
  593. * @param {string} op_name The name of the binary op to remove
  594. * @return jsep
  595. */
  596. jsep.removeBinaryOp = function(op_name) {
  597. delete binary_ops[op_name];
  598. if(op_name.length === max_binop_len) {
  599. max_binop_len = getMaxKeyLen(binary_ops);
  600. }
  601. return this;
  602. };
  603. /**
  604. * @method jsep.removeAllBinaryOps
  605. * @return jsep
  606. */
  607. jsep.removeAllBinaryOps = function() {
  608. binary_ops = {};
  609. max_binop_len = 0;
  610. return this;
  611. };
  612. /**
  613. * @method jsep.removeLiteral
  614. * @param {string} literal_name The name of the literal to remove
  615. * @return jsep
  616. */
  617. jsep.removeLiteral = function(literal_name) {
  618. delete literals[literal_name];
  619. return this;
  620. };
  621. /**
  622. * @method jsep.removeAllLiterals
  623. * @return jsep
  624. */
  625. jsep.removeAllLiterals = function() {
  626. literals = {};
  627. return this;
  628. };
  629. // In desktop environments, have a way to restore the old value for `jsep`
  630. {
  631. // In Node.JS environments
  632. if (module.exports) {
  633. exports = module.exports = jsep;
  634. } else {
  635. exports.parse = jsep;
  636. }
  637. }
  638. }());
  639. });
  640. export { jsep as default };