Validate Syntax

Jul 30, 2010 at 2:50 AM

Is there a way to validate that a piece of Javascript is syntactically valid using Jint? I don't really want to execute the code; I just want to see if it is parse-able. I was hoping for something like this:


string source = "var myvar = 'hello'; alert(myvar);";

JintEngine engine = new JintEngine();
bool isValid = engine.Parse(source);

if (!isValid)
   throw new Exception();