lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

I am pleased to say that there is now a public API defined for the
following components:

a) Lexer
b) Parser
c) AST walking

You can view the API definitions at
https://github.com/dibyendumajumdar/ravi-compiler/blob/master/include/ravi_compiler.h
I decided to create a relatively lower level AST walking api - it is a
bit verbose but it is an attempt to make the use of the API intuitive
and safe.

You can see an example of the AST walking api usage here:
https://github.com/dibyendumajumdar/ravi-compiler/blob/master/tests/tastwalk.c

I will have more details regarding the linear IR generator later but
for now as it is work in progress. The IR is more like standard
compiler IR rather then the Lua bytecode IR. If you are curious, you
can view examples of linear IR output here (note the output contains
AST dumps as well).
https://github.com/dibyendumajumdar/ravi-compiler/blob/master/tests/expected/results.expected

I welcome any feedback.

Regards
Dibyendu

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
>
> All feedback and contributions welcome!
>
> Regards
> Dibyendu
_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org