How can I reuse my javascript code between client and server?

Posted by Chris Farmer on Stack Overflow See other posts from Stack Overflow or by Chris Farmer
Published on 2010-05-21T12:53:21Z Indexed on 2010/05/21 13:00 UTC
Read the original article Hit count: 346

Filed under:
|
|

I have some javascript code that includes an ANTLR-generated lexer and parser, and some associated syntax tree evaluation functionality. This code runs in the browser in my web app to support users who author code snippets which process scientific data.

Now I'd like to do some additional background processing on the server using the same generated parser. I would prefer not to have to re-implement this stuff in C# and have multiple bits of code that did the exact same thing. Performance isn't as critical to me as eliminating duplication, since this is a background process. So, how can I call into my javascript code from C#? And how can I format my script so that it plays nicely with my .NET web app?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about .NET