Skip to content

Commit 08c3375

Browse files
committed
fix n_1.*x
1 parent 0de30b0 commit 08c3375

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

scripts/parser.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ MathParser.exprToPostfix = function (expr, mathFunctions) {
363363
}
364364
expr = expr1s[0].s;
365365

366+
console.log(expr);
366367
// multiplication sign
367368
var expr1 = "";
368369
for (var i = 0; i < expr.length;) {
@@ -375,23 +376,25 @@ MathParser.exprToPostfix = function (expr, mathFunctions) {
375376
for (var j = 0; j < v.length;) {
376377
if (expr1.length > 0) {
377378
var expr1back = expr1[expr1.length-1];
379+
console.log(v, j, expr1, expr1back, has_);
378380
if ((/\)/.test(expr1back) && (
379381
/[A-Za-zΑ-Ωα-ω_\d\(]/.test(v[j]) ||
380382
(v[j]=="." && j+1<v.length && /\d/.test(v[j+1]))
381383
)) ||
382384
(j != 0 && /[A-Za-zΑ-Ωα-ω_\d\.\)]/.test(v[j-1])
383385
&& /\(/.test(v[j])))
384-
expr1 += "*";
385-
else if (!has_ && (
386+
expr1 += "*" , has_ = false;
387+
else if ((!has_ && (
386388
/[A-Za-zΑ-Ωα-ω]/.test(expr1back) ||
387-
/\d\.?$/.test(expr1)
389+
/\d\.$/.test(expr1)) ||
390+
/\d$/.test(expr1)
388391
) && (/[A-Za-zΑ-Ωα-ω]/.test(v[j]) ||
389392
(/^\.\d/.test(v.slice(j)) && !/[\d\.]/.test(expr1back)))
390393
&& v[j] != "_")
391-
expr1 += "*";
394+
expr1 += "*", has_ = false;
392395
else if (!has_ && /[A-Za-zΑ-Ωα-ω]/.test(expr1back)
393396
&& /\d/.test(v[j]))
394-
expr1 += "_";
397+
expr1 += "_", has_ = true;
395398
}
396399
var next_lp = v.substring(j, v.length).search(/\(/);
397400
if (next_lp != -1) {
@@ -417,6 +420,7 @@ MathParser.exprToPostfix = function (expr, mathFunctions) {
417420
}
418421
}
419422
expr = expr1;
423+
console.log(expr);
420424

421425
// unwanted plus sign
422426
expr = expr.replace(/\(\+/g, "(");

0 commit comments

Comments
 (0)