Compiler moonlight


So I have worked on the new jscript compiler for moonlight for 2 months. And I have now a clear idea of how it worked and what is the MS system.

The JScript compiler use standard pattern as lexer and tokenizer but use too some custom things that I will show you.

  1. The Tokenizer read the file and translate it to token and check the lexical grammar. Each token is linked to a keyword, a punctuator or a literal ( indentifier, numeric,…)
  2. The parser will translate the array of token in a compiler object tree aand check the syntax.
  3. The rowan generator will translate the object tree in a runtime object tree wich is common for all scripting language.
  4. The compiler will just manage all called and return the runtime object tree.
  5. All node contain an Emit and a walker function witch seems to be 2 visitors pattern. the first one must Emit code with CodeDOM and the second one must be here to do whatever you want with this tree. For example, we can use it to do some check (as gendarme) or provide code completion in an IDE.

The other big thing of this dll is the Engine system witch is just a system to have full featured and flexible compiler to embded it in whatever you want ( console, GUI, tool, IDE …).

It manage console option in it. For moment, I am a bit stuck on that because ConsoleHost is not overriden. So I guess I have to done it myself.

About status of this assembly, I have done quite all things. The only missing thing is to finished the RowanGenerator and test all with unit test and a small console. Hope I will post screenshot of my console compiler soon 😉

This entry was posted in .NET, development, Mono, open source. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s