[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Development announcement - Ravi/Lua Compiler project
- From: Dibyendu Majumdar <mobile@...>
- Date: Sun, 8 Nov 2020 21:59:14 +0000
On Fri, 21 Feb 2020 at 21:55, Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
>
> Lua's inbuilt parser and code generator is a work of art, very compact
> and low overhead but extremely fast. It uses minimal memory and
> produces bytecodes as it parses the source code (single pass
> compiler). This is great for Lua and Ravi given the use cases of these
> languages, but makes the parser and code generator quite hard to
> understand, play with, or reuse in tools such as IDEs. It also makes
> it harder to perform any advanced type checking or performance
> optimizations.
>
> I am pleased to announce a new project to create a Lua/Ravi parser and
> code generator that is not a replacement for the default one in
> Lua/Ravi but can be used for more specialised code generation, as well
> as as a means of understanding how the parser and code generator
> works. My hope is that it will enable the study of Lua implementation
> in educational institutions, as I intend to use classical methods of
> compilation. Moreover, ease of maintenance is a bigger priority than
> sheer memory or performance efficiency.
>
> The project was initially part of Ravi because I was reusing the Lua
> lexer. However, I have now split this off into a standalone project
> independent of Ravi.
>
> The project is currently under development. You can view the code at:
>
> https://github.com/dibyendumajumdar/ravi-compiler
>
Hi.
I have been working on and off on this new compiler project. I am
pleased to say that it has now got to a stage where I can use it
inside Ravi for a subset of code.
Although a lot more work needs to be done, this effort is already
producing better results than the existing JIT compiler in Ravi.
Key points:
* The pipeline starts from Lua/Ravi source instead of bytecodes
* The compiler creates AST during the parse phase
* This is converted to Linear IR
* From the Linear IR C code is generated
* Finally this C code is compiled using MIR JIT backend
You can see some examples of what works and the output the compiler
generates here:
https://github.com/dibyendumajumdar/ravi/tree/master/tests/comptests
As mentioned there is still a lot of work to do.
Regards
Dibyendu