Well, I haven't gone through all your code to know if I'm changing the right thing, but for functions, I think you can add
.toLowerCase() to
Token in some places so that the code reads:
code:
if (typeof(Math[Token.toLowerCase()])=="function" || eval("typeof("+Token+")=='function'")) {
if (eval("typeof("+Token+")!='function'")) {
Token = "Math." + Token.toLowerCase()
}
(...)
I'm not sure what to do for properties though, because I don't know where these are evaluated.
Also, it seems that sometimes the values are approximated before further functions are performed on them. For example, "sin(PI)" doesn't return "0", but "1.22460635382238E-16" (really close to 0). I guess this doesn't matter too much, but it would be good if it returned "0".
As for the degrees, I think this works for sin, cos and tan (not sure about asin, acos, atan and atan2 though):
code:
for (Index in Params) {
Params[Index] = Params[Index].Calculate()
if(Degrees & /\b(cos|sin|tan)\b/.test(Token)) Params[Index] *= Math.PI / 180
}
Degrees is a global boolean.
EDIT: Found where to change for properties.
code:
if (typeof(Math[Operands[Index].toUpperCase()]) != "undefined" && typeof(Math[Operands[Index]]) != "function") {
Operands[Index] = Math[Operands[Index].toUpperCase()]
}
This time we use
.toUpperCase because the properties are uppercase.
EDIT #2: I've also just noticed that the calculate function will parse "1 + 2 + 3" and "1+(2+3)" but not "1+ (2+3)". Any way to fix that? (It seems to not parse if there is a space before the open bracket.)