@fw-components/formula-editor 2.0.7-formula-editor.40 → 2.0.7-formula-editor.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -94,7 +94,7 @@ export class Parser {
|
|
|
94
94
|
expectation = Expectation.UNDEFINED;
|
|
95
95
|
}
|
|
96
96
|
else if (this.allowedOperators.has(previousToken) && isOperator) {
|
|
97
|
-
parseOutput.errorString = `Please use ${this.variableType}${this.allowedNumbers ? " or numbers" : ""} after '${previousToken}'. Pls do not use consecutive two mathametical operators (+
|
|
97
|
+
parseOutput.errorString = `Please use ${this.variableType}${this.allowedNumbers ? " or numbers" : ""} after '${previousToken}'. Pls do not use consecutive two mathametical operators (+ - * / ^)`;
|
|
98
98
|
expectation = Expectation.UNDEFINED;
|
|
99
99
|
}
|
|
100
100
|
else if (parentheses.isEmpty() && token === ")") {
|
|
@@ -114,7 +114,7 @@ export class Parser {
|
|
|
114
114
|
* Multiple number/variable together without operator
|
|
115
115
|
*/
|
|
116
116
|
else if (expectation === Expectation.OPERATOR && !isOperator && !isSpace && token != ")") {
|
|
117
|
-
parseOutput.errorString = `Please use mathametical operators (${Array.from(this.allowedOperators).join("
|
|
117
|
+
parseOutput.errorString = `Please use mathametical operators (${Array.from(this.allowedOperators).join(" ")}) after '${previousToken}'.`;
|
|
118
118
|
expectation = Expectation.UNDEFINED;
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
@@ -201,13 +201,13 @@ export class Parser {
|
|
|
201
201
|
operatorStack.push("(");
|
|
202
202
|
}
|
|
203
203
|
else if (token === ")") {
|
|
204
|
-
while (operatorStack.top() != "(") {
|
|
204
|
+
while (!operatorStack.isEmpty() && operatorStack.top() != "(") {
|
|
205
205
|
outputQueue.enqueue(operatorStack.pop());
|
|
206
206
|
}
|
|
207
207
|
operatorStack.pop();
|
|
208
208
|
}
|
|
209
209
|
else if (this.allowedOperators.has(token)) {
|
|
210
|
-
while (this.allowedOperators.has(operatorStack.top()) && operatorPrecedence[token] <= operatorPrecedence[operatorStack.top()]) {
|
|
210
|
+
while (!operatorStack.isEmpty() && this.allowedOperators.has(operatorStack.top()) && operatorPrecedence[token] <= operatorPrecedence[operatorStack.top()]) {
|
|
211
211
|
outputQueue.enqueue(operatorStack.pop());
|
|
212
212
|
}
|
|
213
213
|
operatorStack.push(token);
|
|
@@ -216,7 +216,7 @@ export class Parser {
|
|
|
216
216
|
outputQueue.enqueue(token);
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
-
while (operatorStack.top()) {
|
|
219
|
+
while (!operatorStack.isEmpty() && operatorStack.top()) {
|
|
220
220
|
outputQueue.enqueue(operatorStack.pop());
|
|
221
221
|
}
|
|
222
222
|
return outputQueue;
|
|
@@ -306,7 +306,7 @@ export class Parser {
|
|
|
306
306
|
calcStack.push(Big(numA).mul(Big(numB)));
|
|
307
307
|
break;
|
|
308
308
|
case "/":
|
|
309
|
-
if (
|
|
309
|
+
if (Big(numB).eq(0)) {
|
|
310
310
|
calculationResult.errorString = "Division by zero encountered";
|
|
311
311
|
return calculationResult;
|
|
312
312
|
}
|
|
@@ -322,6 +322,10 @@ export class Parser {
|
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
|
+
if (calcStack.isEmpty()) {
|
|
326
|
+
calculationResult.errorString = "Calculation error: Empty result stack";
|
|
327
|
+
return calculationResult;
|
|
328
|
+
}
|
|
325
329
|
calculationResult.result = parseFloat(calcStack.top().toString());
|
|
326
330
|
return calculationResult;
|
|
327
331
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fw-components/formula-editor",
|
|
3
|
-
"version": "2.0.7-formula-editor.
|
|
3
|
+
"version": "2.0.7-formula-editor.42",
|
|
4
4
|
"description": "A WYSIWYG type formula editor",
|
|
5
5
|
"main": "dist/formula-editor/src/formula-editor.js",
|
|
6
6
|
"exports": {
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"@types/big.js": "^6.1.6",
|
|
32
32
|
"es-dev-server": "^2.1.0"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "13003cbdce348fbc73c50bb9a650460f344b4b88"
|
|
35
35
|
}
|