View difference between Paste ID: y69vaQWm and c1yB9NJB
SHOW: | | - or go back to the newest paste.
1-
var parse = function (x) {
1+
//var isVar = vars[x[i]];
2-
    var temp = [];
2+
        //if (isVar != undefined) {
3-
    var pushUn = function (a) {
3+
        //    temp.push(variable(x[i]));
4-
        temp.push(a(temp.pop()));
4+
        //}
5-
    };
5+
        //else if (x[i] >= '0' && x[i] <= '9') {
6-
    function isNumber(n) {
6+
        //    temp.push(cnst(parseInt(x.substr(i))));
7-
        return !isNaN(parseFloat(n)) && isFinite(n);
7+
        //    while (x[i] != ' ' && i != x.length) {
8-
    }
8+
        //        i++;
9-
    var pushBi = function (a) {
9+
        //    }
10-
        var r = temp.pop();
10+
        //}
11-
        var l = temp.pop();
11+
        //else if (x[i] == '*') {
12-
        temp.push(a(l, r));
12+
        //    if (i != x.length - 1 && x[i + 1] == '*') {
13-
    };
13+
        //        pushBi(power);
14-
    var tokens = x.split(' ');
14+
        //        i += 1;
15-
    for (var i = 0; i < tokens.length; i++) {
15+
        //        continue;
16-
        if(tokens[i] in vars){
16+
        //    }
17-
            temp.push(variable(tokens[i]));
17+
        //    pushBi(multiply);
18-
        }
18+
        //}
19-
        else if(tokens[i] in binOps){
19+
        //else if (x[i] == '/') {
20-
            pushBi(binOps[tokens[i]]);
20+
        //    pushBi(divide);
21-
        }
21+
        //}
22-
        else if(tokens[i] in unOps){
22+
        //else if (x[i] == '+') {
23-
            pushUn(unOps[tokens[i]]);
23+
        //    pushBi(add);
24-
        }
24+
        //}
25-
        else if(isNumber(tokens[i])){
25+
        //else if (x[i] == '-') {
26-
            temp.push(cnst(parseInt(tokens[i])));
26+
        //    if (i != x.length - 1 && x[i + 1] >= '0' && x[i + 1] <= '9') {
27-
        }
27+
        //        temp.push(cnst(parseInt(x.substr(i))));
28-
    }
28+
        //        while (x[i] != ' ' && i != x.length) {
29-
    return temp.pop();
29+
        //            i++;
30-
};
30+
        //        }
31
        //        continue;
32
        //    }
33
        //    pushBi(subtract);
34
        //}
35
        //else if (x[i] == 'a') {
36
        //    pushUn(abs);
37
        //    i += 3;
38
        //}
39
        //else if (x[i] == 'l') {
40
        //    pushUn(log);
41
        //    i += 3;
42
        //}
43
        //else if (x[i] == '%') {
44
        //    pushBi(mod);
45
        //}
46
        //else if (x[i] == 'n') {
47
        //    pushUn(negate);
48
        //    i += 6;
49
        //}