8

I would like to understand how Jint, a JavaScript Intrepreter written in C# works. Specifically:

  1. How does it makes use of Antlr?
  2. Which parts, if any, or this project are novel, and which parts represent a port of an existing JS Intrepreter to C#.NET?
  3. In general, how does one go about writing a Javascript Intrepreter in C#? For instance, what's out there already in terms of technology and code, and what do you have to write yourself?
  4. What would be the most challenging parts of writing an interpreter of JS?
Stewart
  • 4,223
  • 6
  • 31
  • 39
Josh Pearce
  • 3,399
  • 1
  • 23
  • 24

2 Answers2

17

I am the author of Jint and before developing it I wrote an article about the techniques which are used in Jint. It was for another project, but this is the exact same architecture.

The article is State of the Art Expression Evaluation

It describes a tool which is also on codeplex, NCalc

Sébastien Ros - MSFT
  • 5,091
  • 29
  • 31
1
  1. Look at the page on CodePlex, it says it uses it.
  2. Nothing is really novel, they're just writing an interpreter of Javascript.
  3. See this
  4. Actually writing it, getting recursion to work, getting the object model to work, etc. And, of course, just getting all the darn operators down correctly.
Community
  • 1
  • 1
Dhaivat Pandya
  • 6,499
  • 4
  • 29
  • 43
  • 1
    4a. (As I understand it) you cannot write a lexer for JavaScript without also writing a parser (unlike many other languages). Details: http://www.mozilla.org/js/language/js20-2002-04/rationale/syntax.html#regular-expressions – Matt Ball May 17 '11 at 02:28