Skip to content
This repository was archived by the owner on Jul 15, 2021. It is now read-only.

Commit 8806c9f

Browse files
committed
Merge branch 'release/1.0.14'
2 parents 96dbd88 + 79c046d commit 8806c9f

File tree

9 files changed

+88
-45
lines changed

9 files changed

+88
-45
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ always keep evaluated value. If error occurs `error` property will be set as:
6161
* `#NAME?` Not recognised function name or variable name;
6262
* `#N/A` Indicates that a value is not available to a formula;
6363
* `#NUM!` Occurs when formula encounters an invalid number;
64-
* `#VALUE?` Occurs when one of formula arguments is of the wrong type.
64+
* `#VALUE!` Occurs when one of formula arguments is of the wrong type.
6565

6666
```js
6767
parser.parse('(1 + 5 + (5 * 10)) / 10'); // returns `Object {error: null, result: 5.6}`

dist/formula-parser.js

Lines changed: 25 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formula-parser.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formula-parser.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formula-parser.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hot-formula-parser",
3-
"version": "1.0.13",
3+
"version": "1.0.14",
44
"description": "Formula parser",
55
"main": "dist/formula-parser.js",
66
"scripts": {

src/grammar-parser/grammar-parser.jison

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,10 @@ number
220220

221221
error
222222
: '#' VARIABLE '!' {
223-
$$ = $1 + $2 + $3;
223+
$$ = yy.throwError($1 + $2 + $3);
224224
}
225225
| VARIABLE '#' VARIABLE '!' {
226-
$$ = $2 + $3 + $4;
226+
$$ = yy.throwError($2 + $3 + $4);
227227
}
228228
;
229229

src/grammar-parser/grammar-parser.js

Lines changed: 34 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/parser.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Parser extends Emitter {
1919
toNumber,
2020
trimEdges,
2121
invertNumber,
22+
throwError: (errorName) => this._throwError(errorName),
2223
callVariable: (variable) => this._callVariable(variable),
2324
evaluateByOperator,
2425
callFunction: evaluateByOperator,
@@ -171,6 +172,23 @@ class Parser extends Emitter {
171172

172173
return value;
173174
}
175+
176+
/**
177+
* Try to throw error by its name.
178+
*
179+
* @param {String} errorName Error name.
180+
* @returns {String}
181+
* @private
182+
*/
183+
_throwError(errorName) {
184+
const parsedError = errorParser(errorName);
185+
186+
if (parsedError) {
187+
throw Error(parsedError);
188+
}
189+
190+
return errorName;
191+
}
174192
}
175193

176194
export {Parser};

0 commit comments

Comments
 (0)