summaryrefslogtreecommitdiff
path: root/node_modules/reduce-css-calc
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-10-14 20:57:16 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-10-14 20:57:16 +0800
commit924a88fab5466307aba0b76d36b30ab06b11dcb5 (patch)
tree088b6e0beeef92d55e2b2ca523af3501b27a2830 /node_modules/reduce-css-calc
parenta240fe4a4810b7f0c678a8519832fa37afaad265 (diff)
updates
Diffstat (limited to 'node_modules/reduce-css-calc')
-rwxr-xr-xnode_modules/reduce-css-calc/CHANGELOG.md122
-rwxr-xr-xnode_modules/reduce-css-calc/README.md18
-rw-r--r--node_modules/reduce-css-calc/dist/index.js51
-rw-r--r--node_modules/reduce-css-calc/dist/lib/convert.js38
-rw-r--r--node_modules/reduce-css-calc/dist/lib/reducer.js258
-rw-r--r--node_modules/reduce-css-calc/dist/lib/stringifier.js78
-rw-r--r--node_modules/reduce-css-calc/dist/parser.js3858
-rwxr-xr-xnode_modules/reduce-css-calc/index.js164
-rw-r--r--node_modules/reduce-css-calc/node_modules/postcss-value-parser/LICENSE22
-rw-r--r--node_modules/reduce-css-calc/node_modules/postcss-value-parser/README.md253
-rw-r--r--node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/index.js28
-rw-r--r--node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/parse.js251
-rw-r--r--node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/stringify.js48
-rw-r--r--node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/unit.js49
-rw-r--r--node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/walk.js22
-rw-r--r--node_modules/reduce-css-calc/node_modules/postcss-value-parser/package.json58
-rw-r--r--node_modules/reduce-css-calc/package.json52
17 files changed, 5160 insertions, 210 deletions
diff --git a/node_modules/reduce-css-calc/CHANGELOG.md b/node_modules/reduce-css-calc/CHANGELOG.md
index fff0c07c..0a42c1bb 100755
--- a/node_modules/reduce-css-calc/CHANGELOG.md
+++ b/node_modules/reduce-css-calc/CHANGELOG.md
@@ -1,84 +1,164 @@
-# 1.3.0 - 2016-08-26
+# Changelog of `reduce-css-call`
+
+## 2.1.8 - 2020-01-08
+
+- Fix Parse error on custom property fallback ([#68](https://github.com/MoOx/reduce-css-calc/pull/68)) - @snowystinger)
+
+## 2.1.7 - 2019-10-22
+
+- Switch to a maintained jison fork ([#57](https://github.com/MoOx/reduce-css-calc/pull/57)) - @davidgovea)
+
+## 2.1.6 - 2019-01-11
+
+- Fixed: Incorrect calculation when subtracting (e.g. `calc(100% - calc(120px + 1em + 2em + 100px))`) ([#52](https://github.com/MoOx/reduce-css-calc/pull/53) - @sylvainpolletvillard)
+
+## 2.1.5 - 2018-09-20
+
+- [Avoid breaking when seeing ` constant()`` or `env()`](https://github.com/MoOx/reduce-css-calc/commit/409c9ba2cd5e06e7f8f679f7f0c3c3a14ff3e673) by @dlee
+
+## 2.1.4 - 2018-01-22
+
+- Prevent webpack parsing issue
+ (see https://github.com/zaach/jison/pull/352)
+
+## 2.1.3 - 2017-11-27
+
+- Fixed: Incorrect reduction for a specific case (e.g. `calc(1em + (1em - 5px))`) ([#43](https://github.com/MoOx/reduce-css-calc/pull/43) - @Justineo)
+
+## 2.1.2 - 2017-11-26
+
+- Fixed: Incorrect reduction of division with custom property (e.g. `calc(var(--foo) / 2)`) ([#41](https://github.com/MoOx/reduce-css-calc/issues/41) - @Semigradsky)
+
+## 2.1.1 - 2017-10-12
+
+- Fixed: Incorrect reduction of nested expression (e.g. `calc( (1em - calc( 10px + 1em)) / 2)`) ([#39](https://github.com/MoOx/reduce-css-calc/pull/39) - @gyoshev)
+
+## 2.1.0 - 2017-10-10
+
+- Added: Support for working in browsers without transpiling ([#36](https://github.com/MoOx/reduce-css-calc/pull/36) - @Semigradsky)
+- Fixed: `calc(100vw - (100vw - 100%))` does not evaluate to `100%` ([#35](https://github.com/MoOx/reduce-css-calc/pull/35) - @Semigradsky)
+
+## 2.0.5 - 2017-05-12
+
+- Fixed: Support division with a CSS variable.
+
+## 2.0.4 - 2017-05-09
+
+- Fixed: CSS variable regex was overly greedy and caused a crash in some
+ cases. ([#27](https://github.com/MoOx/reduce-css-calc/pull/27) - @andyjansson)
+
+## 2.0.3 - 2017-05-09
+
+- Fixed: Regression in handling decimals without having any numbers after
+ the decimal place (e.g. `10.px`).
+
+## 2.0.2 - 2017-05-08
+
+- Fixed: Regression in consecutive subtraction handling
+ ([#25](https://github.com/MoOx/reduce-css-calc/pull/25) - @andyjansson)
+
+## 2.0.1 - 2017-05-08
+
+- Fixed: Support for nested calc e.g. `calc(100% - calc(50px - 25px))`.
+- Fixed: Support for CSS variables e.g. `calc(var(--mouseX) * 1px)`.
+
+## 2.0.0 - 2017-05-08
+
+- Rewritten with a jison parser for more accurate value parsing.
+- Breaking: reduce-css-calc will now throw when trying to multiply or divide
+ by the same unit (e.g. `calc(200px * 20px)`), and also when trying to divide
+ by zero.
+- Added: Better handling of zero values (e.g. `calc(100vw / 2 - 6px + 0px)`
+ becomes `calc(100vw / 2 - 6px)`).
+- Added: Better handling of mixed time values (e.g. `calc(1s - 50ms)`
+ becomes `0.95s`).
+- Added: Inner parentheses calculation to simplify complex expressions (e.g.
+ `calc(14px + 6 * ((100vw - 320px) / 448))` becomes `calc(9.71px + 1.34vw)`
+ with precision set to `2`).
+- Fixed: `calc(1px + 1)` does not evaluate to `2px`.
+
+([#22](https://github.com/MoOx/reduce-css-calc/pull/22) - @andyjansson)
+
+## 1.3.0 - 2016-08-26
- Added: calc identifier from unresolved nested expressions are removed for
better browser support
([#19](https://github.com/MoOx/reduce-css-calc/pull/19) - @ben-eb)
-# 1.2.8 - 2016-08-26
+## 1.2.8 - 2016-08-26
- Fixed: regression from 1.2.5 on calc() with value without leading 0
([#17](https://github.com/MoOx/reduce-css-calc/pull/17) - @ben-eb)
-# 1.2.7 - 2016-08-22
+## 1.2.7 - 2016-08-22
- Fixed: regression from 1.2.5 on calc() with value without leading 0
(@MoOx)
-# 1.2.6 - 2016-08-22
+## 1.2.6 - 2016-08-22
- Fixed: regression from 1.2.5 on calc() on multiple lines
(@MoOx)
-# 1.2.5 - 2016-08-22
+## 1.2.5 - 2016-08-22
-- Fixed: security issue due to the usage of ``eval()``.
+- Fixed: security issue due to the usage of `eval()`.
This is to avoid an arbitrary code execution.
Now operations are resolved using
- [``math-expression-evaluator``](https://github.com/redhivesoftware/math-expression-evaluator)
+ [`math-expression-evaluator`](https://github.com/redhivesoftware/math-expression-evaluator)
-# 1.2.4 - 2016-06-09
+## 1.2.4 - 2016-06-09
- Fixed: zero values are not unitless anymore.
Browsers do not calculate calc() with 0 unitless values.
http://jsbin.com/punivivipo/edit?html,css,output
- ([#11](https://github.com/MoOx/reduce-css-calc/pull/11))

+ ([#11](https://github.com/MoOx/reduce-css-calc/pull/11))
-# 1.2.3 - 2016-04-28
+## 1.2.3 - 2016-04-28
- Fixed: wrong rouding in some edge cases
([#10](https://github.com/MoOx/reduce-css-calc/pull/10))
-# 1.2.2 - 2016-04-19
+## 1.2.2 - 2016-04-19
- Fixed: Don't reduce expression containing CSS variables.
([#9](https://github.com/MoOx/reduce-css-calc/pull/9))
-# 1.2.1 - 2016-02-22
+## 1.2.1 - 2016-02-22
- Fixed: uppercase letters in units are now supported
([#8](https://github.com/MoOx/reduce-css-calc/pull/8))
-# 1.2.0 - 2014-11-24
+## 1.2.0 - 2014-11-24
- Decimal precision is now customisable as the `precision` option
-# 1.1.4 - 2014-11-12
+## 1.1.4 - 2014-11-12
- 5 decimals rounding for everything
-# 1.1.3 - 2014-08-13
+## 1.1.3 - 2014-08-13
- 5 decimals rounding for percentage
-# 1.1.2 - 2014-08-10
+## 1.1.2 - 2014-08-10
- Prevent infinite loop by adding a `Call stack overflow`
- Correctly ignore unrecognized values (safer evaluation for nested expressions,
see [postcss/postcss-calc#2](https://github.com/postcss/postcss-calc/issues/2))
-- Handle rounding issues (eg: 10% * 20% now give 2%, not 2.0000000000000004%)
+- Handle rounding issues (eg: 10% \* 20% now give 2%, not 2.0000000000000004%)
-# 1.1.1 - 2014-08-06
+## 1.1.1 - 2014-08-06
- Fix issue when using mutiples differents prefixes in the same function
-# 1.1.0 - 2014-08-06
+## 1.1.0 - 2014-08-06
- support more complex formulas
- use `reduce-function-call`
- better error message
-
-# 1.0.0 - 2014-08-04
+## 1.0.0 - 2014-08-04
First release
diff --git a/node_modules/reduce-css-calc/README.md b/node_modules/reduce-css-calc/README.md
index 0ba73d30..bc9e59fb 100755
--- a/node_modules/reduce-css-calc/README.md
+++ b/node_modules/reduce-css-calc/README.md
@@ -1,4 +1,6 @@
-# reduce-css-calc [![Build Status](https://travis-ci.org/MoOx/reduce-css-calc.png)](https://travis-ci.org/MoOx/reduce-css-calc)
+# reduce-css-calc
+
+[![Build Status](https://travis-ci.org/MoOx/reduce-css-calc.svg)](https://travis-ci.org/MoOx/reduce-css-calc)
> Reduce CSS calc() function to the maximum.
@@ -7,7 +9,7 @@ Particularly useful for packages like [rework-calc](https://github.com/reworkcss
## Installation
```console
-$ npm install reduce-css-calc
+npm install reduce-css-calc
```
## Usage
@@ -54,17 +56,19 @@ reduceCSSCalc("-moz-calc(50% - 2em)")
// -moz-calc(50% - 2em)
```
-See [unit tests](test/index.js) for others examples.
+See [unit tests](src/__tests__/index.js) for others examples.
+
+---
## Contributing
Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature.
```console
-$ git clone https://github.com/MoOx/reduce-css-calc.git
-$ git checkout -b patch-1
-$ npm install
-$ npm test
+git clone https://github.com/MoOx/reduce-css-calc.git
+git checkout -b patch-1
+npm install
+npm test
```
## [Changelog](CHANGELOG.md)
diff --git a/node_modules/reduce-css-calc/dist/index.js b/node_modules/reduce-css-calc/dist/index.js
new file mode 100644
index 00000000..0a69bf38
--- /dev/null
+++ b/node_modules/reduce-css-calc/dist/index.js
@@ -0,0 +1,51 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _postcssValueParser = require('postcss-value-parser');
+
+var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser);
+
+var _parser = require('./parser');
+
+var _reducer = require('./lib/reducer');
+
+var _reducer2 = _interopRequireDefault(_reducer);
+
+var _stringifier = require('./lib/stringifier');
+
+var _stringifier2 = _interopRequireDefault(_stringifier);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+// eslint-disable-line
+var MATCH_CALC = /((?:\-[a-z]+\-)?calc)/;
+
+exports.default = function (value) {
+ var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
+
+ return (0, _postcssValueParser2.default)(value).walk(function (node) {
+ // skip anything which isn't a calc() function
+ if (node.type !== 'function' || !MATCH_CALC.test(node.value)) return;
+
+ // stringify calc expression and produce an AST
+ var contents = _postcssValueParser2.default.stringify(node.nodes);
+
+ // skip constant() and env()
+ if (contents.indexOf('constant') >= 0 || contents.indexOf('env') >= 0) return;
+
+ var ast = _parser.parser.parse(contents);
+
+ // reduce AST to its simplest form, that is, either to a single value
+ // or a simplified calc expression
+ var reducedAst = (0, _reducer2.default)(ast, precision);
+
+ // stringify AST and write it back
+ node.type = 'word';
+ node.value = (0, _stringifier2.default)(node.value, reducedAst, precision);
+ }, true).toString();
+};
+
+module.exports = exports['default']; \ No newline at end of file
diff --git a/node_modules/reduce-css-calc/dist/lib/convert.js b/node_modules/reduce-css-calc/dist/lib/convert.js
new file mode 100644
index 00000000..3e5815ff
--- /dev/null
+++ b/node_modules/reduce-css-calc/dist/lib/convert.js
@@ -0,0 +1,38 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _cssUnitConverter = require('css-unit-converter');
+
+var _cssUnitConverter2 = _interopRequireDefault(_cssUnitConverter);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function convertNodes(left, right, precision) {
+ switch (left.type) {
+ case 'LengthValue':
+ case 'AngleValue':
+ case 'TimeValue':
+ case 'FrequencyValue':
+ case 'ResolutionValue':
+ return convertAbsoluteLength(left, right, precision);
+ default:
+ return { left: left, right: right };
+ }
+}
+
+function convertAbsoluteLength(left, right, precision) {
+ if (right.type === left.type) {
+ right = {
+ type: left.type,
+ value: (0, _cssUnitConverter2.default)(right.value, right.unit, left.unit, precision),
+ unit: left.unit
+ };
+ }
+ return { left: left, right: right };
+}
+
+exports.default = convertNodes;
+module.exports = exports['default']; \ No newline at end of file
diff --git a/node_modules/reduce-css-calc/dist/lib/reducer.js b/node_modules/reduce-css-calc/dist/lib/reducer.js
new file mode 100644
index 00000000..a3d6cce9
--- /dev/null
+++ b/node_modules/reduce-css-calc/dist/lib/reducer.js
@@ -0,0 +1,258 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.flip = flip;
+
+var _convert = require("./convert");
+
+var _convert2 = _interopRequireDefault(_convert);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function reduce(node, precision) {
+ if (node.type === "MathExpression") return reduceMathExpression(node, precision);
+ if (node.type === "Calc") return reduce(node.value, precision);
+
+ return node;
+}
+
+function isEqual(left, right) {
+ return left.type === right.type && left.value === right.value;
+}
+
+function isValueType(type) {
+ switch (type) {
+ case 'LengthValue':
+ case 'AngleValue':
+ case 'TimeValue':
+ case 'FrequencyValue':
+ case 'ResolutionValue':
+ case 'EmValue':
+ case 'ExValue':
+ case 'ChValue':
+ case 'RemValue':
+ case 'VhValue':
+ case 'VwValue':
+ case 'VminValue':
+ case 'VmaxValue':
+ case 'PercentageValue':
+ case 'Value':
+ return true;
+ }
+ return false;
+}
+
+function convertMathExpression(node, precision) {
+ var nodes = (0, _convert2.default)(node.left, node.right, precision);
+ var left = reduce(nodes.left, precision);
+ var right = reduce(nodes.right, precision);
+
+ if (left.type === "MathExpression" && right.type === "MathExpression") {
+
+ if (left.operator === '/' && right.operator === '*' || left.operator === '-' && right.operator === '+' || left.operator === '*' && right.operator === '/' || left.operator === '+' && right.operator === '-') {
+
+ if (isEqual(left.right, right.right)) nodes = (0, _convert2.default)(left.left, right.left, precision);else if (isEqual(left.right, right.left)) nodes = (0, _convert2.default)(left.left, right.right, precision);
+
+ left = reduce(nodes.left, precision);
+ right = reduce(nodes.right, precision);
+ }
+ }
+
+ node.left = left;
+ node.right = right;
+ return node;
+}
+
+function flip(operator) {
+ return operator === '+' ? '-' : '+';
+}
+
+function flipValue(node) {
+ if (isValueType(node.type)) node.value = -node.value;else if (node.type == 'MathExpression') {
+ node.left = flipValue(node.left);
+ node.right = flipValue(node.right);
+ }
+ return node;
+}
+
+function reduceAddSubExpression(node, precision) {
+ var _node = node,
+ left = _node.left,
+ right = _node.right,
+ op = _node.operator;
+
+
+ if (left.type === 'CssVariable' || right.type === 'CssVariable') return node;
+
+ // something + 0 => something
+ // something - 0 => something
+ if (right.value === 0) return left;
+
+ // 0 + something => something
+ if (left.value === 0 && op === "+") return right;
+
+ // 0 - something => -something
+ if (left.value === 0 && op === "-") return flipValue(right);
+
+ // value + value
+ // value - value
+ if (left.type === right.type && isValueType(left.type)) {
+ node = Object.assign({}, left);
+ if (op === "+") node.value = left.value + right.value;else node.value = left.value - right.value;
+ }
+
+ // value <op> (expr)
+ if (isValueType(left.type) && (right.operator === '+' || right.operator === '-') && right.type === 'MathExpression') {
+ // value + (value + something) => (value + value) + something
+ // value + (value - something) => (value + value) - something
+ // value - (value + something) => (value - value) - something
+ // value - (value - something) => (value - value) + something
+ if (left.type === right.left.type) {
+ node = Object.assign({}, node);
+ node.left = reduce({
+ type: 'MathExpression',
+ operator: op,
+ left: left,
+ right: right.left
+ }, precision);
+ node.right = right.right;
+ node.operator = op === '-' ? flip(right.operator) : right.operator;
+ return reduce(node, precision);
+ }
+ // value + (something + value) => (value + value) + something
+ // value + (something - value) => (value - value) + something
+ // value - (something + value) => (value - value) - something
+ // value - (something - value) => (value + value) - something
+ else if (left.type === right.right.type) {
+ node = Object.assign({}, node);
+ node.left = reduce({
+ type: 'MathExpression',
+ operator: op === '-' ? flip(right.operator) : right.operator,
+ left: left,
+ right: right.right
+ }, precision);
+ node.right = right.left;
+ return reduce(node, precision);
+ }
+ }
+
+ // (expr) <op> value
+ if (left.type === 'MathExpression' && (left.operator === '+' || left.operator === '-') && isValueType(right.type)) {
+ // (value + something) + value => (value + value) + something
+ // (value - something) + value => (value + value) - something
+ // (value + something) - value => (value - value) + something
+ // (value - something) - value => (value - value) - something
+ if (right.type === left.left.type) {
+ node = Object.assign({}, left);
+ node.left = reduce({
+ type: 'MathExpression',
+ operator: op,
+ left: left.left,
+ right: right
+ }, precision);
+ return reduce(node, precision);
+ }
+ // (something + value) + value => something + (value + value)
+ // (something - value1) + value2 => something - (value2 - value1)
+ // (something + value) - value => something + (value - value)
+ // (something - value) - value => something - (value + value)
+ else if (right.type === left.right.type) {
+ node = Object.assign({}, left);
+ if (left.operator === '-') {
+ node.right = reduce({
+ type: 'MathExpression',
+ operator: op === '-' ? '+' : '-',
+ left: right,
+ right: left.right
+ }, precision);
+ node.operator = op === '-' ? '-' : '+';
+ } else {
+ node.right = reduce({
+ type: 'MathExpression',
+ operator: op,
+ left: left.right,
+ right: right
+ }, precision);
+ }
+ if (node.right.value < 0) {
+ node.right.value *= -1;
+ node.operator = node.operator === '-' ? '+' : '-';
+ }
+ return reduce(node, precision);
+ }
+ }
+ return node;
+}
+
+function reduceDivisionExpression(node, precision) {
+ if (!isValueType(node.right.type)) return node;
+
+ if (node.right.type !== 'Value') throw new Error("Cannot divide by \"" + node.right.unit + "\", number expected");
+
+ if (node.right.value === 0) throw new Error('Cannot divide by zero');
+
+ // (expr) / value
+ if (node.left.type === 'MathExpression') {
+ if (isValueType(node.left.left.type) && isValueType(node.left.right.type)) {
+ node.left.left.value /= node.right.value;
+ node.left.right.value /= node.right.value;
+ return reduce(node.left, precision);
+ }
+ return node;
+ }
+ // something / value
+ else if (isValueType(node.left.type)) {
+ node.left.value /= node.right.value;
+ return node.left;
+ }
+ return node;
+}
+
+function reduceMultiplicationExpression(node) {
+ // (expr) * value
+ if (node.left.type === 'MathExpression' && node.right.type === 'Value') {
+ if (isValueType(node.left.left.type) && isValueType(node.left.right.type)) {
+ node.left.left.value *= node.right.value;
+ node.left.right.value *= node.right.value;
+ return node.left;
+ }
+ }
+ // something * value
+ else if (isValueType(node.left.type) && node.right.type === 'Value') {
+ node.left.value *= node.right.value;
+ return node.left;
+ }
+ // value * (expr)
+ else if (node.left.type === 'Value' && node.right.type === 'MathExpression') {
+ if (isValueType(node.right.left.type) && isValueType(node.right.right.type)) {
+ node.right.left.value *= node.left.value;
+ node.right.right.value *= node.left.value;
+ return node.right;
+ }
+ }
+ // value * something
+ else if (node.left.type === 'Value' && isValueType(node.right.type)) {
+ node.right.value *= node.left.value;
+ return node.right;
+ }
+ return node;
+}
+
+function reduceMathExpression(node, precision) {
+ node = convertMathExpression(node, precision);
+
+ switch (node.operator) {
+ case "+":
+ case "-":
+ return reduceAddSubExpression(node, precision);
+ case "/":
+ return reduceDivisionExpression(node, precision);
+ case "*":
+ return reduceMultiplicationExpression(node);
+ }
+ return node;
+}
+
+exports.default = reduce; \ No newline at end of file
diff --git a/node_modules/reduce-css-calc/dist/lib/stringifier.js b/node_modules/reduce-css-calc/dist/lib/stringifier.js
new file mode 100644
index 00000000..92e76326
--- /dev/null
+++ b/node_modules/reduce-css-calc/dist/lib/stringifier.js
@@ -0,0 +1,78 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (calc, node, precision) {
+ var str = stringify(node, precision);
+
+ if (node.type === "MathExpression") {
+ // if calc expression couldn't be resolved to a single value, re-wrap it as
+ // a calc()
+ str = calc + "(" + str + ")";
+ }
+ return str;
+};
+
+var _reducer = require("./reducer");
+
+var order = {
+ "*": 0,
+ "/": 0,
+ "+": 1,
+ "-": 1
+};
+
+function round(value, prec) {
+ if (prec !== false) {
+ var precision = Math.pow(10, prec);
+ return Math.round(value * precision) / precision;
+ }
+ return value;
+}
+
+function stringify(node, prec) {
+ switch (node.type) {
+ case "MathExpression":
+ {
+ var left = node.left,
+ right = node.right,
+ op = node.operator;
+
+ var str = "";
+
+ if (left.type === 'MathExpression' && order[op] < order[left.operator]) str += "(" + stringify(left, prec) + ")";else str += stringify(left, prec);
+
+ str += " " + node.operator + " ";
+
+ if (right.type === 'MathExpression' && order[op] < order[right.operator]) {
+ str += "(" + stringify(right, prec) + ")";
+ } else if (right.type === 'MathExpression' && op === "-" && ["+", "-"].includes(right.operator)) {
+ // fix #52 : a-(b+c) = a-b-c
+ right.operator = (0, _reducer.flip)(right.operator);
+ str += stringify(right, prec);
+ } else {
+ str += stringify(right, prec);
+ }
+
+ return str;
+ }
+ case "Value":
+ return round(node.value, prec);
+ case 'CssVariable':
+ if (node.fallback) {
+ return "var(" + node.value + ", " + stringify(node.fallback, prec, true) + ")";
+ }
+ return "var(" + node.value + ")";
+ case 'Calc':
+ if (node.prefix) {
+ return "-" + node.prefix + "-calc(" + stringify(node.value, prec) + ")";
+ }
+ return "calc(" + stringify(node.value, prec) + ")";
+ default:
+ return round(node.value, prec) + node.unit;
+ }
+}
+
+module.exports = exports["default"]; \ No newline at end of file
diff --git a/node_modules/reduce-css-calc/dist/parser.js b/node_modules/reduce-css-calc/dist/parser.js
new file mode 100644
index 00000000..6d6847ff
--- /dev/null
+++ b/node_modules/reduce-css-calc/dist/parser.js
@@ -0,0 +1,3858 @@
+
+/* parser generated by jison 0.6.1-215 */
+
+/*
+ * Returns a Parser object of the following structure:
+ *
+ * Parser: {
+ * yy: {} The so-called "shared state" or rather the *source* of it;
+ * the real "shared state" `yy` passed around to
+ * the rule actions, etc. is a derivative/copy of this one,
+ * not a direct reference!
+ * }
+ *
+ * Parser.prototype: {
+ * yy: {},
+ * EOF: 1,
+ * TERROR: 2,
+ *
+ * trace: function(errorMessage, ...),
+ *
+ * JisonParserError: function(msg, hash),
+ *
+ * quoteName: function(name),
+ * Helper function which can be overridden by user code later on: put suitable
+ * quotes around literal IDs in a description string.
+ *
+ * originalQuoteName: function(name),
+ * The basic quoteName handler provided by JISON.
+ * `cleanupAfterParse()` will clean up and reset `quoteName()` to reference this function
+ * at the end of the `parse()`.
+ *
+ * describeSymbol: function(symbol),
+ * Return a more-or-less human-readable description of the given symbol, when
+ * available, or the symbol itself, serving as its own 'description' for lack
+ * of something better to serve up.
+ *
+ * Return NULL when the symbol is unknown to the parser.
+ *
+ * symbols_: {associative list: name ==> number},
+ * terminals_: {associative list: number ==> name},
+ * nonterminals: {associative list: rule-name ==> {associative list: number ==> rule-alt}},
+ * terminal_descriptions_: (if there are any) {associative list: number ==> description},
+ * productions_: [...],
+ *
+ * performAction: function parser__performAction(yytext, yyleng, yylineno, yyloc, yystate, yysp, yyvstack, yylstack, yystack, yysstack),
+ *
+ * The function parameters and `this` have the following value/meaning:
+ * - `this` : reference to the `yyval` internal object, which has members (`$` and `_$`)
+ * to store/reference the rule value `$$` and location info `@$`.
+ *
+ * One important thing to note about `this` a.k.a. `yyval`: every *reduce* action gets
+ * to see the same object via the `this` reference, i.e. if you wish to carry custom
+ * data from one reduce action through to the next within a single parse run, then you
+ * may get nasty and use `yyval` a.k.a. `this` for storing you own semi-permanent data.
+ *
+ * `this.yy` is a direct reference to the `yy` shared state object.
+ *
+ * `%parse-param`-specified additional `parse()` arguments have been added to this `yy`
+ * object at `parse()` start and are therefore available to the action code via the
+ * same named `yy.xxxx` attributes (where `xxxx` represents a identifier name from
+ * the %parse-param` list.
+ *
+ * - `yytext` : reference to the lexer value which belongs to the last lexer token used
+ * to match this rule. This is *not* the look-ahead token, but the last token
+ * that's actually part of this rule.
+ *
+ * Formulated another way, `yytext` is the value of the token immediately preceeding
+ * the current look-ahead token.
+ * Caveats apply for rules which don't require look-ahead, such as epsilon rules.
+ *
+ * - `yyleng` : ditto as `yytext`, only now for the lexer.yyleng value.
+ *
+ * - `yylineno`: ditto as `yytext`, only now for the lexer.yylineno value.
+ *
+ * - `yyloc` : ditto as `yytext`, only now for the lexer.yylloc lexer token location info.
+ *
+ * WARNING: since jison 0.4.18-186 this entry may be NULL/UNDEFINED instead
+ * of an empty object when no suitable location info can be provided.
+ *
+ * - `yystate` : the current parser state number, used internally for dispatching and
+ * executing the action code chunk matching the rule currently being reduced.
+ *
+ * - `yysp` : the current state stack position (a.k.a. 'stack pointer')
+ *
+ * This one comes in handy when you are going to do advanced things to the parser
+ * stacks, all of which are accessible from your action code (see the next entries below).
+ *
+ * Also note that you can access this and other stack index values using the new double-hash
+ * syntax, i.e. `##$ === ##0 === yysp`, while `##1` is the stack index for all things
+ * related to the first rule term, just like you have `$1`, `@1` and `#1`.
+ * This is made available to write very advanced grammar action rules, e.g. when you want
+ * to investigate the parse state stack in your action code, which would, for example,
+ * be relevant when you wish to implement error diagnostics and reporting schemes similar
+ * to the work described here:
+ *
+ * + Pottier, F., 2016. Reachability and error diagnosis in LR(1) automata.
+ * In Journées Francophones des Languages Applicatifs.
+ *
+ * + Jeffery, C.L., 2003. Generating LR syntax error messages from examples.
+ * ACM Transactions on Programming Languages and Systems (TOPLAS), 25(5), pp.631–640.
+ *
+ * - `yyrulelength`: the current rule's term count, i.e. the number of entries occupied on the stack.
+ *
+ * This one comes in handy when you are going to do advanced things to the parser
+ * stacks, all of which are accessible from your action code (see the next entries below).
+ *
+ * - `yyvstack`: reference to the parser value stack. Also accessed via the `$1` etc.
+ * constructs.
+ *
+ * - `yylstack`: reference to the parser token location stack. Also accessed via
+ * the `@1` etc. constructs.
+ *
+ * WARNING: since jison 0.4.18-186 this array MAY contain slots which are
+ * UNDEFINED rather than an empty (location) object, when the lexer/parser
+ * action code did not provide a suitable location info object when such a
+ * slot was filled!
+ *
+ * - `yystack` : reference to the parser token id stack. Also accessed via the
+ * `#1` etc. constructs.
+ *
+ * Note: this is a bit of a **white lie** as we can statically decode any `#n` reference to
+ * its numeric token id value, hence that code wouldn't need the `yystack` but *you* might
+ * want access this array for your own purposes, such as error analysis as mentioned above!
+ *
+ * Note that this stack stores the current stack of *tokens*, that is the sequence of
+ * already parsed=reduced *nonterminals* (tokens representing rules) and *terminals*
+ * (lexer tokens *shifted* onto the stack until the rule they belong to is found and
+ * *reduced*.
+ *
+ * - `yysstack`: reference to the parser state stack. This one carries the internal parser
+ * *states* such as the one in `yystate`, which are used to represent
+ * the parser state machine in the *parse table*. *Very* *internal* stuff,
+ * what can I say? If you access this one, you're clearly doing wicked things
+ *
+ * - `...` : the extra arguments you specified in the `%parse-param` statement in your
+ * grammar definition file.
+ *
+ * table: [...],
+ * State transition table
+ * ----------------------
+ *
+ * index levels are:
+ * - `state` --> hash table
+ * - `symbol` --> action (number or array)
+ *
+ * If the `action` is an array, these are the elements' meaning:
+ * - index [0]: 1 = shift, 2 = reduce, 3 = accept
+ * - index [1]: GOTO `state`
+ *
+ * If the `action` is a number, it is the GOTO `state`
+ *
+ * defaultActions: {...},
+ *
+ * parseError: function(str, hash, ExceptionClass),
+ * yyError: function(str, ...),
+ * yyRecovering: function(),
+ * yyErrOk: function(),
+ * yyClearIn: function(),
+ *
+ * constructParseErrorInfo: function(error_message, exception_object, expected_token_set, is_recoverable),
+ * Helper function **which will be set up during the first invocation of the `parse()` method**.
+ * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.
+ * See it's use in this parser kernel in many places; example usage:
+ *
+ * var infoObj = parser.constructParseErrorInfo('fail!', null,
+ * parser.collect_expected_token_set(state), true);
+ * var retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError);
+ *
+ * originalParseError: function(str, hash, ExceptionClass),
+ * The basic `parseError` handler provided by JISON.
+ * `cleanupAfterParse()` will clean up and reset `parseError()` to reference this function
+ * at the end of the `parse()`.
+ *
+ * options: { ... parser %options ... },
+ *
+ * parse: function(input[, args...]),
+ * Parse the given `input` and return the parsed value (or `true` when none was provided by
+ * the root action, in which case the parser is acting as a *matcher*).
+ * You MAY use the additional `args...` parameters as per `%parse-param` spec of this grammar:
+ * these extra `args...` are added verbatim to the `yy` object reference as member variables.
+ *
+ * WARNING:
+ * Parser's additional `args...` parameters (via `%parse-param`) MAY conflict with
+ * any attributes already added to `yy` by the jison run-time;
+ * when such a collision is detected an exception is thrown to prevent the generated run-time
+ * from silently accepting this confusing and potentially hazardous situation!
+ *
+ * The lexer MAY add its own set of additional parameters (via the `%parse-param` line in
+ * the lexer section of the grammar spec): these will be inserted in the `yy` shared state
+ * object and any collision with those will be reported by the lexer via a thrown exception.
+ *
+ * cleanupAfterParse: function(resultValue, invoke_post_methods, do_not_nuke_errorinfos),
+ * Helper function **which will be set up during the first invocation of the `parse()` method**.
+ * This helper API is invoked at the end of the `parse()` call, unless an exception was thrown
+ * and `%options no-try-catch` has been defined for this grammar: in that case this helper MAY
+ * be invoked by calling user code to ensure the `post_parse` callbacks are invoked and
+ * the internal parser gets properly garbage collected under these particular circumstances.
+ *
+ * yyMergeLocationInfo: function(first_index, last_index, first_yylloc, last_yylloc, dont_look_back),
+ * Helper function **which will be set up during the first invocation of the `parse()` method**.
+ * This helper API can be invoked to calculate a spanning `yylloc` location info object.
+ *
+ * Note: %epsilon rules MAY specify no `first_index` and `first_yylloc`, in which case
+ * this function will attempt to obtain a suitable location marker by inspecting the location stack
+ * backwards.
+ *
+ * For more info see the documentation comment further below, immediately above this function's
+ * implementation.
+ *
+ * lexer: {
+ * yy: {...}, A reference to the so-called "shared state" `yy` once
+ * received via a call to the `.setInput(input, yy)` lexer API.
+ * EOF: 1,
+ * ERROR: 2,
+ * JisonLexerError: function(msg, hash),
+ * parseError: function(str, hash, ExceptionClass),
+ * setInput: function(input, [yy]),
+ * input: function(),
+ * unput: function(str),
+ * more: function(),
+ * reject: function(),
+ * less: function(n),
+ * pastInput: function(n),
+ * upcomingInput: function(n),
+ * showPosition: function(),
+ * test_match: function(regex_match_array, rule_index, ...),
+ * next: function(...),
+ * lex: function(...),
+ * begin: function(condition),
+ * pushState: function(condition),
+ * popState: function(),
+ * topState: function(),
+ * _currentRules: function(),
+ * stateStackSize: function(),
+ * cleanupAfterLex: function()
+ *
+ * options: { ... lexer %options ... },
+ *
+ * performAction: function(yy, yy_, $avoiding_name_collisions, YY_START, ...),
+ * rules: [...],
+ * conditions: {associative list: name ==> set},
+ * }
+ * }
+ *
+ *
+ * token location info (@$, _$, etc.): {
+ * first_line: n,
+ * last_line: n,
+ * first_column: n,
+ * last_column: n,
+ * range: [start_number, end_number]
+ * (where the numbers are indexes into the input string, zero-based)
+ * }
+ *
+ * ---
+ *
+ * The `parseError` function receives a 'hash' object with these members for lexer and
+ * parser errors:
+ *
+ * {
+ * text: (matched text)
+ * token: (the produced terminal token, if any)
+ * token_id: (the produced terminal token numeric ID, if any)
+ * line: (yylineno)
+ * loc: (yylloc)
+ * }
+ *
+ * parser (grammar) errors will also provide these additional members:
+ *
+ * {
+ * expected: (array describing the set of expected tokens;
+ * may be UNDEFINED when we cannot easily produce such a set)
+ * state: (integer (or array when the table includes grammar collisions);
+ * represents the current internal state of the parser kernel.
+ * can, for example, be used to pass to the `collect_expected_token_set()`
+ * API to obtain the expected token set)
+ * action: (integer; represents the current internal action which will be executed)
+ * new_state: (integer; represents the next/planned internal state, once the current
+ * action has executed)
+ * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule
+ * available for this particular error)
+ * state_stack: (array: the current parser LALR/LR internal state stack; this can be used,
+ * for instance, for advanced error analysis and reporting)
+ * value_stack: (array: the current parser LALR/LR internal `$$` value stack; this can be used,
+ * for instance, for advanced error analysis and reporting)
+ * location_stack: (array: the current parser LALR/LR internal location stack; this can be used,
+ * for instance, for advanced error analysis and reporting)
+ * yy: (object: the current parser internal "shared state" `yy`
+ * as is also available in the rule actions; this can be used,
+ * for instance, for advanced error analysis and reporting)
+ * lexer: (reference to the current lexer instance used by the parser)
+ * parser: (reference to the current parser instance)
+ * }
+ *
+ * while `this` will reference the current parser instance.
+ *
+ * When `parseError` is invoked by the lexer, `this` will still reference the related *parser*
+ * instance, while these additional `hash` fields will also be provided:
+ *
+ * {
+ * lexer: (reference to the current lexer instance which reported the error)
+ * }
+ *
+ * When `parseError` is invoked by the parser due to a **JavaScript exception** being fired
+ * from either the parser or lexer, `this` will still reference the related *parser*
+ * instance, while these additional `hash` fields will also be provided:
+ *
+ * {
+ * exception: (reference to the exception thrown)
+ * }
+ *
+ * Please do note that in the latter situation, the `expected` field will be omitted as
+ * this type of failure is assumed not to be due to *parse errors* but rather due to user
+ * action code in either parser or lexer failing unexpectedly.
+ *
+ * ---
+ *
+ * You can specify parser options by setting / modifying the `.yy` object of your Parser instance.
+ * These options are available:
+ *
+ * ### options which are global for all parser instances
+ *
+ * Parser.pre_parse: function(yy)
+ * optional: you can specify a pre_parse() function in the chunk following
+ * the grammar, i.e. after the last `%%`.
+ * Parser.post_parse: function(yy, retval, parseInfo) { return retval; }
+ * optional: you can specify a post_parse() function in the chunk following
+ * the grammar, i.e. after the last `%%`. When it does not return any value,
+ * the parser will return the original `retval`.
+ *
+ * ### options which can be set up per parser instance
+ *
+ * yy: {
+ * pre_parse: function(yy)
+ * optional: is invoked before the parse cycle starts (and before the first
+ * invocation of `lex()`) but immediately after the invocation of
+ * `parser.pre_parse()`).
+ * post_parse: function(yy, retval, parseInfo) { return retval; }
+ * optional: is invoked when the parse terminates due to success ('accept')
+ * or failure (even when exceptions are thrown).
+ * `retval` contains the return value to be produced by `Parser.parse()`;
+ * this function can override the return value by returning another.
+ * When it does not return any value, the parser will return the original
+ * `retval`.
+ * This function is invoked immediately before `parser.post_parse()`.
+ *
+ * parseError: function(str, hash, ExceptionClass)
+ * optional: overrides the default `parseError` function.
+ * quoteName: function(name),
+ * optional: overrides the default `quoteName` function.
+ * }
+ *
+ * parser.lexer.options: {
+ * pre_lex: function()
+ * optional: is invoked before the lexer is invoked to produce another token.
+ * `this` refers to the Lexer object.
+ * post_lex: function(token) { return token; }
+ * optional: is invoked when the lexer has produced a token `token`;
+ * this function can override the returned token value by returning another.
+ * When it does not return any (truthy) value, the lexer will return
+ * the original `token`.
+ * `this` refers to the Lexer object.
+ *
+ * ranges: boolean
+ * optional: `true` ==> token location info will include a .range[] member.
+ * flex: boolean
+ * optional: `true` ==> flex-like lexing behaviour where the rules are tested
+ * exhaustively to find the longest match.
+ * backtrack_lexer: boolean
+ * optional: `true` ==> lexer regexes are tested in order and for invoked;
+ * the lexer terminates the scan when a token is returned by the action code.
+ * xregexp: boolean
+ * optional: `true` ==> lexer rule regexes are "extended regex format" requiring the
+ * `XRegExp` library. When this `%option` has not been specified at compile time, all lexer
+ * rule regexes have been written as standard JavaScript RegExp expressions.
+ * }
+ */
+
+
+
+ var parser = (function () {
+
+
+// See also:
+// http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508
+// but we keep the prototype.constructor and prototype.name assignment lines too for compatibility
+// with userland code which might access the derived class in a 'classic' way.
+function JisonParserError(msg, hash) {
+ Object.defineProperty(this, 'name', {
+ enumerable: false,
+ writable: false,
+ value: 'JisonParserError'
+ });
+
+ if (msg == null) msg = '???';
+
+ Object.defineProperty(this, 'message', {
+ enumerable: false,
+ writable: true,
+ value: msg
+ });
+
+ this.hash = hash;
+
+ var stacktrace;
+ if (hash && hash.exception instanceof Error) {
+ var ex2 = hash.exception;
+ this.message = ex2.message || msg;
+ stacktrace = ex2.stack;
+ }
+ if (!stacktrace) {
+ if (Error.hasOwnProperty('captureStackTrace')) { // V8/Chrome engine
+ Error.captureStackTrace(this, this.constructor);
+ } else {
+ stacktrace = (new Error(msg)).stack;
+ }
+ }
+ if (stacktrace) {
+ Object.defineProperty(this, 'stack', {
+ enumerable: false,
+ writable: false,
+ value: stacktrace
+ });
+ }
+}
+
+if (typeof Object.setPrototypeOf === 'function') {
+ Object.setPrototypeOf(JisonParserError.prototype, Error.prototype);
+} else {
+ JisonParserError.prototype = Object.create(Error.prototype);
+}
+JisonParserError.prototype.constructor = JisonParserError;
+JisonParserError.prototype.name = 'JisonParserError';
+
+
+
+
+ // helper: reconstruct the productions[] table
+ function bp(s) {
+ var rv = [];
+ var p = s.pop;
+ var r = s.rule;
+ for (var i = 0, l = p.length; i < l; i++) {
+ rv.push([
+ p[i],
+ r[i]
+ ]);
+ }
+ return rv;
+ }
+
+
+
+ // helper: reconstruct the defaultActions[] table
+ function bda(s) {
+ var rv = {};
+ var d = s.idx;
+ var g = s.goto;
+ for (var i = 0, l = d.length; i < l; i++) {
+ var j = d[i];
+ rv[j] = g[i];
+ }
+ return rv;
+ }
+
+
+
+ // helper: reconstruct the 'goto' table
+ function bt(s) {
+ var rv = [];
+ var d = s.len;
+ var y = s.symbol;
+ var t = s.type;
+ var a = s.state;
+ var m = s.mode;
+ var g = s.goto;
+ for (var i = 0, l = d.length; i < l; i++) {
+ var n = d[i];
+ var q = {};
+ for (var j = 0; j < n; j++) {
+ var z = y.shift();
+ switch (t.shift()) {
+ case 2:
+ q[z] = [
+ m.shift(),
+ g.shift()
+ ];
+ break;
+
+ case 0:
+ q[z] = a.shift();
+ break;
+
+ default:
+ // type === 1: accept
+ q[z] = [
+ 3
+ ];
+ }
+ }
+ rv.push(q);
+ }
+ return rv;
+ }
+
+
+
+ // helper: runlength encoding with increment step: code, length: step (default step = 0)
+ // `this` references an array
+ function s(c, l, a) {
+ a = a || 0;
+ for (var i = 0; i < l; i++) {
+ this.push(c);
+ c += a;
+ }
+ }
+
+ // helper: duplicate sequence from *relative* offset and length.
+ // `this` references an array
+ function c(i, l) {
+ i = this.length - i;
+ for (l += i; i < l; i++) {
+ this.push(this[i]);
+ }
+ }
+
+ // helper: unpack an array using helpers and data, all passed in an array argument 'a'.
+ function u(a) {
+ var rv = [];
+ for (var i = 0, l = a.length; i < l; i++) {
+ var e = a[i];
+ // Is this entry a helper function?
+ if (typeof e === 'function') {
+ i++;
+ e.apply(rv, a[i]);
+ } else {
+ rv.push(e);
+ }
+ }
+ return rv;
+ }
+
+
+var parser = {
+ // Code Generator Information Report
+ // ---------------------------------
+ //
+ // Options:
+ //
+ // default action mode: ............. ["classic","merge"]
+ // test-compile action mode: ........ "parser:*,lexer:*"
+ // try..catch: ...................... true
+ // default resolve on conflict: ..... true
+ // on-demand look-ahead: ............ false
+ // error recovery token skip maximum: 3
+ // yyerror in parse actions is: ..... NOT recoverable,
+ // yyerror in lexer actions and other non-fatal lexer are:
+ // .................................. NOT recoverable,
+ // debug grammar/output: ............ false
+ // has partial LR conflict upgrade: true
+ // rudimentary token-stack support: false
+ // parser table compression mode: ... 2
+ // export debug tables: ............. false
+ // export *all* tables: ............. false
+ // module type: ..................... commonjs
+ // parser engine type: .............. lalr
+ // output main() in the module: ..... true
+ // has user-specified main(): ....... false
+ // has user-specified require()/import modules for main():
+ // .................................. false
+ // number of expected conflicts: .... 0
+ //
+ //
+ // Parser Analysis flags:
+ //
+ // no significant actions (parser is a language matcher only):
+ // .................................. false
+ // uses yyleng: ..................... false
+ // uses yylineno: ................... false
+ // uses yytext: ..................... false
+ // uses yylloc: ..................... false
+ // uses ParseError API: ............. false
+ // uses YYERROR: .................... false
+ // uses YYRECOVERING: ............... false
+ // uses YYERROK: .................... false
+ // uses YYCLEARIN: .................. false
+ // tracks rule values: .............. true
+ // assigns rule values: ............. true
+ // uses location tracking: .......... false
+ // assigns location: ................ false
+ // uses yystack: .................... false
+ // uses yysstack: ................... false
+ // uses yysp: ....................... true
+ // uses yyrulelength: ............... false
+ // uses yyMergeLocationInfo API: .... false
+ // has error recovery: .............. false
+ // has error reporting: ............. false
+ //
+ // --------- END OF REPORT -----------
+
+trace: function no_op_trace() { },
+JisonParserError: JisonParserError,
+yy: {},
+options: {
+ type: "lalr",
+ hasPartialLrUpgradeOnConflict: true,
+ errorRecoveryTokenDiscardCount: 3
+},
+symbols_: {
+ "$accept": 0,
+ "$end": 1,
+ "ADD": 3,
+ "ANGLE": 16,
+ "CHS": 22,
+ "COMMA": 14,
+ "CSS_CPROP": 13,
+ "CSS_VAR": 12,
+ "DIV": 6,
+ "EMS": 20,
+ "EOF": 1,
+ "EXS": 21,
+ "FREQ": 18,
+ "LENGTH": 15,
+ "LPAREN": 7,
+ "MUL": 5,
+ "NESTED_CALC": 9,
+ "NUMBER": 11,
+ "PERCENTAGE": 28,
+ "PREFIX": 10,
+ "REMS": 23,
+ "RES": 19,
+ "RPAREN": 8,
+ "SUB": 4,
+ "TIME": 17,
+ "VHS": 24,
+ "VMAXS": 27,
+ "VMINS": 26,
+ "VWS": 25,
+ "css_value": 33,
+ "css_variable": 32,
+ "error": 2,
+ "expression": 29,
+ "math_expression": 30,
+ "value": 31
+},
+terminals_: {
+ 1: "EOF",
+ 2: "error",
+ 3: "ADD",
+ 4: "SUB",
+ 5: "MUL",
+ 6: "DIV",
+ 7: "LPAREN",
+ 8: "RPAREN",
+ 9: "NESTED_CALC",
+ 10: "PREFIX",
+ 11: "NUMBER",
+ 12: "CSS_VAR",
+ 13: "CSS_CPROP",
+ 14: "COMMA",
+ 15: "LENGTH",
+ 16: "ANGLE",
+ 17: "TIME",
+ 18: "FREQ",
+ 19: "RES",
+ 20: "EMS",
+ 21: "EXS",
+ 22: "CHS",
+ 23: "REMS",
+ 24: "VHS",
+ 25: "VWS",
+ 26: "VMINS",
+ 27: "VMAXS",
+ 28: "PERCENTAGE"
+},
+TERROR: 2,
+ EOF: 1,
+
+ // internals: defined here so the object *structure* doesn't get modified by parse() et al,
+ // thus helping JIT compilers like Chrome V8.
+ originalQuoteName: null,
+ originalParseError: null,
+ cleanupAfterParse: null,
+ constructParseErrorInfo: null,
+ yyMergeLocationInfo: null,
+
+ __reentrant_call_depth: 0, // INTERNAL USE ONLY
+ __error_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup
+ __error_recovery_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup
+
+ // APIs which will be set up depending on user action code analysis:
+ //yyRecovering: 0,
+ //yyErrOk: 0,
+ //yyClearIn: 0,
+
+ // Helper APIs
+ // -----------
+
+ // Helper function which can be overridden by user code later on: put suitable quotes around
+ // literal IDs in a description string.
+ quoteName: function parser_quoteName(id_str) {
+ return '"' + id_str + '"';
+ },
+
+ // Return the name of the given symbol (terminal or non-terminal) as a string, when available.
+ //
+ // Return NULL when the symbol is unknown to the parser.
+ getSymbolName: function parser_getSymbolName(symbol) {
+ if (this.terminals_[symbol]) {
+ return this.terminals_[symbol];
+ }
+
+ // Otherwise... this might refer to a RULE token i.e. a non-terminal: see if we can dig that one up.
+ //
+ // An example of this may be where a rule's action code contains a call like this:
+ //
+ // parser.getSymbolName(#$)
+ //
+ // to obtain a human-readable name of the current grammar rule.
+ var s = this.symbols_;
+ for (var key in s) {
+ if (s[key] === symbol) {
+ return key;
+ }
+ }
+ return null;
+ },
+
+ // Return a more-or-less human-readable description of the given symbol, when available,
+ // or the symbol itself, serving as its own 'description' for lack of something better to serve up.
+ //
+ // Return NULL when the symbol is unknown to the parser.
+ describeSymbol: function parser_describeSymbol(symbol) {
+ if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) {
+ return this.terminal_descriptions_[symbol];
+ }
+ else if (symbol === this.EOF) {
+ return 'end of input';
+ }
+ var id = this.getSymbolName(symbol);
+ if (id) {
+ return this.quoteName(id);
+ }
+ return null;
+ },
+
+ // Produce a (more or less) human-readable list of expected tokens at the point of failure.
+ //
+ // The produced list may contain token or token set descriptions instead of the tokens
+ // themselves to help turning this output into something that easier to read by humans
+ // unless `do_not_describe` parameter is set, in which case a list of the raw, *numeric*,
+ // expected terminals and nonterminals is produced.
+ //
+ // The returned list (array) will not contain any duplicate entries.
+ collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) {
+ var TERROR = this.TERROR;
+ var tokenset = [];
+ var check = {};
+ // Has this (error?) state been outfitted with a custom expectations description text for human consumption?
+ // If so, use that one instead of the less palatable token set.
+ if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) {
+ return [
+ this.state_descriptions_[state]
+ ];
+ }
+ for (var p in this.table[state]) {
+ p = +p;
+ if (p !== TERROR) {
+ var d = do_not_describe ? p : this.describeSymbol(p);
+ if (d && !check[d]) {
+ tokenset.push(d);
+ check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries.
+ }
+ }
+ }
+ return tokenset;
+ },
+productions_: bp({
+ pop: u([
+ 29,
+ s,
+ [30, 10],
+ 31,
+ 31,
+ 32,
+ 32,
+ s,
+ [33, 15]
+]),
+ rule: u([
+ 2,
+ s,
+ [3, 5],
+ 4,
+ 7,
+ s,
+ [1, 4],
+ 2,
+ 4,
+ 6,
+ s,
+ [1, 14],
+ 2
+])
+}),
+performAction: function parser__PerformAction(yystate /* action[1] */, yysp, yyvstack) {
+
+ /* this == yyval */
+
+ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code!
+ var yy = this.yy;
+ var yyparser = yy.parser;
+ var yylexer = yy.lexer;
+
+
+
+ switch (yystate) {
+case 0:
+ /*! Production:: $accept : expression $end */
+
+ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-):
+ this.$ = yyvstack[yysp - 1];
+ // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-)
+ break;
+
+case 1:
+ /*! Production:: expression : math_expression EOF */
+
+ // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-):
+ this.$ = yyvstack[yysp - 1];
+ // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-)
+
+
+ return yyvstack[yysp - 1];
+ break;
+
+case 2:
+ /*! Production:: math_expression : math_expression ADD math_expression */
+case 3:
+ /*! Production:: math_expression : math_expression SUB math_expression */
+case 4:
+ /*! Production:: math_expression : math_expression MUL math_expression */
+case 5:
+ /*! Production:: math_expression : math_expression DIV math_expression */
+
+ this.$ = { type: 'MathExpression', operator: yyvstack[yysp - 1], left: yyvstack[yysp - 2], right: yyvstack[yysp] };
+ break;
+
+case 6:
+ /*! Production:: math_expression : LPAREN math_expression RPAREN */
+
+ this.$ = yyvstack[yysp - 1];
+ break;
+
+case 7:
+ /*! Production:: math_expression : NESTED_CALC LPAREN math_expression RPAREN */
+
+ this.$ = { type: 'Calc', value: yyvstack[yysp - 1] };
+ break;
+
+case 8:
+ /*! Production:: math_expression : SUB PREFIX SUB NESTED_CALC LPAREN math_expression RPAREN */
+
+ this.$ = { type: 'Calc', value: yyvstack[yysp - 1], prefix: yyvstack[yysp - 5] };
+ break;
+
+case 9:
+ /*! Production:: math_expression : css_variable */
+case 10:
+ /*! Production:: math_expression : css_value */
+case 11:
+ /*! Production:: math_expression : value */
+
+ this.$ = yyvstack[yysp];
+ break;
+
+case 12:
+ /*! Production:: value : NUMBER */
+
+ this.$ = { type: 'Value', value: parseFloat(yyvstack[yysp]) };
+ break;
+
+case 13:
+ /*! Production:: value : SUB NUMBER */
+
+ this.$ = { type: 'Value', value: parseFloat(yyvstack[yysp]) * -1 };
+ break;
+
+case 14:
+ /*! Production:: css_variable : CSS_VAR LPAREN CSS_CPROP RPAREN */
+
+ this.$ = { type: 'CssVariable', value: yyvstack[yysp - 1] };
+ break;
+
+case 15:
+ /*! Production:: css_variable : CSS_VAR LPAREN CSS_CPROP COMMA math_expression RPAREN */
+
+ this.$ = { type: 'CssVariable', value: yyvstack[yysp - 3], fallback: yyvstack[yysp - 1] };
+ break;
+
+case 16:
+ /*! Production:: css_value : LENGTH */
+
+ this.$ = { type: 'LengthValue', value: parseFloat(yyvstack[yysp]), unit: /[a-z]+/.exec(yyvstack[yysp])[0] };
+ break;
+
+case 17:
+ /*! Production:: css_value : ANGLE */
+
+ this.$ = { type: 'AngleValue', value: parseFloat(yyvstack[yysp]), unit: /[a-z]+/.exec(yyvstack[yysp])[0] };
+ break;
+
+case 18:
+ /*! Production:: css_value : TIME */
+
+ this.$ = { type: 'TimeValue', value: parseFloat(yyvstack[yysp]), unit: /[a-z]+/.exec(yyvstack[yysp])[0] };
+ break;
+
+case 19:
+ /*! Production:: css_value : FREQ */
+
+ this.$ = { type: 'FrequencyValue', value: parseFloat(yyvstack[yysp]), unit: /[a-z]+/.exec(yyvstack[yysp])[0] };
+ break;
+
+case 20:
+ /*! Production:: css_value : RES */
+
+ this.$ = { type: 'ResolutionValue', value: parseFloat(yyvstack[yysp]), unit: /[a-z]+/.exec(yyvstack[yysp])[0] };
+ break;
+
+case 21:
+ /*! Production:: css_value : EMS */
+
+ this.$ = { type: 'EmValue', value: parseFloat(yyvstack[yysp]), unit: 'em' };
+ break;
+
+case 22:
+ /*! Production:: css_value : EXS */
+
+ this.$ = { type: 'ExValue', value: parseFloat(yyvstack[yysp]), unit: 'ex' };
+ break;
+
+case 23:
+ /*! Production:: css_value : CHS */
+
+ this.$ = { type: 'ChValue', value: parseFloat(yyvstack[yysp]), unit: 'ch' };
+ break;
+
+case 24:
+ /*! Production:: css_value : REMS */
+
+ this.$ = { type: 'RemValue', value: parseFloat(yyvstack[yysp]), unit: 'rem' };
+ break;
+
+case 25:
+ /*! Production:: css_value : VHS */
+
+ this.$ = { type: 'VhValue', value: parseFloat(yyvstack[yysp]), unit: 'vh' };
+ break;
+
+case 26:
+ /*! Production:: css_value : VWS */
+
+ this.$ = { type: 'VwValue', value: parseFloat(yyvstack[yysp]), unit: 'vw' };
+ break;
+
+case 27:
+ /*! Production:: css_value : VMINS */
+
+ this.$ = { type: 'VminValue', value: parseFloat(yyvstack[yysp]), unit: 'vmin' };
+ break;
+
+case 28:
+ /*! Production:: css_value : VMAXS */
+
+ this.$ = { type: 'VmaxValue', value: parseFloat(yyvstack[yysp]), unit: 'vmax' };
+ break;
+
+case 29:
+ /*! Production:: css_value : PERCENTAGE */
+
+ this.$ = { type: 'PercentageValue', value: parseFloat(yyvstack[yysp]), unit: '%' };
+ break;
+
+case 30:
+ /*! Production:: css_value : SUB css_value */
+
+ var prev = yyvstack[yysp]; prev.value *= -1; this.$ = prev;
+ break;
+
+}
+},
+table: bt({
+ len: u([
+ 24,
+ 1,
+ 5,
+ 23,
+ 1,
+ 18,
+ s,
+ [0, 3],
+ 1,
+ s,
+ [0, 16],
+ s,
+ [23, 4],
+ c,
+ [28, 3],
+ 0,
+ 0,
+ 16,
+ 1,
+ 6,
+ 6,
+ s,
+ [0, 3],
+ 5,
+ 1,
+ 2,
+ c,
+ [37, 3],
+ c,
+ [20, 3],
+ 5,
+ 0,
+ 0
+]),
+ symbol: u([
+ 4,
+ 7,
+ 9,
+ 11,
+ 12,
+ s,
+ [15, 19, 1],
+ 1,
+ 1,
+ s,
+ [3, 4, 1],
+ c,
+ [30, 19],
+ c,
+ [29, 4],
+ 7,
+ 4,
+ 10,
+ 11,
+ c,
+ [22, 14],
+ c,
+ [19, 3],
+ c,
+ [43, 22],
+ c,
+ [23, 69],
+ c,
+ [139, 4],
+ 8,
+ c,
+ [51, 24],
+ 4,
+ c,
+ [138, 15],
+ 13,
+ c,
+ [186, 5],
+ 8,
+ c,
+ [6, 6],
+ c,
+ [5, 5],
+ 9,
+ 8,
+ 14,
+ c,
+ [159, 47],
+ c,
+ [60, 10]
+]),
+ type: u([
+ s,
+ [2, 19],
+ s,
+ [0, 5],
+ 1,
+ s,
+ [2, 24],
+ s,
+ [0, 4],
+ c,
+ [22, 19],
+ c,
+ [43, 42],
+ c,
+ [23, 70],
+ c,
+ [28, 25],
+ c,
+ [45, 25],
+ c,
+ [113, 54]
+]),
+ state: u([
+ 1,
+ 2,
+ 8,
+ 6,
+ 7,
+ 30,
+ c,
+ [4, 3],
+ 33,
+ 37,
+ c,
+ [5, 3],
+ 38,
+ c,
+ [4, 3],
+ 39,
+ c,
+ [4, 3],
+ 40,
+ c,
+ [4, 3],
+ 42,
+ c,
+ [21, 4],
+ 50,
+ c,
+ [5, 3],
+ 51,
+ c,
+ [4, 3]
+]),
+ mode: u([
+ s,
+ [1, 179],
+ s,
+ [2, 3],
+ c,
+ [5, 5],
+ c,
+ [6, 4],
+ s,
+ [1, 57]
+]),
+ goto: u([
+ 5,
+ 3,
+ 4,
+ 24,
+ s,
+ [9, 15, 1],
+ s,
+ [25, 5, 1],
+ c,
+ [24, 19],
+ 31,
+ 35,
+ 32,
+ 34,
+ c,
+ [18, 14],
+ 36,
+ c,
+ [38, 19],
+ c,
+ [19, 57],
+ c,
+ [118, 4],
+ 41,
+ c,
+ [24, 19],
+ 43,
+ 35,
+ c,
+ [16, 14],
+ 44,
+ s,
+ [2, 3],
+ 28,
+ 29,
+ 2,
+ s,
+ [3, 3],
+ 28,
+ 29,
+ 3,
+ c,
+ [53, 4],
+ s,
+ [45, 5, 1],
+ c,
+ [100, 42],
+ 52,
+ c,
+ [5, 4],
+ 53
+])
+}),
+defaultActions: bda({
+ idx: u([
+ 6,
+ 7,
+ 8,
+ s,
+ [10, 16, 1],
+ 33,
+ 34,
+ 39,
+ 40,
+ 41,
+ 45,
+ 47,
+ 52,
+ 53
+]),
+ goto: u([
+ 9,
+ 10,
+ 11,
+ s,
+ [16, 14, 1],
+ 12,
+ 1,
+ 30,
+ 13,
+ s,
+ [4, 4, 1],
+ 14,
+ 15,
+ 8
+])
+}),
+parseError: function parseError(str, hash, ExceptionClass) {
+ if (hash.recoverable) {
+ if (typeof this.trace === 'function') {
+ this.trace(str);
+ }
+ hash.destroy(); // destroy... well, *almost*!
+ } else {
+ if (typeof this.trace === 'function') {
+ this.trace(str);
+ }
+ if (!ExceptionClass) {
+ ExceptionClass = this.JisonParserError;
+ }
+ throw new ExceptionClass(str, hash);
+ }
+},
+parse: function parse(input) {
+ var self = this;
+ var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage)
+ var sstack = new Array(128); // state stack: stores states (column storage)
+
+ var vstack = new Array(128); // semantic value stack
+
+ var table = this.table;
+ var sp = 0; // 'stack pointer': index into the stacks
+
+
+
+
+
+ var symbol = 0;
+
+
+
+ var TERROR = this.TERROR;
+ var EOF = this.EOF;
+ var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3;
+ var NO_ACTION = [0, 54 /* === table.length :: ensures that anyone using this new state will fail dramatically! */];
+
+ var lexer;
+ if (this.__lexer__) {
+ lexer = this.__lexer__;
+ } else {
+ lexer = this.__lexer__ = Object.create(this.lexer);
+ }
+
+ var sharedState_yy = {
+ parseError: undefined,
+ quoteName: undefined,
+ lexer: undefined,
+ parser: undefined,
+ pre_parse: undefined,
+ post_parse: undefined,
+ pre_lex: undefined,
+ post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes!
+ };
+
+ var ASSERT;
+ if (typeof assert !== 'function') {
+ ASSERT = function JisonAssert(cond, msg) {
+ if (!cond) {
+ throw new Error('assertion failed: ' + (msg || '***'));
+ }
+ };
+ } else {
+ ASSERT = assert;
+ }
+
+ this.yyGetSharedState = function yyGetSharedState() {
+ return sharedState_yy;
+ };
+
+
+
+
+
+
+
+
+ function shallow_copy_noclobber(dst, src) {
+ for (var k in src) {
+ if (typeof dst[k] === 'undefined' && Object.prototype.hasOwnProperty.call(src, k)) {
+ dst[k] = src[k];
+ }
+ }
+ }
+
+ // copy state
+ shallow_copy_noclobber(sharedState_yy, this.yy);
+
+ sharedState_yy.lexer = lexer;
+ sharedState_yy.parser = this;
+
+
+
+
+
+
+ // Does the shared state override the default `parseError` that already comes with this instance?
+ if (typeof sharedState_yy.parseError === 'function') {
+ this.parseError = function parseErrorAlt(str, hash, ExceptionClass) {
+ if (!ExceptionClass) {
+ ExceptionClass = this.JisonParserError;
+ }
+ return sharedState_yy.parseError.call(this, str, hash, ExceptionClass);
+ };
+ } else {
+ this.parseError = this.originalParseError;
+ }
+
+ // Does the shared state override the default `quoteName` that already comes with this instance?
+ if (typeof sharedState_yy.quoteName === 'function') {
+ this.quoteName = function quoteNameAlt(id_str) {
+ return sharedState_yy.quoteName.call(this, id_str);
+ };
+ } else {
+ this.quoteName = this.originalQuoteName;
+ }
+
+ // set up the cleanup function; make it an API so that external code can re-use this one in case of
+ // calamities or when the `%options no-try-catch` option has been specified for the grammar, in which
+ // case this parse() API method doesn't come with a `finally { ... }` block any more!
+ //
+ // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,
+ // or else your `sharedState`, etc. references will be *wrong*!
+ this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) {
+ var rv;
+
+ if (invoke_post_methods) {
+ var hash;
+
+ if (sharedState_yy.post_parse || this.post_parse) {
+ // create an error hash info instance: we re-use this API in a **non-error situation**
+ // as this one delivers all parser internals ready for access by userland code.
+ hash = this.constructParseErrorInfo(null /* no error! */, null /* no exception! */, null, false);
+ }
+
+ if (sharedState_yy.post_parse) {
+ rv = sharedState_yy.post_parse.call(this, sharedState_yy, resultValue, hash);
+ if (typeof rv !== 'undefined') resultValue = rv;
+ }
+ if (this.post_parse) {
+ rv = this.post_parse.call(this, sharedState_yy, resultValue, hash);
+ if (typeof rv !== 'undefined') resultValue = rv;
+ }
+
+ // cleanup:
+ if (hash && hash.destroy) {
+ hash.destroy();
+ }
+ }
+
+ if (this.__reentrant_call_depth > 1) return resultValue; // do not (yet) kill the sharedState when this is a reentrant run.
+
+ // clean up the lingering lexer structures as well:
+ if (lexer.cleanupAfterLex) {
+ lexer.cleanupAfterLex(do_not_nuke_errorinfos);
+ }
+
+ // prevent lingering circular references from causing memory leaks:
+ if (sharedState_yy) {
+ sharedState_yy.lexer = undefined;
+ sharedState_yy.parser = undefined;
+ if (lexer.yy === sharedState_yy) {
+ lexer.yy = undefined;
+ }
+ }
+ sharedState_yy = undefined;
+ this.parseError = this.originalParseError;
+ this.quoteName = this.originalQuoteName;
+
+ // nuke the vstack[] array at least as that one will still reference obsoleted user values.
+ // To be safe, we nuke the other internal stack columns as well...
+ stack.length = 0; // fastest way to nuke an array without overly bothering the GC
+ sstack.length = 0;
+
+ vstack.length = 0;
+ sp = 0;
+
+ // nuke the error hash info instances created during this run.
+ // Userland code must COPY any data/references
+ // in the error hash instance(s) it is more permanently interested in.
+ if (!do_not_nuke_errorinfos) {
+ for (var i = this.__error_infos.length - 1; i >= 0; i--) {
+ var el = this.__error_infos[i];
+ if (el && typeof el.destroy === 'function') {
+ el.destroy();
+ }
+ }
+ this.__error_infos.length = 0;
+
+
+ }
+
+ return resultValue;
+ };
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,
+ // or else your `lexer`, `sharedState`, etc. references will be *wrong*!
+ this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) {
+ var pei = {
+ errStr: msg,
+ exception: ex,
+ text: lexer.match,
+ value: lexer.yytext,
+ token: this.describeSymbol(symbol) || symbol,
+ token_id: symbol,
+ line: lexer.yylineno,
+
+ expected: expected,
+ recoverable: recoverable,
+ state: state,
+ action: action,
+ new_state: newState,
+ symbol_stack: stack,
+ state_stack: sstack,
+ value_stack: vstack,
+
+ stack_pointer: sp,
+ yy: sharedState_yy,
+ lexer: lexer,
+ parser: this,
+
+ // and make sure the error info doesn't stay due to potential
+ // ref cycle via userland code manipulations.
+ // These would otherwise all be memory leak opportunities!
+ //
+ // Note that only array and object references are nuked as those
+ // constitute the set of elements which can produce a cyclic ref.
+ // The rest of the members is kept intact as they are harmless.
+ destroy: function destructParseErrorInfo() {
+ // remove cyclic references added to error info:
+ // info.yy = null;
+ // info.lexer = null;
+ // info.value = null;
+ // info.value_stack = null;
+ // ...
+ var rec = !!this.recoverable;
+ for (var key in this) {
+ if (this.hasOwnProperty(key) && typeof key === 'object') {
+ this[key] = undefined;
+ }
+ }
+ this.recoverable = rec;
+ }
+ };
+ // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!
+ this.__error_infos.push(pei);
+ return pei;
+ };
+
+
+
+
+
+
+
+
+
+
+
+
+
+ function getNonTerminalFromCode(symbol) {
+ var tokenName = self.getSymbolName(symbol);
+ if (!tokenName) {
+ tokenName = symbol;
+ }
+ return tokenName;
+ }
+
+
+ function stdLex() {
+ var token = lexer.lex();
+ // if token isn't its numeric value, convert
+ if (typeof token !== 'number') {
+ token = self.symbols_[token] || token;
+ }
+
+ return token || EOF;
+ }
+
+ function fastLex() {
+ var token = lexer.fastLex();
+ // if token isn't its numeric value, convert
+ if (typeof token !== 'number') {
+ token = self.symbols_[token] || token;
+ }
+
+ return token || EOF;
+ }
+
+ var lex = stdLex;
+
+
+ var state, action, r, t;
+ var yyval = {
+ $: true,
+ _$: undefined,
+ yy: sharedState_yy
+ };
+ var p;
+ var yyrulelen;
+ var this_production;
+ var newState;
+ var retval = false;
+
+
+ try {
+ this.__reentrant_call_depth++;
+
+ lexer.setInput(input, sharedState_yy);
+
+ // NOTE: we *assume* no lexer pre/post handlers are set up *after*
+ // this initial `setInput()` call: hence we can now check and decide
+ // whether we'll go with the standard, slower, lex() API or the
+ // `fast_lex()` one:
+ if (typeof lexer.canIUse === 'function') {
+ var lexerInfo = lexer.canIUse();
+ if (lexerInfo.fastLex && typeof fastLex === 'function') {
+ lex = fastLex;
+ }
+ }
+
+
+
+ vstack[sp] = null;
+ sstack[sp] = 0;
+ stack[sp] = 0;
+ ++sp;
+
+
+
+
+
+ if (this.pre_parse) {
+ this.pre_parse.call(this, sharedState_yy);
+ }
+ if (sharedState_yy.pre_parse) {
+ sharedState_yy.pre_parse.call(this, sharedState_yy);
+ }
+
+ newState = sstack[sp - 1];
+ for (;;) {
+ // retrieve state number from top of stack
+ state = newState; // sstack[sp - 1];
+
+ // use default actions if available
+ if (this.defaultActions[state]) {
+ action = 2;
+ newState = this.defaultActions[state];
+ } else {
+ // The single `==` condition below covers both these `===` comparisons in a single
+ // operation:
+ //
+ // if (symbol === null || typeof symbol === 'undefined') ...
+ if (!symbol) {
+ symbol = lex();
+ }
+ // read action for current state and first input
+ t = (table[state] && table[state][symbol]) || NO_ACTION;
+ newState = t[1];
+ action = t[0];
+
+
+
+
+
+
+
+
+
+
+
+ // handle parse error
+ if (!action) {
+ var errStr;
+ var errSymbolDescr = (this.describeSymbol(symbol) || symbol);
+ var expected = this.collect_expected_token_set(state);
+
+ // Report error
+ if (typeof lexer.yylineno === 'number') {
+ errStr = 'Parse error on line ' + (lexer.yylineno + 1) + ': ';
+ } else {
+ errStr = 'Parse error: ';
+ }
+ if (typeof lexer.showPosition === 'function') {
+ errStr += '\n' + lexer.showPosition(79 - 10, 10) + '\n';
+ }
+ if (expected.length) {
+ errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;
+ } else {
+ errStr += 'Unexpected ' + errSymbolDescr;
+ }
+ // we cannot recover from the error!
+ p = this.constructParseErrorInfo(errStr, null, expected, false);
+ r = this.parseError(p.errStr, p, this.JisonParserError);
+ if (typeof r !== 'undefined') {
+ retval = r;
+ }
+ break;
+ }
+
+
+ }
+
+
+
+
+
+
+
+
+
+
+ switch (action) {
+ // catch misc. parse failures:
+ default:
+ // this shouldn't happen, unless resolve defaults are off
+ if (action instanceof Array) {
+ p = this.constructParseErrorInfo('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol, null, null, false);
+ r = this.parseError(p.errStr, p, this.JisonParserError);
+ if (typeof r !== 'undefined') {
+ retval = r;
+ }
+ break;
+ }
+ // Another case of better safe than sorry: in case state transitions come out of another error recovery process
+ // or a buggy LUT (LookUp Table):
+ p = this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.', null, null, false);
+ r = this.parseError(p.errStr, p, this.JisonParserError);
+ if (typeof r !== 'undefined') {
+ retval = r;
+ }
+ break;
+
+ // shift:
+ case 1:
+ stack[sp] = symbol;
+ vstack[sp] = lexer.yytext;
+
+ sstack[sp] = newState; // push state
+
+ ++sp;
+ symbol = 0;
+
+
+
+
+ // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:
+
+
+
+
+ continue;
+
+ // reduce:
+ case 2:
+
+
+
+ this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...
+ yyrulelen = this_production[1];
+
+
+
+
+
+
+
+
+
+
+ r = this.performAction.call(yyval, newState, sp - 1, vstack);
+
+ if (typeof r !== 'undefined') {
+ retval = r;
+ break;
+ }
+
+ // pop off stack
+ sp -= yyrulelen;
+
+ // don't overwrite the `symbol` variable: use a local var to speed things up:
+ var ntsymbol = this_production[0]; // push nonterminal (reduce)
+ stack[sp] = ntsymbol;
+ vstack[sp] = yyval.$;
+
+ // goto new state = table[STATE][NONTERMINAL]
+ newState = table[sstack[sp - 1]][ntsymbol];
+ sstack[sp] = newState;
+ ++sp;
+
+
+
+
+
+
+
+
+
+ continue;
+
+ // accept:
+ case 3:
+ if (sp !== -2) {
+ retval = true;
+ // Return the `$accept` rule's `$$` result, if available.
+ //
+ // Also note that JISON always adds this top-most `$accept` rule (with implicit,
+ // default, action):
+ //
+ // $accept: <startSymbol> $end
+ // %{ $$ = $1; @$ = @1; %}
+ //
+ // which, combined with the parse kernel's `$accept` state behaviour coded below,
+ // will produce the `$$` value output of the <startSymbol> rule as the parse result,
+ // IFF that result is *not* `undefined`. (See also the parser kernel code.)
+ //
+ // In code:
+ //
+ // %{
+ // @$ = @1; // if location tracking support is included
+ // if (typeof $1 !== 'undefined')
+ // return $1;
+ // else
+ // return true; // the default parse result if the rule actions don't produce anything
+ // %}
+ sp--;
+ if (typeof vstack[sp] !== 'undefined') {
+ retval = vstack[sp];
+ }
+ }
+ break;
+ }
+
+ // break out of loop: we accept or fail with error
+ break;
+ }
+ } catch (ex) {
+ // report exceptions through the parseError callback too, but keep the exception intact
+ // if it is a known parser or lexer error which has been thrown by parseError() already:
+ if (ex instanceof this.JisonParserError) {
+ throw ex;
+ }
+ else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) {
+ throw ex;
+ }
+
+ p = this.constructParseErrorInfo('Parsing aborted due to exception.', ex, null, false);
+ retval = false;
+ r = this.parseError(p.errStr, p, this.JisonParserError);
+ if (typeof r !== 'undefined') {
+ retval = r;
+ }
+ } finally {
+ retval = this.cleanupAfterParse(retval, true, true);
+ this.__reentrant_call_depth--;
+ } // /finally
+
+ return retval;
+}
+};
+parser.originalParseError = parser.parseError;
+parser.originalQuoteName = parser.quoteName;
+/* lexer generated by jison-lex 0.6.1-215 */
+
+/*
+ * Returns a Lexer object of the following structure:
+ *
+ * Lexer: {
+ * yy: {} The so-called "shared state" or rather the *source* of it;
+ * the real "shared state" `yy` passed around to
+ * the rule actions, etc. is a direct reference!
+ *
+ * This "shared context" object was passed to the lexer by way of
+ * the `lexer.setInput(str, yy)` API before you may use it.
+ *
+ * This "shared context" object is passed to the lexer action code in `performAction()`
+ * so userland code in the lexer actions may communicate with the outside world
+ * and/or other lexer rules' actions in more or less complex ways.
+ *
+ * }
+ *
+ * Lexer.prototype: {
+ * EOF: 1,
+ * ERROR: 2,
+ *
+ * yy: The overall "shared context" object reference.
+ *
+ * JisonLexerError: function(msg, hash),
+ *
+ * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),
+ *
+ * The function parameters and `this` have the following value/meaning:
+ * - `this` : reference to the `lexer` instance.
+ * `yy_` is an alias for `this` lexer instance reference used internally.
+ *
+ * - `yy` : a reference to the `yy` "shared state" object which was passed to the lexer
+ * by way of the `lexer.setInput(str, yy)` API before.
+ *
+ * Note:
+ * The extra arguments you specified in the `%parse-param` statement in your
+ * **parser** grammar definition file are passed to the lexer via this object
+ * reference as member variables.
+ *
+ * - `yyrulenumber` : index of the matched lexer rule (regex), used internally.
+ *
+ * - `YY_START`: the current lexer "start condition" state.
+ *
+ * parseError: function(str, hash, ExceptionClass),
+ *
+ * constructLexErrorInfo: function(error_message, is_recoverable),
+ * Helper function.
+ * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.
+ * See it's use in this lexer kernel in many places; example usage:
+ *
+ * var infoObj = lexer.constructParseErrorInfo('fail!', true);
+ * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);
+ *
+ * options: { ... lexer %options ... },
+ *
+ * lex: function(),
+ * Produce one token of lexed input, which was passed in earlier via the `lexer.setInput()` API.
+ * You MAY use the additional `args...` parameters as per `%parse-param` spec of the **lexer** grammar:
+ * these extra `args...` are added verbatim to the `yy` object reference as member variables.
+ *
+ * WARNING:
+ * Lexer's additional `args...` parameters (via lexer's `%parse-param`) MAY conflict with
+ * any attributes already added to `yy` by the **parser** or the jison run-time;
+ * when such a collision is detected an exception is thrown to prevent the generated run-time
+ * from silently accepting this confusing and potentially hazardous situation!
+ *
+ * cleanupAfterLex: function(do_not_nuke_errorinfos),
+ * Helper function.
+ *
+ * This helper API is invoked when the **parse process** has completed: it is the responsibility
+ * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.
+ *
+ * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.
+ *
+ * setInput: function(input, [yy]),
+ *
+ *
+ * input: function(),
+ *
+ *
+ * unput: function(str),
+ *
+ *
+ * more: function(),
+ *
+ *
+ * reject: function(),
+ *
+ *
+ * less: function(n),
+ *
+ *
+ * pastInput: function(n),
+ *
+ *
+ * upcomingInput: function(n),
+ *
+ *
+ * showPosition: function(),
+ *
+ *
+ * test_match: function(regex_match_array, rule_index),
+ *
+ *
+ * next: function(),
+ *
+ *
+ * begin: function(condition),
+ *
+ *
+ * pushState: function(condition),
+ *
+ *
+ * popState: function(),
+ *
+ *
+ * topState: function(),
+ *
+ *
+ * _currentRules: function(),
+ *
+ *
+ * stateStackSize: function(),
+ *
+ *
+ * performAction: function(yy, yy_, yyrulenumber, YY_START),
+ *
+ *
+ * rules: [...],
+ *
+ *
+ * conditions: {associative list: name ==> set},
+ * }
+ *
+ *
+ * token location info (`yylloc`): {
+ * first_line: n,
+ * last_line: n,
+ * first_column: n,
+ * last_column: n,
+ * range: [start_number, end_number]
+ * (where the numbers are indexes into the input string, zero-based)
+ * }
+ *
+ * ---
+ *
+ * The `parseError` function receives a 'hash' object with these members for lexer errors:
+ *
+ * {
+ * text: (matched text)
+ * token: (the produced terminal token, if any)
+ * token_id: (the produced terminal token numeric ID, if any)
+ * line: (yylineno)
+ * loc: (yylloc)
+ * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule
+ * available for this particular error)
+ * yy: (object: the current parser internal "shared state" `yy`
+ * as is also available in the rule actions; this can be used,
+ * for instance, for advanced error analysis and reporting)
+ * lexer: (reference to the current lexer instance used by the parser)
+ * }
+ *
+ * while `this` will reference the current lexer instance.
+ *
+ * When `parseError` is invoked by the lexer, the default implementation will
+ * attempt to invoke `yy.parser.parseError()`; when this callback is not provided
+ * it will try to invoke `yy.parseError()` instead. When that callback is also not
+ * provided, a `JisonLexerError` exception will be thrown containing the error
+ * message and `hash`, as constructed by the `constructLexErrorInfo()` API.
+ *
+ * Note that the lexer's `JisonLexerError` error class is passed via the
+ * `ExceptionClass` argument, which is invoked to construct the exception
+ * instance to be thrown, so technically `parseError` will throw the object
+ * produced by the `new ExceptionClass(str, hash)` JavaScript expression.
+ *
+ * ---
+ *
+ * You can specify lexer options by setting / modifying the `.options` object of your Lexer instance.
+ * These options are available:
+ *
+ * (Options are permanent.)
+ *
+ * yy: {
+ * parseError: function(str, hash, ExceptionClass)
+ * optional: overrides the default `parseError` function.
+ * }
+ *
+ * lexer.options: {
+ * pre_lex: function()
+ * optional: is invoked before the lexer is invoked to produce another token.
+ * `this` refers to the Lexer object.
+ * post_lex: function(token) { return token; }
+ * optional: is invoked when the lexer has produced a token `token`;
+ * this function can override the returned token value by returning another.
+ * When it does not return any (truthy) value, the lexer will return
+ * the original `token`.
+ * `this` refers to the Lexer object.
+ *
+ * WARNING: the next set of options are not meant to be changed. They echo the abilities of
+ * the lexer as per when it was compiled!
+ *
+ * ranges: boolean
+ * optional: `true` ==> token location info will include a .range[] member.
+ * flex: boolean
+ * optional: `true` ==> flex-like lexing behaviour where the rules are tested
+ * exhaustively to find the longest match.
+ * backtrack_lexer: boolean
+ * optional: `true` ==> lexer regexes are tested in order and for invoked;
+ * the lexer terminates the scan when a token is returned by the action code.
+ * xregexp: boolean
+ * optional: `true` ==> lexer rule regexes are "extended regex format" requiring the
+ * `XRegExp` library. When this %option has not been specified at compile time, all lexer
+ * rule regexes have been written as standard JavaScript RegExp expressions.
+ * }
+ */
+
+
+var lexer = function() {
+ /**
+ * See also:
+ * http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508
+ * but we keep the prototype.constructor and prototype.name assignment lines too for compatibility
+ * with userland code which might access the derived class in a 'classic' way.
+ *
+ * @public
+ * @constructor
+ * @nocollapse
+ */
+ function JisonLexerError(msg, hash) {
+ Object.defineProperty(this, 'name', {
+ enumerable: false,
+ writable: false,
+ value: 'JisonLexerError'
+ });
+
+ if (msg == null)
+ msg = '???';
+
+ Object.defineProperty(this, 'message', {
+ enumerable: false,
+ writable: true,
+ value: msg
+ });
+
+ this.hash = hash;
+ var stacktrace;
+
+ if (hash && hash.exception instanceof Error) {
+ var ex2 = hash.exception;
+ this.message = ex2.message || msg;
+ stacktrace = ex2.stack;
+ }
+
+ if (!stacktrace) {
+ if (Error.hasOwnProperty('captureStackTrace')) {
+ // V8
+ Error.captureStackTrace(this, this.constructor);
+ } else {
+ stacktrace = new Error(msg).stack;
+ }
+ }
+
+ if (stacktrace) {
+ Object.defineProperty(this, 'stack', {
+ enumerable: false,
+ writable: false,
+ value: stacktrace
+ });
+ }
+ }
+
+ if (typeof Object.setPrototypeOf === 'function') {
+ Object.setPrototypeOf(JisonLexerError.prototype, Error.prototype);
+ } else {
+ JisonLexerError.prototype = Object.create(Error.prototype);
+ }
+
+ JisonLexerError.prototype.constructor = JisonLexerError;
+ JisonLexerError.prototype.name = 'JisonLexerError';
+
+ var lexer = {
+
+// Code Generator Information Report
+// ---------------------------------
+//
+// Options:
+//
+// backtracking: .................... false
+// location.ranges: ................. false
+// location line+column tracking: ... true
+//
+//
+// Forwarded Parser Analysis flags:
+//
+// uses yyleng: ..................... false
+// uses yylineno: ................... false
+// uses yytext: ..................... false
+// uses yylloc: ..................... false
+// uses lexer values: ............... true / true
+// location tracking: ............... false
+// location assignment: ............. false
+//
+//
+// Lexer Analysis flags:
+//
+// uses yyleng: ..................... ???
+// uses yylineno: ................... ???
+// uses yytext: ..................... ???
+// uses yylloc: ..................... ???
+// uses ParseError API: ............. ???
+// uses yyerror: .................... ???
+// uses location tracking & editing: ???
+// uses more() API: ................. ???
+// uses unput() API: ................ ???
+// uses reject() API: ............... ???
+// uses less() API: ................. ???
+// uses display APIs pastInput(), upcomingInput(), showPosition():
+// ............................. ???
+// uses describeYYLLOC() API: ....... ???
+//
+// --------- END OF REPORT -----------
+
+EOF: 1,
+ ERROR: 2,
+
+ // JisonLexerError: JisonLexerError, /// <-- injected by the code generator
+
+ // options: {}, /// <-- injected by the code generator
+
+ // yy: ..., /// <-- injected by setInput()
+
+ __currentRuleSet__: null, /// INTERNAL USE ONLY: internal rule set cache for the current lexer state
+
+ __error_infos: [], /// INTERNAL USE ONLY: the set of lexErrorInfo objects created since the last cleanup
+ __decompressed: false, /// INTERNAL USE ONLY: mark whether the lexer instance has been 'unfolded' completely and is now ready for use
+ done: false, /// INTERNAL USE ONLY
+ _backtrack: false, /// INTERNAL USE ONLY
+ _input: '', /// INTERNAL USE ONLY
+ _more: false, /// INTERNAL USE ONLY
+ _signaled_error_token: false, /// INTERNAL USE ONLY
+ conditionStack: [], /// INTERNAL USE ONLY; managed via `pushState()`, `popState()`, `topState()` and `stateStackSize()`
+ 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!
+ matched: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks entire input which has been matched so far
+ matches: false, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks RE match result for last (successful) match attempt
+ 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.
+ 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
+ yyleng: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: length of matched input for the token under construction (`yytext`)
+ yylineno: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: 'line number' at which the token under construction is located
+ yylloc: null, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks location info (lines + columns) for the token under construction
+
+ /**
+ * INTERNAL USE: construct a suitable error info hash object instance for `parseError`.
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) {
+ msg = '' + msg;
+
+ // heuristic to determine if the error message already contains a (partial) source code dump
+ // as produced by either `showPosition()` or `prettyPrintRange()`:
+ if (show_input_position == undefined) {
+ show_input_position = !(msg.indexOf('\n') > 0 && msg.indexOf('^') > 0);
+ }
+
+ if (this.yylloc && show_input_position) {
+ if (typeof this.prettyPrintRange === 'function') {
+ var pretty_src = this.prettyPrintRange(this.yylloc);
+
+ if (!/\n\s*$/.test(msg)) {
+ msg += '\n';
+ }
+
+ msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc);
+ } else if (typeof this.showPosition === 'function') {
+ var pos_str = this.showPosition();
+
+ if (pos_str) {
+ if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') {
+ msg += '\n' + pos_str;
+ } else {
+ msg += pos_str;
+ }
+ }
+ }
+ }
+
+ /** @constructor */
+ var pei = {
+ errStr: msg,
+ recoverable: !!recoverable,
+ 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'...
+ token: null,
+ line: this.yylineno,
+ loc: this.yylloc,
+ yy: this.yy,
+ lexer: this,
+
+ /**
+ * and make sure the error info doesn't stay due to potential
+ * ref cycle via userland code manipulations.
+ * These would otherwise all be memory leak opportunities!
+ *
+ * Note that only array and object references are nuked as those
+ * constitute the set of elements which can produce a cyclic ref.
+ * The rest of the members is kept intact as they are harmless.
+ *
+ * @public
+ * @this {LexErrorInfo}
+ */
+ destroy: function destructLexErrorInfo() {
+ // remove cyclic references added to error info:
+ // info.yy = null;
+ // info.lexer = null;
+ // ...
+ var rec = !!this.recoverable;
+
+ for (var key in this) {
+ if (this.hasOwnProperty(key) && typeof key === 'object') {
+ this[key] = undefined;
+ }
+ }
+
+ this.recoverable = rec;
+ }
+ };
+
+ // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!
+ this.__error_infos.push(pei);
+
+ return pei;
+ },
+
+ /**
+ * handler which is invoked when a lexer error occurs.
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ parseError: function lexer_parseError(str, hash, ExceptionClass) {
+ if (!ExceptionClass) {
+ ExceptionClass = this.JisonLexerError;
+ }
+
+ if (this.yy) {
+ if (this.yy.parser && typeof this.yy.parser.parseError === 'function') {
+ return this.yy.parser.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;
+ } else if (typeof this.yy.parseError === 'function') {
+ return this.yy.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;
+ }
+ }
+
+ throw new ExceptionClass(str, hash);
+ },
+
+ /**
+ * method which implements `yyerror(str, ...args)` functionality for use inside lexer actions.
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ yyerror: function yyError(str /*, ...args */) {
+ var lineno_msg = '';
+
+ if (this.yylloc) {
+ lineno_msg = ' on line ' + (this.yylineno + 1);
+ }
+
+ var p = this.constructLexErrorInfo(
+ 'Lexical error' + lineno_msg + ': ' + str,
+ this.options.lexerErrorsAreRecoverable
+ );
+
+ // Add any extra args to the hash under the name `extra_error_attributes`:
+ var args = Array.prototype.slice.call(arguments, 1);
+
+ if (args.length) {
+ p.extra_error_attributes = args;
+ }
+
+ return this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR;
+ },
+
+ /**
+ * final cleanup function for when we have completed lexing the input;
+ * make it an API so that external code can use this one once userland
+ * code has decided it's time to destroy any lingering lexer error
+ * hash object instances and the like: this function helps to clean
+ * up these constructs, which *may* carry cyclic references which would
+ * otherwise prevent the instances from being properly and timely
+ * garbage-collected, i.e. this function helps prevent memory leaks!
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) {
+ // prevent lingering circular references from causing memory leaks:
+ this.setInput('', {});
+
+ // nuke the error hash info instances created during this run.
+ // Userland code must COPY any data/references
+ // in the error hash instance(s) it is more permanently interested in.
+ if (!do_not_nuke_errorinfos) {
+ for (var i = this.__error_infos.length - 1; i >= 0; i--) {
+ var el = this.__error_infos[i];
+
+ if (el && typeof el.destroy === 'function') {
+ el.destroy();
+ }
+ }
+
+ this.__error_infos.length = 0;
+ }
+
+ return this;
+ },
+
+ /**
+ * clear the lexer token context; intended for internal use only
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ clear: function lexer_clear() {
+ this.yytext = '';
+ this.yyleng = 0;
+ this.match = '';
+
+ // - DO NOT reset `this.matched`
+ this.matches = false;
+
+ this._more = false;
+ this._backtrack = false;
+ var col = (this.yylloc ? this.yylloc.last_column : 0);
+
+ this.yylloc = {
+ first_line: this.yylineno + 1,
+ first_column: col,
+ last_line: this.yylineno + 1,
+ last_column: col,
+ range: [this.offset, this.offset]
+ };
+ },
+
+ /**
+ * resets the lexer, sets new input
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ setInput: function lexer_setInput(input, yy) {
+ this.yy = yy || this.yy || {};
+
+ // also check if we've fully initialized the lexer instance,
+ // including expansion work to be done to go from a loaded
+ // lexer to a usable lexer:
+ if (!this.__decompressed) {
+ // step 1: decompress the regex list:
+ var rules = this.rules;
+
+ for (var i = 0, len = rules.length; i < len; i++) {
+ var rule_re = rules[i];
+
+ // compression: is the RE an xref to another RE slot in the rules[] table?
+ if (typeof rule_re === 'number') {
+ rules[i] = rules[rule_re];
+ }
+ }
+
+ // step 2: unfold the conditions[] set to make these ready for use:
+ var conditions = this.conditions;
+
+ for (var k in conditions) {
+ var spec = conditions[k];
+ var rule_ids = spec.rules;
+ var len = rule_ids.length;
+ 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!
+ var rule_new_ids = new Array(len + 1);
+
+ for (var i = 0; i < len; i++) {
+ var idx = rule_ids[i];
+ var rule_re = rules[idx];
+ rule_regexes[i + 1] = rule_re;
+ rule_new_ids[i + 1] = idx;
+ }
+
+ spec.rules = rule_new_ids;
+ spec.__rule_regexes = rule_regexes;
+ spec.__rule_count = len;
+ }
+
+ this.__decompressed = true;
+ }
+
+ this._input = input || '';
+ this.clear();
+ this._signaled_error_token = false;
+ this.done = false;
+ this.yylineno = 0;
+ this.matched = '';
+ this.conditionStack = ['INITIAL'];
+ this.__currentRuleSet__ = null;
+
+ this.yylloc = {
+ first_line: 1,
+ first_column: 0,
+ last_line: 1,
+ last_column: 0,
+ range: [0, 0]
+ };
+
+ this.offset = 0;
+ return this;
+ },
+
+ /**
+ * edit the remaining input via user-specified callback.
+ * This can be used to forward-adjust the input-to-parse,
+ * e.g. inserting macro expansions and alike in the
+ * input which has yet to be lexed.
+ * The behaviour of this API contrasts the `unput()` et al
+ * APIs as those act on the *consumed* input, while this
+ * one allows one to manipulate the future, without impacting
+ * the current `yyloc` cursor location or any history.
+ *
+ * Use this API to help implement C-preprocessor-like
+ * `#include` statements, etc.
+ *
+ * The provided callback must be synchronous and is
+ * expected to return the edited input (string).
+ *
+ * The `cpsArg` argument value is passed to the callback
+ * as-is.
+ *
+ * `callback` interface:
+ * `function callback(input, cpsArg)`
+ *
+ * - `input` will carry the remaining-input-to-lex string
+ * from the lexer.
+ * - `cpsArg` is `cpsArg` passed into this API.
+ *
+ * The `this` reference for the callback will be set to
+ * reference this lexer instance so that userland code
+ * in the callback can easily and quickly access any lexer
+ * API.
+ *
+ * When the callback returns a non-string-type falsey value,
+ * we assume the callback did not edit the input and we
+ * will using the input as-is.
+ *
+ * When the callback returns a non-string-type value, it
+ * is converted to a string for lexing via the `"" + retval`
+ * operation. (See also why: http://2ality.com/2012/03/converting-to-string.html
+ * -- that way any returned object's `toValue()` and `toString()`
+ * methods will be invoked in a proper/desirable order.)
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) {
+ var rv = callback.call(this, this._input, cpsArg);
+
+ if (typeof rv !== 'string') {
+ if (rv) {
+ this._input = '' + rv;
+ }
+ // else: keep `this._input` as is.
+ } else {
+ this._input = rv;
+ }
+
+ return this;
+ },
+
+ /**
+ * consumes and returns one char from the input
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ input: function lexer_input() {
+ if (!this._input) {
+ //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*)
+ return null;
+ }
+
+ var ch = this._input[0];
+ this.yytext += ch;
+ this.yyleng++;
+ this.offset++;
+ this.match += ch;
+ this.matched += ch;
+
+ // Count the linenumber up when we hit the LF (or a stand-alone CR).
+ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo
+ // and we advance immediately past the LF as well, returning both together as if
+ // it was all a single 'character' only.
+ var slice_len = 1;
+
+ var lines = false;
+
+ if (ch === '\n') {
+ lines = true;
+ } else if (ch === '\r') {
+ lines = true;
+ var ch2 = this._input[1];
+
+ if (ch2 === '\n') {
+ slice_len++;
+ ch += ch2;
+ this.yytext += ch2;
+ this.yyleng++;
+ this.offset++;
+ this.match += ch2;
+ this.matched += ch2;
+ this.yylloc.range[1]++;
+ }
+ }
+
+ if (lines) {
+ this.yylineno++;
+ this.yylloc.last_line++;
+ this.yylloc.last_column = 0;
+ } else {
+ this.yylloc.last_column++;
+ }
+
+ this.yylloc.range[1]++;
+ this._input = this._input.slice(slice_len);
+ return ch;
+ },
+
+ /**
+ * unshifts one char (or an entire string) into the input
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ unput: function lexer_unput(ch) {
+ var len = ch.length;
+ var lines = ch.split(/(?:\r\n?|\n)/g);
+ this._input = ch + this._input;
+ this.yytext = this.yytext.substr(0, this.yytext.length - len);
+ this.yyleng = this.yytext.length;
+ this.offset -= len;
+ this.match = this.match.substr(0, this.match.length - len);
+ this.matched = this.matched.substr(0, this.matched.length - len);
+
+ if (lines.length > 1) {
+ this.yylineno -= lines.length - 1;
+ this.yylloc.last_line = this.yylineno + 1;
+
+ // Get last entirely matched line into the `pre_lines[]` array's
+ // last index slot; we don't mind when other previously
+ // matched lines end up in the array too.
+ var pre = this.match;
+
+ var pre_lines = pre.split(/(?:\r\n?|\n)/g);
+
+ if (pre_lines.length === 1) {
+ pre = this.matched;
+ pre_lines = pre.split(/(?:\r\n?|\n)/g);
+ }
+
+ this.yylloc.last_column = pre_lines[pre_lines.length - 1].length;
+ } else {
+ this.yylloc.last_column -= len;
+ }
+
+ this.yylloc.range[1] = this.yylloc.range[0] + this.yyleng;
+ this.done = false;
+ return this;
+ },
+
+ /**
+ * cache matched text and append it on next action
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ more: function lexer_more() {
+ this._more = true;
+ return this;
+ },
+
+ /**
+ * signal the lexer that this rule fails to match the input, so the
+ * next matching rule (regex) should be tested instead.
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ reject: function lexer_reject() {
+ if (this.options.backtrack_lexer) {
+ this._backtrack = true;
+ } else {
+ // when the `parseError()` call returns, we MUST ensure that the error is registered.
+ // We accomplish this by signaling an 'error' token to be produced for the current
+ // `.lex()` run.
+ var lineno_msg = '';
+
+ if (this.yylloc) {
+ lineno_msg = ' on line ' + (this.yylineno + 1);
+ }
+
+ var p = this.constructLexErrorInfo(
+ 'Lexical error' + lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',
+ false
+ );
+
+ this._signaled_error_token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR;
+ }
+
+ return this;
+ },
+
+ /**
+ * retain first n characters of the match
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ less: function lexer_less(n) {
+ return this.unput(this.match.slice(n));
+ },
+
+ /**
+ * return (part of the) already matched input, i.e. for error
+ * messages.
+ *
+ * Limit the returned string length to `maxSize` (default: 20).
+ *
+ * Limit the returned string to the `maxLines` number of lines of
+ * input (default: 1).
+ *
+ * Negative limit values equal *unlimited*.
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ pastInput: function lexer_pastInput(maxSize, maxLines) {
+ var past = this.matched.substring(0, this.matched.length - this.match.length);
+
+ if (maxSize < 0)
+ maxSize = past.length;
+ else if (!maxSize)
+ maxSize = 20;
+
+ if (maxLines < 0)
+ maxLines = past.length; // can't ever have more input lines than this!
+ else if (!maxLines)
+ maxLines = 1;
+
+ // `substr` anticipation: treat \r\n as a single character and take a little
+ // more than necessary so that we can still properly check against maxSize
+ // after we've transformed and limited the newLines in here:
+ past = past.substr(-maxSize * 2 - 2);
+
+ // now that we have a significantly reduced string to process, transform the newlines
+ // and chop them, then limit them:
+ var a = past.replace(/\r\n|\r/g, '\n').split('\n');
+
+ a = a.slice(-maxLines);
+ past = a.join('\n');
+
+ // When, after limiting to maxLines, we still have too much to return,
+ // do add an ellipsis prefix...
+ if (past.length > maxSize) {
+ past = '...' + past.substr(-maxSize);
+ }
+
+ return past;
+ },
+
+ /**
+ * return (part of the) upcoming input, i.e. for error messages.
+ *
+ * Limit the returned string length to `maxSize` (default: 20).
+ *
+ * Limit the returned string to the `maxLines` number of lines of input (default: 1).
+ *
+ * Negative limit values equal *unlimited*.
+ *
+ * > ### NOTE ###
+ * >
+ * > *"upcoming input"* is defined as the whole of the both
+ * > the *currently lexed* input, together with any remaining input
+ * > following that. *"currently lexed"* input is the input
+ * > already recognized by the lexer but not yet returned with
+ * > the lexer token. This happens when you are invoking this API
+ * > from inside any lexer rule action code block.
+ * >
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) {
+ var next = this.match;
+
+ if (maxSize < 0)
+ maxSize = next.length + this._input.length;
+ else if (!maxSize)
+ maxSize = 20;
+
+ if (maxLines < 0)
+ maxLines = maxSize; // can't ever have more input lines than this!
+ else if (!maxLines)
+ maxLines = 1;
+
+ // `substring` anticipation: treat \r\n as a single character and take a little
+ // more than necessary so that we can still properly check against maxSize
+ // after we've transformed and limited the newLines in here:
+ if (next.length < maxSize * 2 + 2) {
+ next += this._input.substring(0, maxSize * 2 + 2); // substring is faster on Chrome/V8
+ }
+
+ // now that we have a significantly reduced string to process, transform the newlines
+ // and chop them, then limit them:
+ var a = next.replace(/\r\n|\r/g, '\n').split('\n');
+
+ a = a.slice(0, maxLines);
+ next = a.join('\n');
+
+ // When, after limiting to maxLines, we still have too much to return,
+ // do add an ellipsis postfix...
+ if (next.length > maxSize) {
+ next = next.substring(0, maxSize) + '...';
+ }
+
+ return next;
+ },
+
+ /**
+ * return a string which displays the character position where the
+ * lexing error occurred, i.e. for error messages
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) {
+ var pre = this.pastInput(maxPrefix).replace(/\s/g, ' ');
+ var c = new Array(pre.length + 1).join('-');
+ return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^';
+ },
+
+ /**
+ * return an YYLLOC info object derived off the given context (actual, preceding, following, current).
+ * Use this method when the given `actual` location is not guaranteed to exist (i.e. when
+ * it MAY be NULL) and you MUST have a valid location info object anyway:
+ * then we take the given context of the `preceding` and `following` locations, IFF those are available,
+ * and reconstruct the `actual` location info from those.
+ * If this fails, the heuristic is to take the `current` location, IFF available.
+ * If this fails as well, we assume the sought location is at/around the current lexer position
+ * and then produce that one as a response. DO NOTE that these heuristic/derived location info
+ * values MAY be inaccurate!
+ *
+ * NOTE: `deriveLocationInfo()` ALWAYS produces a location info object *copy* of `actual`, not just
+ * a *reference* hence all input location objects can be assumed to be 'constant' (function has no side-effects).
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) {
+ var loc = {
+ first_line: 1,
+ first_column: 0,
+ last_line: 1,
+ last_column: 0,
+ range: [0, 0]
+ };
+
+ if (actual) {
+ loc.first_line = actual.first_line | 0;
+ loc.last_line = actual.last_line | 0;
+ loc.first_column = actual.first_column | 0;
+ loc.last_column = actual.last_column | 0;
+
+ if (actual.range) {
+ loc.range[0] = actual.range[0] | 0;
+ loc.range[1] = actual.range[1] | 0;
+ }
+ }
+
+ if (loc.first_line <= 0 || loc.last_line < loc.first_line) {
+ // plan B: heuristic using preceding and following:
+ if (loc.first_line <= 0 && preceding) {
+ loc.first_line = preceding.last_line | 0;
+ loc.first_column = preceding.last_column | 0;
+
+ if (preceding.range) {
+ loc.range[0] = actual.range[1] | 0;
+ }
+ }
+
+ if ((loc.last_line <= 0 || loc.last_line < loc.first_line) && following) {
+ loc.last_line = following.first_line | 0;
+ loc.last_column = following.first_column | 0;
+
+ if (following.range) {
+ loc.range[1] = actual.range[0] | 0;
+ }
+ }
+
+ // plan C?: see if the 'current' location is useful/sane too:
+ if (loc.first_line <= 0 && current && (loc.last_line <= 0 || current.last_line <= loc.last_line)) {
+ loc.first_line = current.first_line | 0;
+ loc.first_column = current.first_column | 0;
+
+ if (current.range) {
+ loc.range[0] = current.range[0] | 0;
+ }
+ }
+
+ if (loc.last_line <= 0 && current && (loc.first_line <= 0 || current.first_line >= loc.first_line)) {
+ loc.last_line = current.last_line | 0;
+ loc.last_column = current.last_column | 0;
+
+ if (current.range) {
+ loc.range[1] = current.range[1] | 0;
+ }
+ }
+ }
+
+ // sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter
+ // or plan D heuristics to produce a 'sensible' last_line value:
+ if (loc.last_line <= 0) {
+ if (loc.first_line <= 0) {
+ loc.first_line = this.yylloc.first_line;
+ loc.last_line = this.yylloc.last_line;
+ loc.first_column = this.yylloc.first_column;
+ loc.last_column = this.yylloc.last_column;
+ loc.range[0] = this.yylloc.range[0];
+ loc.range[1] = this.yylloc.range[1];
+ } else {
+ loc.last_line = this.yylloc.last_line;
+ loc.last_column = this.yylloc.last_column;
+ loc.range[1] = this.yylloc.range[1];
+ }
+ }
+
+ if (loc.first_line <= 0) {
+ loc.first_line = loc.last_line;
+ loc.first_column = 0; // loc.last_column;
+ loc.range[1] = loc.range[0];
+ }
+
+ if (loc.first_column < 0) {
+ loc.first_column = 0;
+ }
+
+ if (loc.last_column < 0) {
+ loc.last_column = (loc.first_column > 0 ? loc.first_column : 80);
+ }
+
+ return loc;
+ },
+
+ /**
+ * return a string which displays the lines & columns of input which are referenced
+ * by the given location info range, plus a few lines of context.
+ *
+ * This function pretty-prints the indicated section of the input, with line numbers
+ * and everything!
+ *
+ * This function is very useful to provide highly readable error reports, while
+ * the location range may be specified in various flexible ways:
+ *
+ * - `loc` is the location info object which references the area which should be
+ * displayed and 'marked up': these lines & columns of text are marked up by `^`
+ * characters below each character in the entire input range.
+ *
+ * - `context_loc` is the *optional* location info object which instructs this
+ * pretty-printer how much *leading* context should be displayed alongside
+ * the area referenced by `loc`. This can help provide context for the displayed
+ * error, etc.
+ *
+ * When this location info is not provided, a default context of 3 lines is
+ * used.
+ *
+ * - `context_loc2` is another *optional* location info object, which serves
+ * a similar purpose to `context_loc`: it specifies the amount of *trailing*
+ * context lines to display in the pretty-print output.
+ *
+ * When this location info is not provided, a default context of 1 line only is
+ * used.
+ *
+ * Special Notes:
+ *
+ * - when the `loc`-indicated range is very large (about 5 lines or more), then
+ * only the first and last few lines of this block are printed while a
+ * `...continued...` message will be printed between them.
+ *
+ * This serves the purpose of not printing a huge amount of text when the `loc`
+ * range happens to be huge: this way a manageable & readable output results
+ * for arbitrary large ranges.
+ *
+ * - this function can display lines of input which whave not yet been lexed.
+ * `prettyPrintRange()` can access the entire input!
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) {
+ loc = this.deriveLocationInfo(loc, context_loc, context_loc2);
+ const CONTEXT = 3;
+ const CONTEXT_TAIL = 1;
+ const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2;
+ var input = this.matched + this._input;
+ var lines = input.split('\n');
+ var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT));
+ var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL));
+ var lineno_display_width = 1 + Math.log10(l1 | 1) | 0;
+ var ws_prefix = new Array(lineno_display_width).join(' ');
+ var nonempty_line_indexes = [];
+
+ var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) {
+ var lno = index + l0;
+ var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width);
+ var rv = lno_pfx + ': ' + line;
+ var errpfx = new Array(lineno_display_width + 1).join('^');
+ var offset = 2 + 1;
+ var len = 0;
+
+ if (lno === loc.first_line) {
+ offset += loc.first_column;
+
+ len = Math.max(
+ 2,
+ ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1
+ );
+ } else if (lno === loc.last_line) {
+ len = Math.max(2, loc.last_column + 1);
+ } else if (lno > loc.first_line && lno < loc.last_line) {
+ len = Math.max(2, line.length + 1);
+ }
+
+ if (len) {
+ var lead = new Array(offset).join('.');
+ var mark = new Array(len).join('^');
+ rv += '\n' + errpfx + lead + mark;
+
+ if (line.trim().length > 0) {
+ nonempty_line_indexes.push(index);
+ }
+ }
+
+ rv = rv.replace(/\t/g, ' ');
+ return rv;
+ });
+
+ // now make sure we don't print an overly large amount of error area: limit it
+ // to the top and bottom line count:
+ if (nonempty_line_indexes.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) {
+ var clip_start = nonempty_line_indexes[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1;
+ var clip_end = nonempty_line_indexes[nonempty_line_indexes.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1;
+ var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)';
+ intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)';
+ rv.splice(clip_start, clip_end - clip_start + 1, intermediate_line);
+ }
+
+ return rv.join('\n');
+ },
+
+ /**
+ * helper function, used to produce a human readable description as a string, given
+ * the input `yylloc` location object.
+ *
+ * Set `display_range_too` to TRUE to include the string character index position(s)
+ * in the description if the `yylloc.range` is available.
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) {
+ var l1 = yylloc.first_line;
+ var l2 = yylloc.last_line;
+ var c1 = yylloc.first_column;
+ var c2 = yylloc.last_column;
+ var dl = l2 - l1;
+ var dc = c2 - c1;
+ var rv;
+
+ if (dl === 0) {
+ rv = 'line ' + l1 + ', ';
+
+ if (dc <= 1) {
+ rv += 'column ' + c1;
+ } else {
+ rv += 'columns ' + c1 + ' .. ' + c2;
+ }
+ } else {
+ rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')';
+ }
+
+ if (yylloc.range && display_range_too) {
+ var r1 = yylloc.range[0];
+ var r2 = yylloc.range[1] - 1;
+
+ if (r2 <= r1) {
+ rv += ' {String Offset: ' + r1 + '}';
+ } else {
+ rv += ' {String Offset range: ' + r1 + ' .. ' + r2 + '}';
+ }
+ }
+
+ return rv;
+ },
+
+ /**
+ * test the lexed token: return FALSE when not a match, otherwise return token.
+ *
+ * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]`
+ * contains the actually matched text string.
+ *
+ * Also move the input cursor forward and update the match collectors:
+ *
+ * - `yytext`
+ * - `yyleng`
+ * - `match`
+ * - `matches`
+ * - `yylloc`
+ * - `offset`
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ test_match: function lexer_test_match(match, indexed_rule) {
+ var token, lines, backup, match_str, match_str_len;
+
+ if (this.options.backtrack_lexer) {
+ // save context
+ backup = {
+ yylineno: this.yylineno,
+
+ yylloc: {
+ first_line: this.yylloc.first_line,
+ last_line: this.yylloc.last_line,
+ first_column: this.yylloc.first_column,
+ last_column: this.yylloc.last_column,
+ range: this.yylloc.range.slice(0)
+ },
+
+ yytext: this.yytext,
+ match: this.match,
+ matches: this.matches,
+ matched: this.matched,
+ yyleng: this.yyleng,
+ offset: this.offset,
+ _more: this._more,
+ _input: this._input,
+
+ //_signaled_error_token: this._signaled_error_token,
+ yy: this.yy,
+
+ conditionStack: this.conditionStack.slice(0),
+ done: this.done
+ };
+ }
+
+ match_str = match[0];
+ match_str_len = match_str.length;
+
+ // if (match_str.indexOf('\n') !== -1 || match_str.indexOf('\r') !== -1) {
+ lines = match_str.split(/(?:\r\n?|\n)/g);
+
+ if (lines.length > 1) {
+ this.yylineno += lines.length - 1;
+ this.yylloc.last_line = this.yylineno + 1;
+ this.yylloc.last_column = lines[lines.length - 1].length;
+ } else {
+ this.yylloc.last_column += match_str_len;
+ }
+
+ // }
+ this.yytext += match_str;
+
+ this.match += match_str;
+ this.matched += match_str;
+ this.matches = match;
+ this.yyleng = this.yytext.length;
+ this.yylloc.range[1] += match_str_len;
+
+ // previous lex rules MAY have invoked the `more()` API rather than producing a token:
+ // those rules will already have moved this `offset` forward matching their match lengths,
+ // hence we must only add our own match length now:
+ this.offset += match_str_len;
+
+ this._more = false;
+ this._backtrack = false;
+ this._input = this._input.slice(match_str_len);
+
+ // calling this method:
+ //
+ // function lexer__performAction(yy, yyrulenumber, YY_START) {...}
+ token = this.performAction.call(
+ this,
+ this.yy,
+ indexed_rule,
+ this.conditionStack[this.conditionStack.length - 1] /* = YY_START */
+ );
+
+ // otherwise, when the action codes are all simple return token statements:
+ //token = this.simpleCaseActionClusters[indexed_rule];
+
+ if (this.done && this._input) {
+ this.done = false;
+ }
+
+ if (token) {
+ return token;
+ } else if (this._backtrack) {
+ // recover context
+ for (var k in backup) {
+ this[k] = backup[k];
+ }
+
+ this.__currentRuleSet__ = null;
+ return false; // rule action called reject() implying the next rule should be tested instead.
+ } else if (this._signaled_error_token) {
+ // produce one 'error' token as `.parseError()` in `reject()`
+ // did not guarantee a failure signal by throwing an exception!
+ token = this._signaled_error_token;
+
+ this._signaled_error_token = false;
+ return token;
+ }
+
+ return false;
+ },
+
+ /**
+ * return next match in input
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ next: function lexer_next() {
+ if (this.done) {
+ this.clear();
+ return this.EOF;
+ }
+
+ if (!this._input) {
+ this.done = true;
+ }
+
+ var token, match, tempMatch, index;
+
+ if (!this._more) {
+ this.clear();
+ }
+
+ var spec = this.__currentRuleSet__;
+
+ if (!spec) {
+ // Update the ruleset cache as we apparently encountered a state change or just started lexing.
+ // The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will
+ // invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps
+ // speed up those activities a tiny bit.
+ spec = this.__currentRuleSet__ = this._currentRules();
+
+ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against
+ // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19
+ if (!spec || !spec.rules) {
+ var lineno_msg = '';
+
+ if (this.options.trackPosition) {
+ lineno_msg = ' on line ' + (this.yylineno + 1);
+ }
+
+ var p = this.constructLexErrorInfo(
+ '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!',
+ false
+ );
+
+ // produce one 'error' token until this situation has been resolved, most probably by parse termination!
+ return this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR;
+ }
+ }
+
+ var rule_ids = spec.rules;
+ var regexes = spec.__rule_regexes;
+ var len = spec.__rule_count;
+
+ // Note: the arrays are 1-based, while `len` itself is a valid index,
+ // hence the non-standard less-or-equal check in the next loop condition!
+ for (var i = 1; i <= len; i++) {
+ tempMatch = this._input.match(regexes[i]);
+
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
+ match = tempMatch;
+ index = i;
+
+ if (this.options.backtrack_lexer) {
+ token = this.test_match(tempMatch, rule_ids[i]);
+
+ if (token !== false) {
+ return token;
+ } else if (this._backtrack) {
+ match = undefined;
+ continue; // rule action called reject() implying a rule MISmatch.
+ } else {
+ // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
+ return false;
+ }
+ } else if (!this.options.flex) {
+ break;
+ }
+ }
+ }
+
+ if (match) {
+ token = this.test_match(match, rule_ids[index]);
+
+ if (token !== false) {
+ return token;
+ }
+
+ // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
+ return false;
+ }
+
+ if (!this._input) {
+ this.done = true;
+ this.clear();
+ return this.EOF;
+ } else {
+ var lineno_msg = '';
+
+ if (this.options.trackPosition) {
+ lineno_msg = ' on line ' + (this.yylineno + 1);
+ }
+
+ var p = this.constructLexErrorInfo(
+ 'Lexical error' + lineno_msg + ': Unrecognized text.',
+ this.options.lexerErrorsAreRecoverable
+ );
+
+ var pendingInput = this._input;
+ var activeCondition = this.topState();
+ var conditionStackDepth = this.conditionStack.length;
+ token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR;
+
+ if (token === this.ERROR) {
+ // we can try to recover from a lexer error that `parseError()` did not 'recover' for us
+ // by moving forward at least one character at a time IFF the (user-specified?) `parseError()`
+ // has not consumed/modified any pending input or changed state in the error handler:
+ if (!this.matches && // and make sure the input has been modified/consumed ...
+ pendingInput === this._input && // ...or the lexer state has been modified significantly enough
+ // to merit a non-consuming error handling action right now.
+ activeCondition === this.topState() && conditionStackDepth === this.conditionStack.length) {
+ this.input();
+ }
+ }
+
+ return token;
+ }
+ },
+
+ /**
+ * return next match that has a token
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ lex: function lexer_lex() {
+ var r;
+
+ // allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer:
+ if (typeof this.pre_lex === 'function') {
+ r = this.pre_lex.call(this, 0);
+ }
+
+ if (typeof this.options.pre_lex === 'function') {
+ // (also account for a userdef function which does not return any value: keep the token as is)
+ r = this.options.pre_lex.call(this, r) || r;
+ }
+
+ if (this.yy && typeof this.yy.pre_lex === 'function') {
+ // (also account for a userdef function which does not return any value: keep the token as is)
+ r = this.yy.pre_lex.call(this, r) || r;
+ }
+
+ while (!r) {
+ r = this.next();
+ }
+
+ if (this.yy && typeof this.yy.post_lex === 'function') {
+ // (also account for a userdef function which does not return any value: keep the token as is)
+ r = this.yy.post_lex.call(this, r) || r;
+ }
+
+ if (typeof this.options.post_lex === 'function') {
+ // (also account for a userdef function which does not return any value: keep the token as is)
+ r = this.options.post_lex.call(this, r) || r;
+ }
+
+ if (typeof this.post_lex === 'function') {
+ // (also account for a userdef function which does not return any value: keep the token as is)
+ r = this.post_lex.call(this, r) || r;
+ }
+
+ return r;
+ },
+
+ /**
+ * return next match that has a token. Identical to the `lex()` API but does not invoke any of the
+ * `pre_lex()` nor any of the `post_lex()` callbacks.
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ fastLex: function lexer_fastLex() {
+ var r;
+
+ while (!r) {
+ r = this.next();
+ }
+
+ return r;
+ },
+
+ /**
+ * return info about the lexer state that can help a parser or other lexer API user to use the
+ * most efficient means available. This API is provided to aid run-time performance for larger
+ * systems which employ this lexer.
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ canIUse: function lexer_canIUse() {
+ var rv = {
+ 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'
+ };
+
+ return rv;
+ },
+
+ /**
+ * backwards compatible alias for `pushState()`;
+ * the latter is symmetrical with `popState()` and we advise to use
+ * those APIs in any modern lexer code, rather than `begin()`.
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ begin: function lexer_begin(condition) {
+ return this.pushState(condition);
+ },
+
+ /**
+ * activates a new lexer condition state (pushes the new lexer
+ * condition state onto the condition stack)
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ pushState: function lexer_pushState(condition) {
+ this.conditionStack.push(condition);
+ this.__currentRuleSet__ = null;
+ return this;
+ },
+
+ /**
+ * pop the previously active lexer condition state off the condition
+ * stack
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ popState: function lexer_popState() {
+ var n = this.conditionStack.length - 1;
+
+ if (n > 0) {
+ this.__currentRuleSet__ = null;
+ return this.conditionStack.pop();
+ } else {
+ return this.conditionStack[0];
+ }
+ },
+
+ /**
+ * return the currently active lexer condition state; when an index
+ * argument is provided it produces the N-th previous condition state,
+ * if available
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ topState: function lexer_topState(n) {
+ n = this.conditionStack.length - 1 - Math.abs(n || 0);
+
+ if (n >= 0) {
+ return this.conditionStack[n];
+ } else {
+ return 'INITIAL';
+ }
+ },
+
+ /**
+ * (internal) determine the lexer rule set which is active for the
+ * currently active lexer condition state
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ _currentRules: function lexer__currentRules() {
+ if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
+ return this.conditions[this.conditionStack[this.conditionStack.length - 1]];
+ } else {
+ return this.conditions['INITIAL'];
+ }
+ },
+
+ /**
+ * return the number of states currently on the stack
+ *
+ * @public
+ * @this {RegExpLexer}
+ */
+ stateStackSize: function lexer_stateStackSize() {
+ return this.conditionStack.length;
+ },
+
+ options: {
+ trackPosition: true
+ },
+
+ JisonLexerError: JisonLexerError,
+
+ performAction: function lexer__performAction(yy, yyrulenumber, YY_START) {
+ var yy_ = this;
+ var YYSTATE = YY_START;
+
+ switch (yyrulenumber) {
+ case 1:
+ /*! Conditions:: INITIAL */
+ /*! Rule:: \s+ */
+ /* skip whitespace */
+ break;
+
+ default:
+ return this.simpleCaseActionClusters[yyrulenumber];
+ }
+ },
+
+ simpleCaseActionClusters: {
+ /*! Conditions:: INITIAL */
+ /*! Rule:: (--[0-9a-z-A-Z-]*) */
+ 0: 13,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: \* */
+ 2: 5,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: \/ */
+ 3: 6,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: \+ */
+ 4: 3,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: - */
+ 5: 4,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)px\b */
+ 6: 15,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)cm\b */
+ 7: 15,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)mm\b */
+ 8: 15,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)in\b */
+ 9: 15,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)pt\b */
+ 10: 15,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)pc\b */
+ 11: 15,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)deg\b */
+ 12: 16,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)grad\b */
+ 13: 16,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)rad\b */
+ 14: 16,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)turn\b */
+ 15: 16,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)s\b */
+ 16: 17,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)ms\b */
+ 17: 17,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)Hz\b */
+ 18: 18,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)kHz\b */
+ 19: 18,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)dpi\b */
+ 20: 19,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)dpcm\b */
+ 21: 19,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)dppx\b */
+ 22: 19,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)em\b */
+ 23: 20,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)ex\b */
+ 24: 21,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)ch\b */
+ 25: 22,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)rem\b */
+ 26: 23,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)vw\b */
+ 27: 25,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)vh\b */
+ 28: 24,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)vmin\b */
+ 29: 26,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)vmax\b */
+ 30: 27,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)% */
+ 31: 28,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)\b */
+ 32: 11,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: (calc) */
+ 33: 9,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: (var) */
+ 34: 12,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: ([a-z]+) */
+ 35: 10,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: \( */
+ 36: 7,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: \) */
+ 37: 8,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: , */
+ 38: 14,
+
+ /*! Conditions:: INITIAL */
+ /*! Rule:: $ */
+ 39: 1
+ },
+
+ rules: [
+ /* 0: */ /^(?:(--[\d\-A-Za-z]*))/,
+ /* 1: */ /^(?:\s+)/,
+ /* 2: */ /^(?:\*)/,
+ /* 3: */ /^(?:\/)/,
+ /* 4: */ /^(?:\+)/,
+ /* 5: */ /^(?:-)/,
+ /* 6: */ /^(?:(\d+(\.\d*)?|\.\d+)px\b)/,
+ /* 7: */ /^(?:(\d+(\.\d*)?|\.\d+)cm\b)/,
+ /* 8: */ /^(?:(\d+(\.\d*)?|\.\d+)mm\b)/,
+ /* 9: */ /^(?:(\d+(\.\d*)?|\.\d+)in\b)/,
+ /* 10: */ /^(?:(\d+(\.\d*)?|\.\d+)pt\b)/,
+ /* 11: */ /^(?:(\d+(\.\d*)?|\.\d+)pc\b)/,
+ /* 12: */ /^(?:(\d+(\.\d*)?|\.\d+)deg\b)/,
+ /* 13: */ /^(?:(\d+(\.\d*)?|\.\d+)grad\b)/,
+ /* 14: */ /^(?:(\d+(\.\d*)?|\.\d+)rad\b)/,
+ /* 15: */ /^(?:(\d+(\.\d*)?|\.\d+)turn\b)/,
+ /* 16: */ /^(?:(\d+(\.\d*)?|\.\d+)s\b)/,
+ /* 17: */ /^(?:(\d+(\.\d*)?|\.\d+)ms\b)/,
+ /* 18: */ /^(?:(\d+(\.\d*)?|\.\d+)Hz\b)/,
+ /* 19: */ /^(?:(\d+(\.\d*)?|\.\d+)kHz\b)/,
+ /* 20: */ /^(?:(\d+(\.\d*)?|\.\d+)dpi\b)/,
+ /* 21: */ /^(?:(\d+(\.\d*)?|\.\d+)dpcm\b)/,
+ /* 22: */ /^(?:(\d+(\.\d*)?|\.\d+)dppx\b)/,
+ /* 23: */ /^(?:(\d+(\.\d*)?|\.\d+)em\b)/,
+ /* 24: */ /^(?:(\d+(\.\d*)?|\.\d+)ex\b)/,
+ /* 25: */ /^(?:(\d+(\.\d*)?|\.\d+)ch\b)/,
+ /* 26: */ /^(?:(\d+(\.\d*)?|\.\d+)rem\b)/,
+ /* 27: */ /^(?:(\d+(\.\d*)?|\.\d+)vw\b)/,
+ /* 28: */ /^(?:(\d+(\.\d*)?|\.\d+)vh\b)/,
+ /* 29: */ /^(?:(\d+(\.\d*)?|\.\d+)vmin\b)/,
+ /* 30: */ /^(?:(\d+(\.\d*)?|\.\d+)vmax\b)/,
+ /* 31: */ /^(?:(\d+(\.\d*)?|\.\d+)%)/,
+ /* 32: */ /^(?:(\d+(\.\d*)?|\.\d+)\b)/,
+ /* 33: */ /^(?:(calc))/,
+ /* 34: */ /^(?:(var))/,
+ /* 35: */ /^(?:([a-z]+))/,
+ /* 36: */ /^(?:\()/,
+ /* 37: */ /^(?:\))/,
+ /* 38: */ /^(?:,)/,
+ /* 39: */ /^(?:$)/
+ ],
+
+ conditions: {
+ 'INITIAL': {
+ rules: [
+ 0,
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12,
+ 13,
+ 14,
+ 15,
+ 16,
+ 17,
+ 18,
+ 19,
+ 20,
+ 21,
+ 22,
+ 23,
+ 24,
+ 25,
+ 26,
+ 27,
+ 28,
+ 29,
+ 30,
+ 31,
+ 32,
+ 33,
+ 34,
+ 35,
+ 36,
+ 37,
+ 38,
+ 39
+ ],
+
+ inclusive: true
+ }
+ }
+ };
+
+ return lexer;
+}();
+parser.lexer = lexer;
+
+
+
+function Parser() {
+ this.yy = {};
+}
+Parser.prototype = parser;
+parser.Parser = Parser;
+
+return new Parser();
+})();
+
+
+
+
+if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
+ exports.parser = parser;
+ exports.Parser = parser.Parser;
+ exports.parse = function () {
+ return parser.parse.apply(parser, arguments);
+ };
+
+}
diff --git a/node_modules/reduce-css-calc/index.js b/node_modules/reduce-css-calc/index.js
deleted file mode 100755
index 3ec72471..00000000
--- a/node_modules/reduce-css-calc/index.js
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- * Module dependencies
- */
-var balanced = require("balanced-match")
-var reduceFunctionCall = require("reduce-function-call")
-var mexp = require("math-expression-evaluator")
-
-/**
- * Constantes
- */
-var MAX_STACK = 100 // should be enough for a single calc()...
-var NESTED_CALC_RE = /(\+|\-|\*|\\|[^a-z]|)(\s*)(\()/g
-
-/**
- * Global variables
- */
-var stack
-
-/**
- * Expose reduceCSSCalc plugin
- *
- * @type {Function}
- */
-module.exports = reduceCSSCalc
-
-/**
- * Reduce CSS calc() in a string, whenever it's possible
- *
- * @param {String} value css input
- */
-function reduceCSSCalc(value, decimalPrecision) {
- stack = 0
- decimalPrecision = Math.pow(10, decimalPrecision === undefined ? 5 : decimalPrecision)
-
- // Allow calc() on multiple lines
- value = value.replace(/\n+/g, " ")
-
- /**
- * Evaluates an expression
- *
- * @param {String} expression
- * @returns {String}
- */
- function evaluateExpression (expression, functionIdentifier, call) {
- if (stack++ > MAX_STACK) {
- stack = 0
- throw new Error("Call stack overflow for " + call)
- }
-
- if (expression === "") {
- throw new Error(functionIdentifier + "(): '" + call + "' must contain a non-whitespace string")
- }
-
- expression = evaluateNestedExpression(expression, call)
-
- var units = getUnitsInExpression(expression)
-
- // If the expression contains multiple units or CSS variables,
- // then let the expression be (i.e. browser calc())
- if (units.length > 1 || expression.indexOf("var(") > -1) {
- return functionIdentifier + "(" + expression + ")"
- }
-
- var unit = units[0] || ""
-
- if (unit === "%") {
- // Convert percentages to numbers, to handle expressions like: 50% * 50% (will become: 25%):
- // console.log(expression)
- expression = expression.replace(/\b[0-9\.]+%/g, function(percent) {
- return parseFloat(percent.slice(0, -1)) * 0.01
- })
- }
-
- // Remove units in expression:
- var toEvaluate = expression.replace(new RegExp(unit, "gi"), "")
- var result
-
- try {
- result = mexp.eval(toEvaluate)
- }
- catch (e) {
- return functionIdentifier + "(" + expression + ")"
- }
-
- // Transform back to a percentage result:
- if (unit === "%") {
- result *= 100
- }
-
- // adjust rounding shit
- // (0.1 * 0.2 === 0.020000000000000004)
- if (functionIdentifier.length || unit === "%") {
- result = Math.round(result * decimalPrecision) / decimalPrecision
- }
-
- // Add unit
- result += unit
-
- return result
- }
-
- /**
- * Evaluates nested expressions
- *
- * @param {String} expression
- * @returns {String}
- */
- function evaluateNestedExpression(expression, call) {
- // Remove the calc part from nested expressions to ensure
- // better browser compatibility
- expression = expression.replace(/((?:\-[a-z]+\-)?calc)/g, "")
- var evaluatedPart = ""
- var nonEvaluatedPart = expression
- var matches
- while ((matches = NESTED_CALC_RE.exec(nonEvaluatedPart))) {
- if (matches[0].index > 0) {
- evaluatedPart += nonEvaluatedPart.substring(0, matches[0].index)
- }
-
- var balancedExpr = balanced("(", ")", nonEvaluatedPart.substring([0].index))
- if (balancedExpr.body === "") {
- throw new Error("'" + expression + "' must contain a non-whitespace string")
- }
-
- var evaluated = evaluateExpression(balancedExpr.body, "", call)
-
- evaluatedPart += balancedExpr.pre + evaluated
- nonEvaluatedPart = balancedExpr.post
- }
-
- return evaluatedPart + nonEvaluatedPart
- }
-
- return reduceFunctionCall(value, /((?:\-[a-z]+\-)?calc)\(/, evaluateExpression)
-}
-
-/**
- * Checks what units are used in an expression
- *
- * @param {String} expression
- * @returns {Array}
- */
-
-function getUnitsInExpression(expression) {
- var uniqueUnits = []
- var uniqueLowerCaseUnits = []
- var unitRegEx = /[\.0-9]([%a-z]+)/gi
- var matches = unitRegEx.exec(expression)
-
- while (matches) {
- if (!matches || !matches[1]) {
- continue
- }
-
- if (uniqueLowerCaseUnits.indexOf(matches[1].toLowerCase()) === -1) {
- uniqueUnits.push(matches[1])
- uniqueLowerCaseUnits.push(matches[1].toLowerCase())
- }
-
- matches = unitRegEx.exec(expression)
- }
-
- return uniqueUnits
-}
diff --git a/node_modules/reduce-css-calc/node_modules/postcss-value-parser/LICENSE b/node_modules/reduce-css-calc/node_modules/postcss-value-parser/LICENSE
new file mode 100644
index 00000000..6dcaefcb
--- /dev/null
+++ b/node_modules/reduce-css-calc/node_modules/postcss-value-parser/LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) Bogdan Chadkin <trysound@yandex.ru>
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/reduce-css-calc/node_modules/postcss-value-parser/README.md b/node_modules/reduce-css-calc/node_modules/postcss-value-parser/README.md
new file mode 100644
index 00000000..0f3be478
--- /dev/null
+++ b/node_modules/reduce-css-calc/node_modules/postcss-value-parser/README.md
@@ -0,0 +1,253 @@
+# postcss-value-parser
+
+[![Travis CI](https://travis-ci.org/TrySound/postcss-value-parser.svg)](https://travis-ci.org/TrySound/postcss-value-parser)
+
+Transforms CSS declaration values and at-rule parameters into a tree of nodes, and provides a simple traversal API.
+
+## Usage
+
+```js
+var valueParser = require('postcss-value-parser');
+var cssBackgroundValue = 'url(foo.png) no-repeat 40px 73%';
+var parsedValue = valueParser(cssBackgroundValue);
+// parsedValue exposes an API described below,
+// e.g. parsedValue.walk(..), parsedValue.toString(), etc.
+```
+
+For example, parsing the value `rgba(233, 45, 66, .5)` will return the following:
+
+```js
+{
+ nodes: [
+ {
+ type: 'function',
+ value: 'rgba',
+ before: '',
+ after: '',
+ nodes: [
+ { type: 'word', value: '233' },
+ { type: 'div', value: ',', before: '', after: ' ' },
+ { type: 'word', value: '45' },
+ { type: 'div', value: ',', before: '', after: ' ' },
+ { type: 'word', value: '66' },
+ { type: 'div', value: ',', before: ' ', after: '' },
+ { type: 'word', value: '.5' }
+ ]
+ }
+ ]
+}
+```
+
+If you wanted to convert each `rgba()` value in `sourceCSS` to a hex value, you could do so like this:
+
+```js
+var valueParser = require('postcss-value-parser');
+
+var parsed = valueParser(sourceCSS);
+
+// walk() will visit all the of the nodes in the tree,
+// invoking the callback for each.
+parsed.walk(function (node) {
+
+ // Since we only want to transform rgba() values,
+ // we can ignore anything else.
+ if (node.type !== 'function' && node.value !== 'rgba') return;
+
+ // We can make an array of the rgba() arguments to feed to a
+ // convertToHex() function
+ var color = node.nodes.filter(function (node) {
+ return node.type === 'word';
+ }).map(function (node) {
+ return Number(node.value);
+ }); // [233, 45, 66, .5]
+
+ // Now we will transform the existing rgba() function node
+ // into a word node with the hex value
+ node.type = 'word';
+ node.value = convertToHex(color);
+})
+
+parsed.toString(); // #E92D42
+```
+
+## Nodes
+
+Each node is an object with these common properties:
+
+- **type**: The type of node (`word`, `string`, `div`, `space`, `comment`, or `function`).
+ Each type is documented below.
+- **value**: Each node has a `value` property; but what exactly `value` means
+ is specific to the node type. Details are documented for each type below.
+- **sourceIndex**: The starting index of the node within the original source
+ string. For example, given the source string `10px 20px`, the `word` node
+ whose value is `20px` will have a `sourceIndex` of `5`.
+
+### word
+
+The catch-all node type that includes keywords (e.g. `no-repeat`),
+quantities (e.g. `20px`, `75%`, `1.5`), and hex colors (e.g. `#e6e6e6`).
+
+Node-specific properties:
+
+- **value**: The "word" itself.
+
+### string
+
+A quoted string value, e.g. `"something"` in `content: "something";`.
+
+Node-specific properties:
+
+- **value**: The text content of the string.
+- **quote**: The quotation mark surrounding the string, either `"` or `'`.
+- **unclosed**: `true` if the string was not closed properly. e.g. `"unclosed string `.
+
+### div
+
+A divider, for example
+
+- `,` in `animation-duration: 1s, 2s, 3s`
+- `/` in `border-radius: 10px / 23px`
+- `:` in `(min-width: 700px)`
+
+Node-specific properties:
+
+- **value**: The divider character. Either `,`, `/`, or `:` (see examples above).
+- **before**: Whitespace before the divider.
+- **after**: Whitespace after the divider.
+
+### space
+
+Whitespace used as a separator, e.g. ` ` occurring twice in `border: 1px solid black;`.
+
+Node-specific properties:
+
+- **value**: The whitespace itself.
+
+### comment
+
+A CSS comment starts with `/*` and ends with `*/`
+
+Node-specific properties:
+
+- **value**: The comment value without `/*` and `*/`
+- **unclosed**: `true` if the comment was not closed properly. e.g. `/* comment without an end `.
+
+### function
+
+A CSS function, e.g. `rgb(0,0,0)` or `url(foo.bar)`.
+
+Function nodes have nodes nested within them: the function arguments.
+
+Additional properties:
+
+- **value**: The name of the function, e.g. `rgb` in `rgb(0,0,0)`.
+- **before**: Whitespace after the opening parenthesis and before the first argument,
+ e.g. ` ` in `rgb( 0,0,0)`.
+- **after**: Whitespace before the closing parenthesis and after the last argument,
+ e.g. ` ` in `rgb(0,0,0 )`.
+- **nodes**: More nodes representing the arguments to the function.
+- **unclosed**: `true` if the parentheses was not closed properly. e.g. `( unclosed-function `.
+
+Media features surrounded by parentheses are considered functions with an
+empty value. For example, `(min-width: 700px)` parses to these nodes:
+
+```js
+[
+ {
+ type: 'function', value: '', before: '', after: '',
+ nodes: [
+ { type: 'word', value: 'min-width' },
+ { type: 'div', value: ':', before: '', after: ' ' },
+ { type: 'word', value: '700px' }
+ ]
+ }
+]
+```
+
+`url()` functions can be parsed a little bit differently depending on
+whether the first character in the argument is a quotation mark.
+
+`url( /gfx/img/bg.jpg )` parses to:
+
+```js
+{ type: 'function', sourceIndex: 0, value: 'url', before: ' ', after: ' ', nodes: [
+ { type: 'word', sourceIndex: 5, value: '/gfx/img/bg.jpg' }
+] }
+```
+
+`url( "/gfx/img/bg.jpg" )`, on the other hand, parses to:
+
+```js
+{ type: 'function', sourceIndex: 0, value: 'url', before: ' ', after: ' ', nodes: [
+ type: 'string', sourceIndex: 5, quote: '"', value: '/gfx/img/bg.jpg' },
+] }
+```
+
+## API
+
+```
+var valueParser = require('postcss-value-parser');
+```
+
+### valueParser.unit(quantity)
+
+Parses `quantity`, distinguishing the number from the unit. Returns an object like the following:
+
+```js
+// Given 2rem
+{
+ number: '2',
+ unit: 'rem'
+}
+```
+
+If the `quantity` argument cannot be parsed as a number, returns `false`.
+
+*This function does not parse complete values*: you cannot pass it `1px solid black` and expect `px` as
+the unit. Instead, you should pass it single quantities only. Parse `1px solid black`, then pass it
+the stringified `1px` node (a `word` node) to parse the number and unit.
+
+### valueParser.stringify(nodes[, custom])
+
+Stringifies a node or array of nodes.
+
+The `custom` function is called for each `node`; return a string to override the default behaviour.
+
+### valueParser.walk(nodes, callback[, bubble])
+
+Walks each provided node, recursively walking all descendent nodes within functions.
+
+Returning `false` in the `callback` will prevent traversal of descendent nodes (within functions).
+You can use this feature to for shallow iteration, walking over only the *immediate* children.
+*Note: This only applies if `bubble` is `false` (which is the default).*
+
+By default, the tree is walked from the outermost node inwards.
+To reverse the direction, pass `true` for the `bubble` argument.
+
+The `callback` is invoked with three arguments: `callback(node, index, nodes)`.
+
+- `node`: The current node.
+- `index`: The index of the current node.
+- `nodes`: The complete nodes array passed to `walk()`.
+
+Returns the `valueParser` instance.
+
+### var parsed = valueParser(value)
+
+Returns the parsed node tree.
+
+### parsed.nodes
+
+The array of nodes.
+
+### parsed.toString()
+
+Stringifies the node tree.
+
+### parsed.walk(callback[, bubble])
+
+Walks each node inside `parsed.nodes`. See the documentation for `valueParser.walk()` above.
+
+# License
+
+MIT © [Bogdan Chadkin](mailto:trysound@yandex.ru)
diff --git a/node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/index.js b/node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/index.js
new file mode 100644
index 00000000..f9ac0e68
--- /dev/null
+++ b/node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/index.js
@@ -0,0 +1,28 @@
+var parse = require("./parse");
+var walk = require("./walk");
+var stringify = require("./stringify");
+
+function ValueParser(value) {
+ if (this instanceof ValueParser) {
+ this.nodes = parse(value);
+ return this;
+ }
+ return new ValueParser(value);
+}
+
+ValueParser.prototype.toString = function() {
+ return Array.isArray(this.nodes) ? stringify(this.nodes) : "";
+};
+
+ValueParser.prototype.walk = function(cb, bubble) {
+ walk(this.nodes, cb, bubble);
+ return this;
+};
+
+ValueParser.unit = require("./unit");
+
+ValueParser.walk = walk;
+
+ValueParser.stringify = stringify;
+
+module.exports = ValueParser;
diff --git a/node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/parse.js b/node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/parse.js
new file mode 100644
index 00000000..50d1fe9c
--- /dev/null
+++ b/node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/parse.js
@@ -0,0 +1,251 @@
+var openParentheses = "(".charCodeAt(0);
+var closeParentheses = ")".charCodeAt(0);
+var singleQuote = "'".charCodeAt(0);
+var doubleQuote = '"'.charCodeAt(0);
+var backslash = "\\".charCodeAt(0);
+var slash = "/".charCodeAt(0);
+var comma = ",".charCodeAt(0);
+var colon = ":".charCodeAt(0);
+var star = "*".charCodeAt(0);
+
+module.exports = function(input) {
+ var tokens = [];
+ var value = input;
+
+ var next, quote, prev, token, escape, escapePos, whitespacePos;
+ var pos = 0;
+ var code = value.charCodeAt(pos);
+ var max = value.length;
+ var stack = [{ nodes: tokens }];
+ var balanced = 0;
+ var parent;
+
+ var name = "";
+ var before = "";
+ var after = "";
+
+ while (pos < max) {
+ // Whitespaces
+ if (code <= 32) {
+ next = pos;
+ do {
+ next += 1;
+ code = value.charCodeAt(next);
+ } while (code <= 32);
+ token = value.slice(pos, next);
+
+ prev = tokens[tokens.length - 1];
+ if (code === closeParentheses && balanced) {
+ after = token;
+ } else if (prev && prev.type === "div") {
+ prev.after = token;
+ } else if (
+ code === comma ||
+ code === colon ||
+ (code === slash && value.charCodeAt(next + 1) !== star)
+ ) {
+ before = token;
+ } else {
+ tokens.push({
+ type: "space",
+ sourceIndex: pos,
+ value: token
+ });
+ }
+
+ pos = next;
+
+ // Quotes
+ } else if (code === singleQuote || code === doubleQuote) {
+ next = pos;
+ quote = code === singleQuote ? "'" : '"';
+ token = {
+ type: "string",
+ sourceIndex: pos,
+ quote: quote
+ };
+ do {
+ escape = false;
+ next = value.indexOf(quote, next + 1);
+ if (~next) {
+ escapePos = next;
+ while (value.charCodeAt(escapePos - 1) === backslash) {
+ escapePos -= 1;
+ escape = !escape;
+ }
+ } else {
+ value += quote;
+ next = value.length - 1;
+ token.unclosed = true;
+ }
+ } while (escape);
+ token.value = value.slice(pos + 1, next);
+
+ tokens.push(token);
+ pos = next + 1;
+ code = value.charCodeAt(pos);
+
+ // Comments
+ } else if (code === slash && value.charCodeAt(pos + 1) === star) {
+ token = {
+ type: "comment",
+ sourceIndex: pos
+ };
+
+ next = value.indexOf("*/", pos);
+ if (next === -1) {
+ token.unclosed = true;
+ next = value.length;
+ }
+
+ token.value = value.slice(pos + 2, next);
+ tokens.push(token);
+
+ pos = next + 2;
+ code = value.charCodeAt(pos);
+
+ // Dividers
+ } else if (code === slash || code === comma || code === colon) {
+ token = value[pos];
+
+ tokens.push({
+ type: "div",
+ sourceIndex: pos - before.length,
+ value: token,
+ before: before,
+ after: ""
+ });
+ before = "";
+
+ pos += 1;
+ code = value.charCodeAt(pos);
+
+ // Open parentheses
+ } else if (openParentheses === code) {
+ // Whitespaces after open parentheses
+ next = pos;
+ do {
+ next += 1;
+ code = value.charCodeAt(next);
+ } while (code <= 32);
+ token = {
+ type: "function",
+ sourceIndex: pos - name.length,
+ value: name,
+ before: value.slice(pos + 1, next)
+ };
+ pos = next;
+
+ if (name === "url" && code !== singleQuote && code !== doubleQuote) {
+ next -= 1;
+ do {
+ escape = false;
+ next = value.indexOf(")", next + 1);
+ if (~next) {
+ escapePos = next;
+ while (value.charCodeAt(escapePos - 1) === backslash) {
+ escapePos -= 1;
+ escape = !escape;
+ }
+ } else {
+ value += ")";
+ next = value.length - 1;
+ token.unclosed = true;
+ }
+ } while (escape);
+ // Whitespaces before closed
+ whitespacePos = next;
+ do {
+ whitespacePos -= 1;
+ code = value.charCodeAt(whitespacePos);
+ } while (code <= 32);
+ if (pos !== whitespacePos + 1) {
+ token.nodes = [
+ {
+ type: "word",
+ sourceIndex: pos,
+ value: value.slice(pos, whitespacePos + 1)
+ }
+ ];
+ } else {
+ token.nodes = [];
+ }
+ if (token.unclosed && whitespacePos + 1 !== next) {
+ token.after = "";
+ token.nodes.push({
+ type: "space",
+ sourceIndex: whitespacePos + 1,
+ value: value.slice(whitespacePos + 1, next)
+ });
+ } else {
+ token.after = value.slice(whitespacePos + 1, next);
+ }
+ pos = next + 1;
+ code = value.charCodeAt(pos);
+ tokens.push(token);
+ } else {
+ balanced += 1;
+ token.after = "";
+ tokens.push(token);
+ stack.push(token);
+ tokens = token.nodes = [];
+ parent = token;
+ }
+ name = "";
+
+ // Close parentheses
+ } else if (closeParentheses === code && balanced) {
+ pos += 1;
+ code = value.charCodeAt(pos);
+
+ parent.after = after;
+ after = "";
+ balanced -= 1;
+ stack.pop();
+ parent = stack[balanced];
+ tokens = parent.nodes;
+
+ // Words
+ } else {
+ next = pos;
+ do {
+ if (code === backslash) {
+ next += 1;
+ }
+ next += 1;
+ code = value.charCodeAt(next);
+ } while (
+ next < max &&
+ !(
+ code <= 32 ||
+ code === singleQuote ||
+ code === doubleQuote ||
+ code === comma ||
+ code === colon ||
+ code === slash ||
+ code === openParentheses ||
+ (code === closeParentheses && balanced)
+ )
+ );
+ token = value.slice(pos, next);
+
+ if (openParentheses === code) {
+ name = token;
+ } else {
+ tokens.push({
+ type: "word",
+ sourceIndex: pos,
+ value: token
+ });
+ }
+
+ pos = next;
+ }
+ }
+
+ for (pos = stack.length - 1; pos; pos -= 1) {
+ stack[pos].unclosed = true;
+ }
+
+ return stack[0].nodes;
+};
diff --git a/node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/stringify.js b/node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/stringify.js
new file mode 100644
index 00000000..5f2c845a
--- /dev/null
+++ b/node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/stringify.js
@@ -0,0 +1,48 @@
+function stringifyNode(node, custom) {
+ var type = node.type;
+ var value = node.value;
+ var buf;
+ var customResult;
+
+ if (custom && (customResult = custom(node)) !== undefined) {
+ return customResult;
+ } else if (type === "word" || type === "space") {
+ return value;
+ } else if (type === "string") {
+ buf = node.quote || "";
+ return buf + value + (node.unclosed ? "" : buf);
+ } else if (type === "comment") {
+ return "/*" + value + (node.unclosed ? "" : "*/");
+ } else if (type === "div") {
+ return (node.before || "") + value + (node.after || "");
+ } else if (Array.isArray(node.nodes)) {
+ buf = stringify(node.nodes);
+ if (type !== "function") {
+ return buf;
+ }
+ return (
+ value +
+ "(" +
+ (node.before || "") +
+ buf +
+ (node.after || "") +
+ (node.unclosed ? "" : ")")
+ );
+ }
+ return value;
+}
+
+function stringify(nodes, custom) {
+ var result, i;
+
+ if (Array.isArray(nodes)) {
+ result = "";
+ for (i = nodes.length - 1; ~i; i -= 1) {
+ result = stringifyNode(nodes[i], custom) + result;
+ }
+ return result;
+ }
+ return stringifyNode(nodes, custom);
+}
+
+module.exports = stringify;
diff --git a/node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/unit.js b/node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/unit.js
new file mode 100644
index 00000000..06a1f667
--- /dev/null
+++ b/node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/unit.js
@@ -0,0 +1,49 @@
+var minus = "-".charCodeAt(0);
+var plus = "+".charCodeAt(0);
+var dot = ".".charCodeAt(0);
+var exp = "e".charCodeAt(0);
+var EXP = "E".charCodeAt(0);
+
+module.exports = function(value) {
+ var pos = 0;
+ var length = value.length;
+ var dotted = false;
+ var sciPos = -1;
+ var containsNumber = false;
+ var code;
+
+ while (pos < length) {
+ code = value.charCodeAt(pos);
+
+ if (code >= 48 && code <= 57) {
+ containsNumber = true;
+ } else if (code === exp || code === EXP) {
+ if (sciPos > -1) {
+ break;
+ }
+ sciPos = pos;
+ } else if (code === dot) {
+ if (dotted) {
+ break;
+ }
+ dotted = true;
+ } else if (code === plus || code === minus) {
+ if (pos !== 0) {
+ break;
+ }
+ } else {
+ break;
+ }
+
+ pos += 1;
+ }
+
+ if (sciPos + 1 === pos) pos--;
+
+ return containsNumber
+ ? {
+ number: value.slice(0, pos),
+ unit: value.slice(pos)
+ }
+ : false;
+};
diff --git a/node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/walk.js b/node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/walk.js
new file mode 100644
index 00000000..7666c5b1
--- /dev/null
+++ b/node_modules/reduce-css-calc/node_modules/postcss-value-parser/lib/walk.js
@@ -0,0 +1,22 @@
+module.exports = function walk(nodes, cb, bubble) {
+ var i, max, node, result;
+
+ for (i = 0, max = nodes.length; i < max; i += 1) {
+ node = nodes[i];
+ if (!bubble) {
+ result = cb(node, i, nodes);
+ }
+
+ if (
+ result !== false &&
+ node.type === "function" &&
+ Array.isArray(node.nodes)
+ ) {
+ walk(node.nodes, cb, bubble);
+ }
+
+ if (bubble) {
+ cb(node, i, nodes);
+ }
+ }
+};
diff --git a/node_modules/reduce-css-calc/node_modules/postcss-value-parser/package.json b/node_modules/reduce-css-calc/node_modules/postcss-value-parser/package.json
new file mode 100644
index 00000000..14ae1dc7
--- /dev/null
+++ b/node_modules/reduce-css-calc/node_modules/postcss-value-parser/package.json
@@ -0,0 +1,58 @@
+{
+ "name": "postcss-value-parser",
+ "version": "3.3.1",
+ "description": "Transforms css values and at-rule params into the tree",
+ "main": "lib/index.js",
+ "files": [
+ "lib"
+ ],
+ "devDependencies": {
+ "eslint": "^5.6.1",
+ "husky": "^1.0.0",
+ "lint-staged": "^7.3.0",
+ "prettier": "^1.4.4",
+ "tap-spec": "^5.0.0",
+ "tape": "^4.2.0"
+ },
+ "scripts": {
+ "lint:prettier": "prettier '**/*.js' --list-different",
+ "lint:js": "eslint . --cache",
+ "lint": "yarn lint:js && yarn lint:prettier",
+ "pretest": "yarn lint",
+ "test": "tape test/*.js | tap-spec"
+ },
+ "eslintConfig": {
+ "env": {
+ "es6": true,
+ "node": true
+ },
+ "extends": "eslint:recommended"
+ },
+ "lint-staged": {
+ "*.js": [
+ "eslint",
+ "prettier --write",
+ "git add"
+ ]
+ },
+ "husky": {
+ "hooks": {
+ "pre-commit": "lint-staged"
+ }
+ },
+ "author": "Bogdan Chadkin <trysound@yandex.ru>",
+ "license": "MIT",
+ "homepage": "https://github.com/TrySound/postcss-value-parser",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/TrySound/postcss-value-parser.git"
+ },
+ "keywords": [
+ "postcss",
+ "value",
+ "parser"
+ ],
+ "bugs": {
+ "url": "https://github.com/TrySound/postcss-value-parser/issues"
+ }
+}
diff --git a/node_modules/reduce-css-calc/package.json b/node_modules/reduce-css-calc/package.json
index 6baa0601..e68caf24 100644
--- a/node_modules/reduce-css-calc/package.json
+++ b/node_modules/reduce-css-calc/package.json
@@ -1,33 +1,49 @@
{
"name": "reduce-css-calc",
- "version": "1.3.0",
+ "version": "2.1.8",
"description": "Reduce CSS calc() function to the maximum",
"keywords": [
"css",
"calculation",
"calc"
],
- "author": "Maxime Thirouin",
- "license": "MIT",
- "repository": "https://github.com/MoOx/reduce-css-calc.git",
+ "main": "dist/index.js",
"files": [
- "index.js"
+ "dist"
],
- "dependencies": {
- "balanced-match": "^0.4.2",
- "math-expression-evaluator": "^1.2.14",
- "reduce-function-call": "^1.0.1"
+ "scripts": {
+ "prepublish": "npm run build && del-cli dist/__tests__",
+ "build": "del-cli dist && cross-env BABEL_ENV=publish babel src --out-dir dist && jison parser.jison -o dist/parser.js",
+ "pretest": "eslint src && npm run build",
+ "test": "ava dist/__tests__/",
+ "release": "npmpub"
},
+ "author": "Maxime Thirouin",
+ "license": "MIT",
+ "repository": "https://github.com/MoOx/reduce-css-calc.git",
"devDependencies": {
- "jscs": "^1.5.9",
- "jshint": "^2.5.2",
- "npmpub": "^3.0.3",
- "tape": "^2.13.4"
+ "ava": "^0.18.2",
+ "babel-cli": "^6.18.0",
+ "babel-core": "^6.21.0",
+ "babel-eslint": "^7.1.1",
+ "babel-plugin-add-module-exports": "^0.2.1",
+ "babel-preset-env": "^1.6.0",
+ "babel-register": "^6.18.0",
+ "cross-env": "^3.1.4",
+ "del-cli": "^0.2.1",
+ "eslint": "^3.12.2",
+ "eslint-config-i-am-meticulous": "^6.0.1",
+ "eslint-plugin-babel": "^4.0.0",
+ "eslint-plugin-import": "^2.2.0",
+ "jison-gho": "^0.6.1-216",
+ "npmpub": "^5.0.0"
},
- "scripts": {
- "jscs": "jscs *.js **/*.js",
- "jshint": "jshint . --exclude node_modules",
- "test": "npm run jscs && npm run jshint && tape test",
- "release": "npmpub"
+ "dependencies": {
+ "css-unit-converter": "^1.1.1",
+ "postcss-value-parser": "^3.3.0"
+ },
+ "eslintConfig": {
+ "parser": "babel-eslint",
+ "extends": "eslint-config-i-am-meticulous"
}
}