validateFunction

Validates a function.

@trusted
bool
validateFunction
(
in dstring func
,
in dstring def
)

Parameters

func dstring

The function name and parameters.

def dstring

The definition of the function.

Return Value

Type: bool

Whether the function is valid or not.

Examples

/********************************************
* List of stuff that is invalid but crashes:
*
*     Whitespace
*     Preceding Operators
*     Invalid Operators and Characters
*/ 
dstring func = "(Number,Number)(Number)"d;
dstring def = "x1*x2"d;
assert(validateFunction(func, def));
func = "(Number,Number,Number)(Number)"d;
def = "x1*x2+x3"d;
assert(validateFunction(func, def));
def = "(x1"d;
assert(!validateFunction(func, def));
def = "(x1)"d;
assert(validateFunction(func, def));
def = "x1)"d;
assert(!validateFunction(func, def));
def = "x1x2"d;
assert(!validateFunction(func, def));
def = "x1+"d;
assert(!validateFunction(func, def));
def = "x1*x2"d;
func = "(Number,Number)(Number)"d;
assert(registerFunction("f"d, func, def));
//Functions within functions were too hard to implement, so we removed them.
//def =  "x1* f(x1,x2)(Number)"d;
//assert(validateFunction(func, def));

Meta