This project has moved. For the latest updates, please go here.

Parsing For Syntax Checks

Apr 25, 2012 at 12:18 PM

Hi - First off, fantastic work! I've been tinkering with Jurassic for several days and am very impressed.

In any case, I was wondering if there was any way to trigger the lexing/parsing of input without actually executing the code. My use case is that I'm creating a scripting component for a larger project and would like to provide users with immediate feedback (and perhaps reject their scripts) if they contain invalid syntax. Because I'll be providing several runtime globals for their use, I don't want to and probably can't go through the entire execution in order to check the syntax (since the globals won't be available at that point). I haven't found any exposed way of doing this. I'm prepared to dig around in the code and figure out how to patch it to allow access to the lexer and parser, but I'd prefer use the "official" mechanism if there is one.


Apr 26, 2012 at 6:40 AM

Sorry, there's no exposed way of doing this.  Should be pretty easy to do though - check out ScriptEngine.Execute(ScriptSource).  I'll definately consider adding this capability in an official manner too.

Jun 5, 2012 at 4:20 PM

You may want to look at Google's closure compiler:

And then I've actually written a little C# Windows Form tool that you might be interested in as well that uses this compiler: