Hi folks, i've searched and searched and can't find any example of
what i'm trying to do. Essentially (i think) i need to add a new
operator to Number.
I'm using eval to evaluate expressions that can be entered by users,
these expressions are defined by another app so i can't change the
format of the expressions. I've managed to support the majority of
operators by supplying my own functions that wrap the equivalent Math
functions but i'm struggling with a few.
I need to support mod, div, shl and shr which will be in the format:
x div y, x mod y, x shl y, x shr y
How can i add an operator to Number to handle these? Is it even
possible?
Or is there some another way i can support them?
I considered using regexp to replace the relevent bits but that got
pretty ugly when i started to look at the possibility of nesting.
Any help greatly appreciated.
Cheers!
what i'm trying to do. Essentially (i think) i need to add a new
operator to Number.
I'm using eval to evaluate expressions that can be entered by users,
these expressions are defined by another app so i can't change the
format of the expressions. I've managed to support the majority of
operators by supplying my own functions that wrap the equivalent Math
functions but i'm struggling with a few.
I need to support mod, div, shl and shr which will be in the format:
x div y, x mod y, x shl y, x shr y
How can i add an operator to Number to handle these? Is it even
possible?
Or is there some another way i can support them?
I considered using regexp to replace the relevent bits but that got
pretty ugly when i started to look at the possibility of nesting.
Any help greatly appreciated.
Cheers!
Comment