Lever standalone compiler
Lever programming language is going to receive a compiler written in Lever.
How does it work?
When Lever starts up it needs to attach a compiler into module scope to become capable of compiling its own source files. To achieve this the runtime imports the compiler
as an ordinary module and retrieves the compiler.compile_file
-function.
If compiling is triggered before a compiler is attached, the application fails to load. This is solved by precompiling the compiler.
The earlier compiler that was written in python is still present in the lever source directory. It precompiles everything in the lib/
-directory, which contains the new compiler.
Why do this?
Lever becomes stand-alone. Runtime no longer requires python after it has been built. You may wonder, why did it do?
Lever runtime has been written in RPython. That code is translated into native machine code, which no longer depends on Python. Why compiler was not translated to RPython?
RPython spends long time translating the runtime. 1000 seconds on my computer. Therefore more, more complex items I have in the runtime, longer I spend watching the code translating.
RPython, despite not being C, is still very strict compared to Python or Lever. Translation from Python to Lever was very much a rewrite that allowed to revise the code meanwhile. Translation from Python to RPython would have been more than that.
Unlike the RPython code, code written in Lever naturally becomes exposed through its runtime. This means that the grammar language, chart parsing, tokenizing and pretty much everything else required by the compiler and the compiler itself became exposed and available in the lib/
.
Outcome of not embedding compiler into the runtime causes lot of other features implemented outside the long-translating runtime. Further exposing important functionality to the user scripts.
Future for Lever
Standalone compiler was the requirement for the 0.8.0 release, to make it easier to just download lever executable and start hacking away. It was important because I am going to make a whole virtual reality programming environment that runs in Lever.
That's the niche Lever will take. Without a niche it'd be just an another, run off the mill, neatly designed language that comes with customizable syntax.