Well, to check whether the basics are correct (correct number of arguments, open/close brackets, number of commas, etc) would not be difficult - you could easily cater for the nested IFs using recursive techniques.
But you would also need to tell us whether you also need to check whether the "condition" and "expression" syntax is correct?
And are commas or brackets, for example going to be legal inside an expression or condition? If so, you'll need to define your rules for string qualification, escape characters, etc, so your parser interprets these as being part of the expression or condition and doesn't confuse them as being control characters.
In its most simple form however, some psuedo-code:
var stmt = "IF(condition,expression,IF(condition,expr2,expr3))"
function checkIfSyntax(stmt){
var tokens = splitStmt(stmt); // careful to take into account where
// control chars (that is, commas and
// brackets) are qualified, escaped,
// or inside a nested IF()
checkCondition(tokens.condition); //with whatever rules you have, plus [1]
checkExpression(tokens.expr1); //with whatever rules, plus [1]
checkExpression(tokens.expr2); //with whatever rules, plus [1]
/* [1]: if any of the tokens are nested IF() statements,
call checkIfSyntax() from within checkCondition()
or checkExpression()
- (this is the recursive bit) */
}
This is just hopefully to get you on the right track. To actually answer your question fully would be to code it for you - I don't think anyone is going to do that. Try to understand the above as well as reading the links others have provided, and hopefully you should get on the right track