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.
- 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,…)
- The parser will translate the array of token in a compiler object tree aand check the syntax.
- The rowan generator will translate the object tree in a runtime object tree wich is common for all scripting language.
- The compiler will just manage all called and return the runtime object tree.
- 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😉