Bootstrapping: Compiler and Runtime Engine
Bootstrapping: Compiler and Runtime Engine
I will probably be busy with the language specification for another two months, but I am now pretty sure about the architecture of compiler and runtime and have plans for the bootstrapping phase.
The transformation of a textual Eek program to binary code will have three steps, unlike Java and C# which have two. In step one the textual source code is parsed and converted into a XML format. This conversion does not lose any semantics and with the help of optional annotations the formatting can be kept as well. The relationship between the two should be similar to the one between
XQuery and
XQueryX. The intermediate format is intended as an easy way to extract information from the source (e.g. for API documentation) and to allow modifications (like refactoring). In the far future an IDE may also use it as primary storage format instead of text.
Step two is the transformation from the lossless XML format to a language independent format that is intended for distribution, similar to Java's bytecode classes. Unlike Java it will not be a new binary format, but also XML. And it will not be instruction-oriented, but keep the program in a tree structure that's easier to work on. It may be somewhat comparable to gcc's RTL trees, just stack-based and stored on disk. Eek knows assemblies like C# and there should be one file for each assembly.
Step three is the runtime engine that transforms the lossless XML format to executable code. Eventually there should be a compiler, using something like
libjit, that converts the assembly's trees inside the XML file into binary code. I don't think that it will be a real JIT, rather a caching compiler that's invoked on demand.
For the bootstrap process I will write the compilers/converters for the first two step in Java. I already started writing Eek's XML library for Java, to allow easy porting to Eek later. It's not very far yet though. As intermediate solution for step three I will write an interpreter in Java, using the XML library, instead of a real compiler. When all three parts are working (and I can finally write my first Eek programs), I will port the two parts to Eek. And then, finally, write runtime engine/compiler that makes assemblies executable. If everything works out as I hope, that may be in a year or so :)
written at 12:24. (0 Comments, Permalink)